OmniConvert

GeoJSON Format Explained: Structure, Coordinates and Examples

GeoJSON is a JSON format for geographic features: points, lines and polygons with their attributes. It is the standard format for web maps and is read natively by Leaflet, Mapbox, OpenLayers, D3, QGIS and most GIS software. GitHub even renders .geojson files as maps.

The current specification is RFC 7946, published by the IETF in 2016.

Example: A FeatureCollection with one point
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": { "name": "Brandenburg Gate", "built": 1791 },
      "geometry": {
        "type": "Point",
        "coordinates": [13.377704, 52.516275]
      }
    }
  ]
}

Convert GeoJSON files

Geometry types

A Feature wraps one geometry together with a properties object for its attributes, and a FeatureCollection holds a list of features.

  • Point and MultiPoint
  • LineString and MultiLineString
  • Polygon and MultiPolygon: the first ring is the outer boundary, any further rings are holes
  • GeometryCollection: a mix of geometries

Coordinate rules that trip people up

  • Order is [longitude, latitude], the reverse of how coordinates are usually spoken
  • RFC 7946 GeoJSON is always WGS 84 longitude/latitude. The older "crs" member was removed from the standard, so projected coordinates (for example UTM metres) are not valid GeoJSON
  • Polygon rings must be closed: the last position repeats the first
  • Exterior rings should run counter-clockwise and holes clockwise (the right-hand rule)
  • Six decimal places is about 10 cm of precision, enough for almost all uses; more digits only make the file bigger

GeoJSON vs TopoJSON, KML and Shapefile

  • TopoJSON: stores shared borders once, so files with neighbouring polygons are much smaller; common with D3
  • KML: XML with styling, made for Google Earth
  • Shapefile: the traditional desktop GIS format, a set of files with strict field limits

How to open a GeoJSON file

  • geojson.io: view and edit in the browser
  • QGIS: drag the file into the map
  • GitHub: commit a .geojson file and open it to see a map
  • Any text editor or JSON viewer

Frequently Asked Questions

Is it [lat, lng] or [lng, lat] in GeoJSON?
Always [longitude, latitude], optionally followed by altitude. Leaflet's L.latLng uses the opposite order, which is a common source of mistakes.
Why does my GeoJSON show up in the wrong place?
Usually because latitude and longitude are swapped, or the coordinates are in a projected system such as UTM instead of WGS 84 degrees.

More format guides