Atlaslog / Field Notes / Coordinates & projections
Field note · Coordinates & projections
GeoJSON without a CRS: 3857 metres read as degrees
Quick answer
A GeoJSON exported straight from EPSG:3857 geometry holds metre coordinates but no usable CRS declaration. RFC 7946 removed the crs member and every parser assumes degrees, so nothing renders.
Symptom
- districts.geojson parses fine with 312 features, but L.geoJSON(data).addTo(map) draws nothing and logs nothing.
- map.fitBounds(layer.getBounds()) returns LatLngBounds(20037508, 20037508).
- QGIS reports an invalid layer extent, and the first coordinate pair is [13522390.4, 3669871.9].
Checklist
- Read the first coordinate pair and check magnitude; an absolute value above 180 is not a degree.
- Look for a top-level crs member, but note that Leaflet 1.x and Mapbox GL ignore it.
- Compute the bbox: x 7.3e6~1.5e7 and y 2.4e6~6.1e6 match China in EPSG:3857.
- Trace back to the export SQL and check whether ST_Transform(geom, 4326) was applied.
- If the export cannot be changed, reproject before constructing L.geoJSON, not inside coordsToLatLng.
Fix
Fix it at the source: serialize with ST_AsGeoJSON(ST_Transform(geom, 4326)); on the client, walk the coordinates with proj4('EPSG:3857','EPSG:4326', xy) before calling L.geoJSON.
Code
const c = fc.features[0].geometry.coordinates;
const is4326 = Math.abs(c[0]) <= 180 && Math.abs(c[1]) <= 90;
console.log(is4326 ? '经纬度' : '投影坐标,量级 ' + c[0].toExponential(2));
// 13522390.4 -> "投影坐标,量级 1.35e+7"-- PostGIS:导出前必须转换
SELECT jsonb_build_object(
'type', 'FeatureCollection',
'features', jsonb_agg(ST_AsGeoJSON(t, 15)::jsonb)
)
FROM (
SELECT id, name, ST_Transform(geom, 4326) AS geom FROM districts
) AS t;
Watch out
- Adding a crs member naming EPSG:3857 and expecting Leaflet to honour it, which it does not.
- Passing a coordsToLatLng callback that guesses units, which silently mangles valid degree data.
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Atlaslog (2026). GeoJSON without a CRS: 3857 metres read as degrees. https://www.jingweizhi.com/en/cookbook/geojson-no-crs.html (accessed 2026-11-03).