1

I queried some ArcGIS JSON from "Global Forest Watch API", then converted it to GeoJSON using a web service.

When I try to add it to my Leaflet map I get "Invalid geojson object".

The GeoJSON looks like this:

 {
      "type": "FeatureCollection",
      "features": [
        {
          "type": "Feature",
          "geometry": {
            "type": "Polygon",
            "coordinates": [
              [
                [
              43.36960659625765,
              -22.252918060115043
            ],
            [
              43.3694190980949,
              -22.25288200352778
            ],
            [
              43.36917877180695,
              -22.252807617249033
            ],
            [
              43.36895751944741,
              -22.25271034218535
            ],
            [
              48.97787106415192,
              -16.582301013579393
            ],
            [
              48.977741977143914,
              -16.582301013579393
            ],
            [
              48.97748380402619,
              -16.582301013579393
            ],
            [
              48.97722563001018,
              -16.58217192710138
                ]
              ]
            ]
          },
          "properties": {
            "OBJECTID": 1974,
            "CLASS": "IFL2016",
            "AREA_HA": 58083.0137401,
            "CLASS_NAME": "IFL2016",
            "AREA": 580830137.401,
            "GlobalID": "{94379FB6-6962-498B-A9DC-30FEC0EE1D49}",
            "Shape_Length": 360660.35501490464,
            "Shape_Area": 633182785.1308166
          },
          "id": 6
        }
      ]
    }

NOTE - the list of coordinate is much longer, I only included 2 for this purpose

1 Answer 1

1

You can test GeoJSON here: http://geojsonlint.com/

In this case, it says:

Line 9: a LinearRing of coordinates needs to have four or more positions

Line 9: the first and last positions in a LinearRing of coordinates must be the same

If your orginal JSON contains more coordinate pairs, please include at least 4, including the last one.

2
  • Thanks for the answer. I ran the entire geoJSON through that site and had no problems. Unsure why I cannot display it in leaflet.
    – Stuey17
    Commented Oct 30, 2019 at 12:45
  • Edit - I solved the problem, thanks.
    – Stuey17
    Commented Oct 30, 2019 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.