question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed lookup generates `Cannot read property 'geometry' of null` error

See original GitHub issue

Consider performing a lookup that attaches a topjson as a secondary data source to a standard data table as primary. The specification below shows an example of doing this:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "data": {
    "values": [{"fips": 499999, "state":"UT"},
               {"fips": 4, "state":"AZ"},
               {"fips": 8, "state":"CO"},
               {"fips": 35, "state":"NM"}]
  },
  "transform": [
    {
      "lookup": "fips",
      "from": {
        "data": {
          "url": "https://vega.github.io/vega-lite/data/us-10m.json",
          "format": { "type": "topojson","feature": "states"}
        },
        "key": "id"
      },
      "as": "geo"
    }
  ],
  "mark": "geoshape",
  "encoding": {
    "shape": {"field": "geo","type": "geojson"},
    "color": {"field": "state","type": "nominal"}
  }
}

However, if any of the lookups fail (in the example above Utah’s FIPS code is incorrect as 499999), the entire specification fails with the error Cannot read property 'geometry' of null.

While this can be remedied by filtering out invalid geoshapes ( {"filter" : "isValid(datum.geo)"}), this shouldn’t be necessary. In contrast, when the topojson is primary and the table secondary, failed lookups simply don’t get encoded, without any need to perform explicit filtering. It would be good to make this default behaviour for topojson as secondary too.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
domoritzcommented, Dec 3, 2020

I have an idea. I what if we always generate a filter for geoshapes? We could make that part of the filterinvalid we already have. Essentially, we add the filter because of the geo mark, and not because of the lookup.

0reactions
jwoLondoncommented, Dec 3, 2020

That sounds like an ideal solution. I don’t think there would ever be a situation where a geoshape containing nulls would be needed, so this should have no problematic downstream effects.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property '__e3_' of null
I'm getting the error Uncaught TypeError: Cannot read property '__e3_' of null randomly when dragging a polygon inside a google map.
Read more >
Uncaught (in promise) TypeError: Cannot read prope...
I am using ArcGIS api JS with a layer of polygons. When I click on one polygon, it creates a layer of points...
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >
Error Messages | Maps JavaScript API - Google Developers
You may have supplied an incorrect version number in your script element. Please make sure you are using a correct version number. See...
Read more >
TypeError: cannot use 'in' operator to search for 'x' in 'y'
Make sure the object you are inspecting isn't actually null or undefined . const foo = null; "bar" in foo; // ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found