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.

Problem accessing geojson properties when generated inline

See original GitHub issue

Perhaps I am missing something, but there appears to be a problem in accessing inline geoJson objects.

The following spec, which loads a geoJson file works as expected:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "width": 200, "height": 200,
  "data": {
    "url": "https://gist.githubusercontent.com/jwoLondon/6caab27b0d131c74c194efd943389201/raw/e9ea15b56001dfac9c3795dff4f2a0f67dbfc710/geojsontest.json",
    "format": { "type": "json", "property":  "features" }
  },
  "projection": { "type":  "orthographic" },
  "encoding": {
    "color": {
      "field": "properties.myRegionName",
      "type": "nominal"
    }
  },
  "mark": "geoshape"
}

But if I generate the same content inline, I do not seem to be able to access the myRegionName property:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "width": 200, "height": 200,
  "data": {
    "values": [
    {
      "type": "FeatureCollection",
      "features": [
        {
          "type": "Feature",
          "geometry": {
            "type": "Polygon",
            "coordinates": [ [ [-3,52], [4,52], [4,45], [-3,45], [-3,52] ] ]
          },
          "properties": { "myRegionName": "Southern region" }
        },{
            "type": "Feature",
            "geometry": {
              "type": "Polygon",
              "coordinates": [ [ [-3,59], [4,59], [4,52], [-3,52], [-3,59] ] ]
            },
            "properties": { "myRegionName": "Northern region" }
          }
        ]
      }
    ],
    "format": { "type": "json", "property": "features" }
  },
  "projection": { "type": "orthographic" },
  "encoding": {
    "color": {
      "field": "properties.myRegionName",
      "type": "nominal"
    }
  },
  "mark": "geoshape"
}

This spec generates the error : TypeError: undefined is not an object (evaluating 'e.hasOwnProperty’)

Is this perhaps related to one of the issues in #3369, or is there some other way of accessing nested inline fields?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jwoLondoncommented, May 19, 2018

Thanks @iliatimofeev, that’s helpful and clarifies where the problem lies, and so as far as I can see once the documentation is updated this issue can be closed.

0reactions
ratnanilcommented, Dec 25, 2022

Ok, so you have something planned? Would suggestions for some minimal examples be helpful?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with loading GeoJSON file in OpenLayers generated ...
The problem seems to be that the features-array in your featurecollection contains three features, two with geometry:none and one with just ...
Read more >
Why inline geojson source must have a properties ... - GitHub
When set the "properties": { "id": 1 }, , works as expected. Note that mapbox-gl-js does not have this problem.
Read more >
Chapter 7 GeoJSON | Introduction to Web Mapping
The "coordinates" property is specified with an array. The basic unit of the coordinate array is the point coordinate. According to the GeoJSON...
Read more >
geojson - Leaflet - map layers not loading - Stack Overflow
I am getting the error: Uncaught TypeError: Cannot read property 'features' of null at Object.t.choropleth.n.exports [as choropleth]. Is this a ...
Read more >
Work with markers in Mapbox.js | Help
You can add markers to your map using Leaflet or with GeoJSON using Mapbox.js. ... of the Mapbox D.C. and San Francisco offices...
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