GeoJSON Standard Explained: Master RFC 7946 for Geospatial Data
In the world of web mapping and Geographic Information Systems (GIS), GeoJSON has become the universal language for sharing spatial data. Whether you are using Leaflet, Mapbox, or Google Maps, you are likely interacting with RFC 7946, the official GeoJSON standard.
What is RFC 7946 (GeoJSON)?
Published in 2016, RFC 7946 formalized the GeoJSON format. It is a geospatial data interchange format based on JSON (JavaScript Object Notation). It allows you to represent geometry, features, and collections of features.
GeoJSON supports the following geometry types:
- Point: A single position (longitude, latitude).
- LineString: A series of connected points.
- Polygon: An enclosed area (the first and last points are the same).
- MultiPoint, MultiLineString, MultiPolygon: Collections of the above.
- GeometryCollection: A mix of different geometry types.
Core Principles of GeoJSON
1. The Coordinate System
RFC 7946 strictly mandates the use of the WGS 84 (World Geodetic System 1984) datum. Coordinates are always ordered as [longitude, latitude]. Warning: Many developers make the mistake of using [latitude, longitude], which will place your data in the wrong part of the world!
2. The Feature Object
A GeoJSON Feature object contains a geometry and additional metadata (properties).
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [102.0, 0.5]
},
"properties": {
"name": "Dinagat Islands"
}
}
3. The FeatureCollection
Most GeoJSON files are FeatureCollection objects, allowing you to bundle multiple features into a single file.
Practical Application Scenarios
Web Mapping
GeoJSON is the native format for most modern web mapping libraries. It is easy to load via AJAX and can be styled dynamically based on the properties object.
Database Storage
Modern databases like PostgreSQL (with PostGIS) and MongoDB have native support for GeoJSON, allowing you to perform spatial queries (e.g., "Find all points within 5km of this location").
Data Visualization
Tools like D3.js can take GeoJSON data and render it as interactive SVG maps, perfect for dashboards and infographics.
GeoJSON vs. KML vs. Shapefile
| Feature | GeoJSON | KML | Shapefile |
|---|---|---|---|
| Format | JSON | XML | Binary (Multiple files) |
| Web Friendly | Excellent | Moderate | Poor |
| Styling | via properties | Built-in (XML) | Separate (.qml/.sld) |
| Human Readable | Yes | Yes | No |
FAQ
Q: Why is it [longitude, latitude] instead of [latitude, longitude]?
A: RFC 7946 follows the standard Cartesian coordinate system [x, y], where longitude corresponds to the X-axis and latitude to the Y-axis.
Q: Can I use different coordinate systems (CRS)?
A: While older versions of GeoJSON allowed custom CRS, RFC 7946 strictly requires WGS 84. If your data is in a different system (like UTM), you must project it to WGS 84 before sharing it as GeoJSON.
Q: How do I handle large datasets?
A: For very large spatial datasets, GeoJSON can become slow to load. Consider using TopoJSON (which reduces file size by sharing topology) or Vector Tiles (MVT) for production-grade mapping.
Related Tools
- JSON Formatter - Essential for validating and cleaning your GeoJSON structures.
- URL Encoder/Decoder - Useful when passing GeoJSON data as a URL parameter.
- UUID Generator - Often used to generate unique IDs for GeoJSON features.