Failed lookup generates `Cannot read property 'geometry' of null` error
See original GitHub issueConsider 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:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.