Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#4995 closed defect (fixed)

ogr2ogr geojson does not include CRS

Reported by: nelson Owned by: warmerdam
Priority: normal Milestone: 1.10.0
Component: OGR_SF Version: 1.9.2
Severity: normal Keywords:
Cc:

Description

When creating geojson via "ogr2ogr -t_srs EPSG:xxxx -f geojson", ogr2ogr correctly reprojects the coordinates to the requested SRS but it does not include the SRS identifer in the output GeoJSON. With no CRS specified, the GeoJSON spec says the default is "the WGS84 datum, and with longitude and latitude units of decimal degrees" which may well be incorrect.

There's code inside ogr2ogr to emit the CRS identifier which was #ifdefed out in December 2011: http://trac.osgeo.org/gdal/changeset/23662

Discussion of the ogr2ogr behavior: http://gis.stackexchange.com/questions/46881/ogr2ogr-from-postgres-to-geojson-missing-crs-key

Reference on GeoJSON CRS naming http://www.geojson.org/geojson-spec.html#coordinate-reference-system-objects

Change History (5)

comment:1 Changed 7 years ago by Even Rouault

Milestone: 1.10.0
Resolution: fixed
Status: newclosed

r25665 "GeoJSON: write crs object as a FeatureCollection? attribute in generated GeoJSON files (#4995); on read, strip AXIS nodes"

comment:2 Changed 7 years ago by nelson

Thanks!

comment:3 in reply to:  1 Changed 5 years ago by martinl

Replying to rouault:

r25665 "GeoJSON: write crs object as a FeatureCollection? attribute in generated GeoJSON files (#4995); on read, strip AXIS nodes"

I am not sure if it's related but if try eg.

ogr2ogr -f GeoJSON -t_srs +init=epsg:3857 -s_srs +init=epsg:5514 test.json /vsicurl/http://geo102.fsv.cvut.cz/~landa/tmp/cfm.shp

The output GeoJSON file doesn't contain any information about SRS... ?

comment:4 Changed 5 years ago by Even Rouault

trunk r28491, branches/1.11 r28492 "GeoJSON writer: make string comparison for authority name case insensitive so as to recognize lowercase 'epsg' (#4995)"

As a workaround you can use -t_srs EPSG:3857

Note that the IETF version of GeoJSON will deprecate any use of CRS != longlat WGS84

comment:5 in reply to:  4 Changed 5 years ago by martinl

Replying to rouault:

trunk r28491, branches/1.11 r28492 "GeoJSON writer: make string comparison for authority name case insensitive so as to recognize lowercase 'epsg' (#4995)"

As a workaround you can use -t_srs EPSG:3857

Note that the IETF version of GeoJSON will deprecate any use of CRS != longlat WGS84

Thanks for clarification.

Note: See TracTickets for help on using tickets.