Working with GeoJSON: Mapping and Geospatial Data in JSON

geojsonjsongismapping

GeoJSON is a standard format for encoding geographic data structures using JSON. It's used by mapping libraries, GIS tools, and location-based services.

GeoJSON Structure

Every GeoJSON object has a type property:

{

"type": "Feature",

"geometry": {

"type": "Point",

"coordinates": [-73.9857, 40.7484]

},

"properties": {

"name": "Empire State Building",

"city": "New York"

}

}

Geometry Types

GeoJSON supports seven geometry types:

Point — Single location:

{ "type": "Point", "coordinates": [102.0, 0.5] }

LineString — Path between points:

{ "type": "LineString", "coordinates": [[102.0, 0.0], [103.0, 1.0]] }

Polygon — Area with boundary:

{

"type": "Polygon",

"coordinates": [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]]

}

Other types: MultiPoint, MultiLineString, MultiPolygon, GeometryCollection.

Feature Collection

Group multiple features:

{

"type": "FeatureCollection",

"features": [

{

"type": "Feature",

"geometry": { "type": "Point", "coordinates": [-73.9857, 40.7484] },

"properties": { "name": "Empire State Building" }

},

{

"type": "Feature",

"geometry": { "type": "Point", "coordinates": [-73.9851, 40.7589] },

"properties": { "name": "Rockefeller Center" }

}

]

}

Coordinate Order

GeoJSON uses [longitude, latitude] (x, y) order, not [lat, lng]. This is a common source of errors.

Popular Libraries

  • Mapbox GL JS — Interactive maps with GeoJSON
  • Leaflet — Lightweight map library
  • Turf.js — Geospatial analysis in JavaScript
  • GeoPandas — Python geospatial data analysis
  • Tips

  • Use "crs" property if not using default WGS84
  • Keep coordinate precision to 6 decimal places (~0.1m accuracy)
  • Validate GeoJSON with tools before using in production
  • Use FeatureCollections for multiple geometries
  • Validate your GeoJSON with our JSON Validator and explore structure with JSON Viewer.

    Related Tools