Why Reproject GeoJSON Bounding Boxes?
According to the IETF RFC 7946 GeoJSON Specification, standard GeoJSON coordinates must strictly be in geographic coordinates using the WGS84 datum (EPSG:4326) with longitude preceding latitude ([longitude, latitude]).
However, in real-world geospatial pipelines:
- Mapbox GL / MapLibre / OpenLayers / Deck.gl: Web mapping engines render data internally in Web Mercator metric projection (EPSG:3857). Calculating pixel bounding boxes, zoom extents, and tile intersections requires reprojecting bounding boxes into metric space.
- Area & Distance Calculations: Geographic degrees cannot be used for direct Euclidean distance or area formulas (Δ X · Δ Y). At latitude 35°, one degree of longitude spans ~91.3 km, while one degree of latitude spans ~110.9 km. Transforming to projected coordinates (EPSG:3857 or UTM) is necessary to compute true metric dimensions.
X = Lon · (20,037,508.34 / 180)
Y = ln[tan((90 + Lat) · π / 360)] / (π / 180) · (20,037,508.34 / 180)
Web Mercator → WGS84 Inverse Formulas:
Lon = X / (20,037,508.34 / 180)
Lat = (2 · arctan(e^(Y / (20,037,508.34 / 180) · (π / 180))) - π/2) · (180 / π)
GeoJSON Axis Order Standard (RFC 7946)
The most frequent error in Web GIS development is the latitude/longitude reversal bug. RFC 7946 Section 3.1.1 mandates:
"A position is an array of numbers. There MUST be two or more elements. The first two elements are longitude and latitude, or easting and northing, precisely in that order."
Always ensure your GeoJSON bounding box arrays follow [west, south, east, north] (i.e. [minX, minY, maxX, maxY]).