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.
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": { "name": "Brandenburg Gate", "built": 1791 },
"geometry": {
"type": "Point",
"coordinates": [13.377704, 52.516275]
}
}
]
}Convert GeoJSON files
- Convert GeoJSON to KML— Convert a GeoJSON file to KML for Google Earth
- Convert GeoJSON to Shapefile— Convert a GeoJSON file to a Shapefile ZIP (.shp, .shx, .dbf, .prj)
- Convert GeoJSON to GPX— Convert a GeoJSON file to a GPS track/route file
- Convert GeoJSON to CSV (lat/lng)— Extract Point features from GeoJSON to a lat/lng CSV
- Convert GeoJSON to TopoJSON— Convert GeoJSON to compact TopoJSON with shared borders for D3 and web maps
- Convert GeoJSON to SVG map— Render GeoJSON geometry as a standalone SVG map
- Convert GeoJSON to WKT— Convert GeoJSON geometry/features to WKT text
- Convert GeoJSON to KMZ— Convert a GeoJSON file to a compressed KMZ archive for Google Earth
- Convert Shapefile to GeoJSON— Convert a Shapefile ZIP (.shp + .dbf) to GeoJSON
- Convert KML to GeoJSON— Convert a KML map file to GeoJSON
- Convert GPX to GeoJSON— Convert a GPS track/route file to GeoJSON
- Convert CSV to GeoJSON— Convert a CSV with latitude and longitude columns to a GeoJSON FeatureCollection
- Convert TopoJSON to GeoJSON— Convert TopoJSON topology objects to GeoJSON features
- Convert WKT to GeoJSON— Parse Well-Known Text geometry into a GeoJSON FeatureCollection
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.