Understanding GeoJSON: A Complete Guide to Representing Geographic Data in JSON
In today’s data-driven world, location is everything — whether you’re building a mapping application, processing delivery routes, visualizing climate data, or tracking wildlife migration.
When it comes to representing geographic data in a human-readable, machine-friendly, and web-ready format, one format has become the go-to standard: GeoJSON.
This article will walk you through what GeoJSON is, its structure, use cases, real-world examples, and best practices to avoid common pitfalls.
What is GeoJSON?
GeoJSON is an open standard format for representing geographic data structures using JSON (JavaScript Object Notation).
It’s essentially JSON with a geographical twist, designed to store geometry (shapes like points, lines, polygons) and their associated properties.
Some key points:
- Based on WGS84 coordinate reference system (longitude, latitude).
- Supports multiple geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.
- Easily used with mapping libraries like Leaflet, Mapbox GL, OpenLayers, and databases like PostGIS.
Why GeoJSON?
There are other spatial formats like KML (used by Google Earth) or Shapefile (common in GIS systems). So why GeoJSON?
- Human-readable: It's just JSON — easy to understand and debug.
- Lightweight: No bulky binary data, just text.
- Web-friendly: Perfect for APIs and JavaScript-based maps.
- Interoperable: Supported by major GIS tools and web frameworks.
Core Structure of GeoJSON
At its heart, a GeoJSON object always has:
- A type field ("Feature","FeatureCollection", or a geometry type).
- A geometry field describing the shape.
- An optional properties field for metadata.
Example of a simple GeoJSON Point:
{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "name": "Sample Location" } }
Geometry Types in GeoJSON
1. Point
A Point represents a single location in space.
It’s the simplest geometry type in GeoJSON — just one coordinate pair (longitude, latitude), and optionally an altitude.
Basic Structure
{ "type": "Point", "coordinates": [longitude, latitude] }
With Altitude
GeoJSON supports a third number for elevation in meters above sea level:
{ "type": "Point", "coordinates": [longitude, latitude, altitude] }
For example:
{ "type": "Point", "coordinates": [125.6, 10.1, 350] }
This means:
- Longitude: 125.6° E
- Latitude: 10.1° N
- Altitude: 350 metersabove sea level
When to Use a Point
- Marking a specific location: store, restaurant, parking spot.
- Pinpointing GPS coordinates from a tracking device.
- Representing a sensor location (e.g., a weather station).
Common Gotchas
- Coordinate Order: Always [longitude, latitude]— easy to mix up.
- Altitude is Optional: If omitted, it's assumed to be 0 or irrelevant.
- Precision: Too many decimal places can make your file unnecessarily big — 6 decimal places is enough for sub-meter accuracy.
Example with Metadata
Points are often wrapped in a Feature to include descriptive properties:
{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "name": "Sample Location", "category": "Restaurant" } }
2. MultiPoint
A MultiPoint is simply a collection of multiple Points.
Think of it as "several locations in one geometry."
Basic Structure
{ "type": "MultiPoint", "coordinates": [ [longitude1, latitude1], [longitude2, latitude2], [longitude3, latitude3] ] }
When to Use a MultiPoint
- Representing multiple addresses or POIs in one record.
- Grouping sensor stations in a region.
- Storing stop points along a route (when you don’t need lines connecting them).
Example
{ "type": "Feature", "geometry": { "type": "MultiPoint", "coordinates": [ [102.0, 0.5], [103.0, 1.0], [104.0, 0.5] ] }, "properties": { "name": "Service Points", "category": "ATM" } }
Pro Tip
While you can store multiple Points inside a FeatureCollection, using MultiPoint can be more efficient when:
- All points share the same properties (e.g., all belong to the same company).
- You want to store them as one geometry object instead of many Features.
3. LineString
A LineString represents a sequence of two or more points connected by straight lines.
Think of it as “a path between coordinates.”
Basic Structure
{ "type": "LineString", "coordinates": [ [longitude1, latitude1], [longitude2, latitude2], [longitude3, latitude3] ] }
Rules for LineString
- Must have at least two coordinate pairs.
- Points are connected in the order listed.
- No restriction that it must form a closed loop (unlike a polygon).
Example
A walking trail from Point A → Point B → Point C:
{ "type": "Feature", "geometry": { "type": "LineString", "coordinates": [ [102.0, 0.0], [103.0, 1.0], [104.0, 0.0] ] }, "properties": { "name": "Trail A-C" } }
When to Use LineString
- Roads, railways, hiking paths.
- River centerlines.
- Ship or flight routes.
- Drawing a boundary without enclosing it.
Gotchas
- Coordinate order matters — reversing them reverses the direction of the line (important for navigation data).
- Don’t use for shapes that need to be closed — use Polygon instead.
4. MultiLineString
A MultiLineString is a collection of multiple LineStrings.
Think of it as “several separate paths in one geometry.”
Basic Structure
{ "type": "MultiLineString", "coordinates": [ [ [longitude1, latitude1], [longitude2, latitude2] ], [ [longitude3, latitude3], [longitude4, latitude4], [longitude5, latitude5] ] ] }
Example
Two hiking trails in the same park:
{ "type": "Feature", "geometry": { "type": "MultiLineString", "coordinates": [ [ [102.0, 0.0], [103.0, 1.0] ], [ [104.0, 0.0], [105.0, 1.0], [106.0, 0.0] ] ] }, "properties": { "name": "Park Trails" } }
When to Use MultiLineString
- Bus routes with multiple unconnected segments.
- Multiple river sections.
- Subway lines that aren’t continuous in one geometry.
- Storing multiple boundary lines in one record.
Pro Tip
If your dataset has many separate paths with different attributes, use FeatureCollection of LineStrings instead of one MultiLineString.
If all paths share the same attributes (e.g., “Metro Line 1”), MultiLineString is more efficient.
5. Polygon
A Polygon represents an enclosed shape with one or more rings (loops).
The first ring is the outer boundary, and any additional rings are holes inside the polygon.
Basic Structure
{ "type": "Polygon", "coordinates": [ [ [longitude1, latitude1], [longitude2, latitude2], [longitude3, latitude3], [longitude1, latitude1] // same as first point, closes the loop ] ] }
Rules for Polygons
- Each ring must have at least four points (first and last are identical to close the loop).
- Coordinates in a ring are connected in order.
- The first ring = outer boundary; additional rings = holes.
Example: Simple Polygon
A rectangular park boundary:
{ "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ] ] }, "properties": { "name": "Central Park" } }
Example: Polygon with a Hole
Outer ring = island boundary, inner ring = a lake in the island.
{ "type": "Polygon", "coordinates": [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ], [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ] ] }
When to Use Polygon
- Representing administrative boundaries (countries, cities).
- Drawing building footprints.
- Marking zones for geofencing.
- Representing areas like lakes or parks.
Gotchas
- First and last coordinate must match.
- Ring direction (clockwise vs counterclockwise) can matter in some GIS tools, especially for holes.
- Complex polygons can become heavy in file size — consider simplification.
6. MultiPolygon
A MultiPolygon is a collection of multiple Polygons.
Think of it as “several separate areas” in one geometry.
Basic Structure
{ "type": "MultiPolygon", "coordinates": [ [ [ // First Polygon [ [lon1, lat1], [lon2, lat2], [lon3, lat3], [lon1, lat1] ] ] ], [ [ // Second Polygon [ [lon4, lat4], [lon5, lat5], [lon6, lat6], [lon4, lat4] ] ] ] ] }
Example
Two islands:
{ "type": "Feature", "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0] ] ], [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ] ] ] }, "properties": { "name": "Island Group" } }
When to Use MultiPolygon
- Countries with multiple islands (e.g., Indonesia, Japan).
- Multiple unconnected land parcels.
- Complex geofencing zones.
Pro Tip
If each polygon needs different metadata (e.g., different names), store them as separate Features in a FeatureCollection instead of one MultiPolygon.
7. GeometryCollection
A GeometryCollection is a single object that contains multiple geometry objects of any type — Points, LineStrings, Polygons, etc.
Think of it as a basket of different shapes in one geometry field.
It’s different from MultiPoint, MultiLineString, and MultiPolygon because those can only contain one type of geometry, while a GeometryCollection can mix types.
Basic Structure
{ "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [100.0, 0.0] }, { "type": "LineString", "coordinates": [ [101.0, 0.0], [102.0, 1.0] ] } ] }
When to Use GeometryCollection
- Representing complex shapes made of different geometry types.
- Grouping related features where separating them into multiple Features is unnecessary.
- Storing a combination of Points and shapes for one entity (e.g., a delivery zone polygon and its central depot point).
Example
A building with:
- A Point for the main entrance.
- A Polygon for its footprint.
{ "type": "Feature", "geometry": { "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [102.0, 0.5] }, { "type": "Polygon", "coordinates": [ [ [102.0, 0.0], [103.0, 0.0], [103.0, 1.0], [102.0, 1.0], [102.0, 0.0] ] ] } ] }, "properties": { "name": "Main Office" } }
Gotchas
- If geometries have different properties, consider using multiple Features in a FeatureCollection instead.
- Keep in mind that not all mapping libraries handle GeometryCollection efficiently — test first.
- Can get messy if used excessively — use sparingly for logically related shapes.
Real-World Examples of GeoJSON Usage
GeoJSON is not just for maps — it’s used in logistics, urban planning, disaster management, agriculture, environmental science, and even gaming.
Here are some examples based on each geometry type:
1. Point
📍 Represents a single location.
- Food Delivery App – Store the GPS location of restaurants and customers for routing.
- IoT Sensors – Weather stations, air quality monitors, or traffic cameras.
- Ride-Hailing Services – Pickup and drop-off points for trips.
- E-commerce Warehousing – Warehouse entrance coordinates.
2. MultiPoint
📍📍 Represents multiple separate points in one object.
- Retail Chain – Locations of all stores in a city.
- ATM / Bank Branch Locator – All ATMs for a bank brand.
- Wildlife Research – All GPS sightings of a tagged animal in a day.
3. LineString
➖ Represents a single connected path.
- Public Transport – A single bus route from start to end.
- Hiking Apps – A single hiking trail.
- Delivery Routing – The path taken by a courier.
- Drone Flight Path – Waypoints for aerial mapping.
4. MultiLineString
〰️〰️ Represents multiple unconnected paths.
- Railway Systems – All segments of a railway line with gaps between them.
- Maritime Routes – Shipping lanes in different seas.
- River Mapping – Tributaries of a river system.
- Fiber Optic Network – Different unconnected cable sections.
5. Polygon
⬜ Represents a single enclosed area.
- City Boundaries – Administrative limits of a municipality.
- Land Parcels – A farmer’s field boundary.
- Geofencing – A delivery area where orders are allowed.
- Disaster Mapping – Flooded area outline.
6. MultiPolygon
🗾 Represents multiple separate enclosed areas.
- Island Nations – Indonesia, Japan, or the Philippines boundaries.
- Real Estate – Multiple non-contiguous land parcels owned by a company.
- Protected Areas – Multiple wildlife sanctuaries under one category.
- Airport Zones – Different restricted airspaces around an airport.
7. GeometryCollection
🧩 Mixes different geometry types.
- Tourism Maps – A city landmark (Point) + walking path (LineString) + park boundary (Polygon) in one object.
- Campus Maps – Buildings (Polygons) + entrances (Points) + roads (LineStrings).
- Construction Projects – Site boundary (Polygon) + planned road (LineString) + crane position (Point).
Cross-Industry Use Cases
Urban Planning
- Mapping utility lines, zoning boundaries, and public transport stops.
- Planning new infrastructure with precise geospatial data.
Logistics & Delivery
- Calculating optimal delivery routes (LineString).
- Determining coverage zones for delivery (Polygon).
- Tracking delivery vehicles in real time (Point).
Disaster Response
- Mapping wildfire spread areas (Polygon).
- Locating temporary shelters (Point).
- Defining evacuation routes (LineString).
Environmental Science
- Tracking deforestation areas (MultiPolygon).
- Mapping migration paths of animals (LineString / MultiLineString).
- Monitoring coral reef locations (MultiPoint).
Gaming & Augmented Reality
- Geofencing game zones (Polygon).
- Defining AR spawn points (MultiPoint).
- Mapping walking trails for exploration games (LineString).
Best Practices for GeoJSON
1. Use the Correct Geometry Types
- Pick the right geometry:
- Point– single location (e.g., a bus stop)
- MultiPoint– multiple discrete points (e.g., fire hydrants)
- LineString– connected points in order (e.g., a road segment)
- MultiLineString– multiple separate lines (e.g., subway lines)
- Polygon– closed shape (first and last coordinates match)
- MultiPolygon– multiple polygons (e.g., a country with islands)
- Avoid “geometry misuse” – don’t store a polygon as a MultiPolygonwith one polygon unless truly needed.
2. Keep Coordinates Clean
- Use decimal degrees (WGS84, EPSG:4326) — e.g., [longitude, latitude].
- Keep a consistent precision — typically 5–7 decimal places (~1 meter accuracy).
- Avoid unnecessary extra decimal places (increases file size without improving accuracy).
- Validate winding order:
-
Outer rings → counterclockwise
-
Inner rings (holes) → clockwise
(Some GIS software breaks if this is wrong.)
-
3. Store Only What You Need
- Put non-spatial data in properties— avoid overloading geometry with metadata.
- Remove unused fields and null values to keep payloads small.
- Use short property names if file size matters (e.g., "id"instead of"identifier").
4. Optimize for Performance
- If dealing with large datasets:
- Simplify geometries for web display (reduce vertex count).
- Split large datasets into tiles or bounding-box queries (GeoJSON doesn’t need to be all in one file).
- Compress when transmitting over network (Gzip reduces file size by ~80–90%).
- Consider GeoJSON sequences (newline-delimited GeoJSON) for streaming.
5. Ensure Compatibility
- Always wrap data in a FeatureCollection if multiple features are included:
- Include a bbox(bounding box) at Feature or FeatureCollection level for quick spatial indexing.
- Validate with tools like:
- geojson.io
- Mapbox GeoJSONLint
6. Make It Interoperable
- If integrating with PostGIS:
- Ensure SRID is set to 4326.
- Store geometry as GEOMETRYtype and convert to/from GeoJSON withST_AsGeoJSON()/ST_GeomFromGeoJSON().
- For APIs, keep geometry and properties separate so clients can handle them independently.
7. Think About Real-Time Usage
- If sending live updates (e.g., moving vehicles):
- Send only changed features (diffs), not the whole dataset.
- Keep payloads small — maybe send just Pointcoordinates in minimal GeoJSON.
8. Test in Multiple Viewers
- Always test your GeoJSON in:
-
Leaflet
-
Mapbox GL JS
-
QGIS
(They have different tolerance levels for malformed GeoJSON.)
-
9. Performance
- If you’re going to store millions of GeoJSON features in a DB, don’t store raw GeoJSON as text for querying. Store as a spatial type (PostGIS geometry/geography) and convert to GeoJSON only when sending to the client. This drastically improves query performance.
Conclusion
GeoJSON is a powerful yet simple way to represent geographic data in a web-friendly format. Whether you’re building a global mapping service or a small geofencing feature, GeoJSON makes it easy to store, share, and visualize location-based information.
If you understand JSON, you’re already halfway to mastering GeoJSON — just add a dash of geography.