Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This question already has an answer here:

I am new to JSON and GeoJSON and would like to start to use this but I am a little confused about some things. Perhaps you can help me out:

1) Is there a GeoJSON validator out there? 2) Is the text below valid GeoJSON? To be a valid GeoJSON file do all the GeoJSON objects have to live in a GeoJSON array or can they be stored willie nellie as below?

The data below is a return from the geocouch example on github:

{
"rows": [
    {
        "id": "augsburg",
        "bbox": [
            10.898333,
            48.371667,
            10.898333,
            48.371667
        ],
        "geometry": {
            "type": "Point",
            "coordinates": [
                10.898333,
                48.371667
            ]
        },
        "value": [
            "augsburg",
            [
                10.898333,
                48.371667
            ]
        ]
    },
    {
        "id": "oakland",
        "bbox": [
            -122.270833,
            37.804444,
            -122.270833,
            37.804444
        ],
        "geometry": {
            "type": "Point",
            "coordinates": [
                -122.270833,
                37.804444
            ]
        },
        "value": [
            "oakland",
            [
                -122.270833,
                37.804444
            ]
        ]
    }
]

}

share|improve this question

marked as duplicate by Devdatta Tengshe, PolyGeo, iant yesterday

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 4 down vote accepted

GeoJSON is also simply JSON, so I usually run it through the validator at http://jsonlint.com/ to check it passes this first. Unfortunately I don't think there is an online validator specific to GeoJSON.

You can however use the GDAL GeoJSON driver to try and load or get information about the dataset - if it fails it's invalid. You can also use the Python Shapely library to check features as it uses a GeoJSON-like notation for geometry.

Your example seems to be missing some type attributes - features must have a type attribute and can be grouped in collections if needed. The key criteria for GeoJSON objects (from the spec) are:

  • GeoJSON always consists of a single object
  • The GeoJSON object may have any number of members (name/value pairs).
  • The GeoJSON object must have a member with the name "type"
  • The value of the type member must be one of: "Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection", "Feature", or "FeatureCollection". The case of the type member values must be as shown here.
  • A GeoJSON object may have an optional "crs" member, the value of which must be a coordinate reference system object
  • A GeoJSON object may have a "bbox" member, the value of which must be a bounding box array

The GDAL driver also had issues if I did not set a "crs" value

For more details take a look at the full GeoJSON specification and examples.

I also found the GeoJSON from CloudMade's services very useful for comparison - http://developers.cloudmade.com/projects/geocoding/examples

share|improve this answer
GeoJSON validation will be problematic. Does a "geometry" property have to be paired with a "type:Feature" property? To be a GeoJSON Feature, yes. But do objects necessarily have to be contained within a GeoJSON FeatureCollection to be valid Features? I argue not. The object above (with "rows") isn't a Feature Collection but it does contain Features (or almost-Features). – sgillies Jun 17 '11 at 22:59
@sgillies - well having one of the creators of the spec on this question certainly helps ;-) While you're here - according to the spec a CRS is not required correct? The GDAL driver seems to crash without it (in the last version I tested) – geographika Jun 17 '11 at 23:10
updated to state features need not be in feature collections and details from spec – geographika Jun 17 '11 at 23:16

I don't know of a validator but there is a spec (http://geojson.org/geojson-spec.html) you can consult.

share|improve this answer

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