Yuval Adam
Yuval Adam

Reputation: 165242

Why is this GeoJSON file invalid?

I am trying to work with a GeoJSON file that looks like so:

[
    {
        "geometry": {
            "type": "Point", 
            "coordinates": [
                35.109876, 
                32.711323
            ]
        }, 
        "type": "Feature", 
        "properties": {
            "name": "אורנים"
        }
    },
    // ...
]

(the full file can be found at: https://raw.githubusercontent.com/yuvadm/geolocations-il/master/cities.geojson)

This file, however, fails to render on Github, and it also fails validation through http://geojsonlint.com/ which claims that Data was not a JSON object. This file does however validate when run through a JSON linter.

Any idea why this isn't a valid GeoJSON?

Upvotes: 2

Views: 1110

Answers (2)

Yuval Adam
Yuval Adam

Reputation: 165242

Turns out the GeoJSON spec does support collections, they just need to be wrapped properly:

{
    "type": "FeatureCollection",
    "features": [
        {
            "geometry": {
                "type": "Point", 
                "coordinates": [
                    35.109876, 
                    32.711323
                ]
            }, 
            "type": "Feature", 
            "properties": {
                "name": "אורנים"
            }
        },
        // ...
    ]
}

Upvotes: 1

Knut
Knut

Reputation: 1790

As single elements of your list verifies on GeoJSONlint and the file itself is valid JSON I read the GeoJSON spec and what I saw there is it seems not to support lists of GeoJSON objects. So it should be able to verify each single element of your list but not the list as a whole…

Upvotes: 2

Related Questions