Introduction

GeoJSON is a geospatial data interchange format based on JavaScript Object Notation (JSON). It defines several types of JSON objects and the manner in which they are combined to represent data about geographic features, their properties, and their spatial extents. GeoJSON uses a geographic coordinate reference system, World Geodetic System 1984, and units of decimal degrees. A GeoJSON object may represent a region of space (a Geometry), a spatially bounded entity (a Feature), or a list of Features (a FeatureCollection)

Example

 { "type": "FeatureCollection",
    "features": [
      { "type": "Feature",
        "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
        "properties": {"prop0": "value0"}
        },
      { "type": "Feature",
        "geometry": {
          "type": "LineString",
          "coordinates": [
            [102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]
            ]
          },
        "properties": {
          "prop0": "value0",
          "prop1": 0.0
          }
        }
       ]
     }

There a quite a few important points to note in the above example

  • The order of elements (coordinates) must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Here is a good reference to check who is on which side of the LatLng debate
  • The feature collection can support multiple different geometry types

GeoJSON supports the following geometry types:

  • Point
  • LineString
  • Polygon
  • MultiPoint
  • MultiLineString
  • MultiPolygon
  • GeometryCollection

Is GeoJSON same as JSON?

While GeoJSON is a geospatial data interchange format based on JSON but GeoJSON follows a well specified Open data standard. For details read here

JSON because of its simplicity, flexibility and native support in Javascript has become the de-facto standard for the web developers similarly GeoJSON is now the de-facto standard for majority of OGC standards complaint Maps platform and libraries. Let us take a look at some examples

  1. Leaflet – load geojson example
  2. Openlayers – load geojson example
  3. Mapbox – load geojson data example
  4. Google Maps – geospatial analytics using GeoJSON in BigQuery
  5. PostGIS – spatial extension for PostgreSQL database. You can store data is GeoJSON objects
  6. MongoDB – you can store geospatial data as GeoJSON objects

Convert your data to GeoJSON

There are several open source tools for converting other geospatial data formats to GeoJSON, including:

  • togeojson, a Node package for converting KML and GPX (XML formats)
  • ogr2ogr, a vector data conversion tool
  • geojson.io, a Mapbox developer tool for creating, converting, and editing GeoJSON

Happy Mapping !!!