Another 3857 vs 4326 question. When I reproject from EPSG:3857 to EPSG:4326 (and from .shp to .geojson) via the QGIS 'Save As' dialog, I get results that display in the expected place on Google Maps.
Yet when I use ogr2ogr to do the same thing, the coordinates are slightly different, and the polygon appears many kilometres to the north.
ogr2ogr -f 'GeoJSON' -s_srs "+EPSG:3857" -t_srs "EPSG:4326" ./out.geojson ./in.shp The same unexpected coordinates result from this expanded command:
ogr2ogr -f 'GeoJSON' -s_srs "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs" -t_srs "+proj=longlat +datum=WGS84 +no_defs" ./out.geojson ./in.shp I imagine QGIS is using ogr2ogr with slightly different parameters. I used the crs definitions found in QGIS's CRS Selector dialog, so I'm not sure what would be different. I have tried to find QGIS logs so that I can see the exact command it is using, but came up empty.
Can you suggest a way to see what QGIS is doing under the hood or a way to fix my commands above?
I am aware of this question ogr2ogr reprojection works on command line but shifts output when same command run from inside python?, but I think my second command above implements the main suggestion in the answer which is to not rely on EPSG code numbers.
Ubuntu 14; QGIS 2.8.1; GDAL 1.11.2
Original 3857 (converted to geojson):
{"type": "FeatureCollection","crs": { "type": "name", "properties": { "name": "urn
gc:def:crs:EPSG::3857" } }, "features": [{ "type": "Feature", "properties": { "id": 1 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -8947459.1603874694556, 5370208.95458666421473 ], [ -8946835.596433963626623, 5370184.012028524652123 ], [ -8946825.619410708546638, 5369819.85067967697978 ], [ -8947509.045503750443459, 5369884.701330841518939 ], [ -8947459.1603874694556, 5370208.95458666421473 ] ] ] } }]}
4326 output via QGIS Save As
{"type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn
gc:def:crs:OGC:1.3:CRS84" }}, "features": [ { "type": "Feature", "properties": { "id": 1 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -80.376393178112849, 43.381418128580314 ], [ -80.370791607812237, 43.381255280077752 ], [ -80.370701982687436, 43.378877642127314 ], [ -80.376841303736896, 43.37930106392843 ], [ -80.376393178112849, 43.381418128580314 ] ] ] } }]}
Result of ogr2ogr -f 'GeoJSON' -s_srs "+EPSG:3857" -t_srs "EPSG:4326" ./out.geojson ./in.shp
{"type": "FeatureCollection","crs": { "type": "name", "properties": { "name": "urn
gc:def:crs:OGC:1.3:CRS84" } }, "features": [{ "type": "Feature", "properties": { "id": 1 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -80.376393178112821, 43.381418128580307 ], [ -80.370791607812222, 43.381255280077738 ], [ -80.370701982687422, 43.378877642127307 ], [ -80.376841303736867, 43.379301063928423 ], [ -80.376393178112821, 43.381418128580307 ] ] ] } }]}
أكثر...
Yet when I use ogr2ogr to do the same thing, the coordinates are slightly different, and the polygon appears many kilometres to the north.
ogr2ogr -f 'GeoJSON' -s_srs "+EPSG:3857" -t_srs "EPSG:4326" ./out.geojson ./in.shp The same unexpected coordinates result from this expanded command:
ogr2ogr -f 'GeoJSON' -s_srs "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs" -t_srs "+proj=longlat +datum=WGS84 +no_defs" ./out.geojson ./in.shp I imagine QGIS is using ogr2ogr with slightly different parameters. I used the crs definitions found in QGIS's CRS Selector dialog, so I'm not sure what would be different. I have tried to find QGIS logs so that I can see the exact command it is using, but came up empty.
Can you suggest a way to see what QGIS is doing under the hood or a way to fix my commands above?
I am aware of this question ogr2ogr reprojection works on command line but shifts output when same command run from inside python?, but I think my second command above implements the main suggestion in the answer which is to not rely on EPSG code numbers.
Ubuntu 14; QGIS 2.8.1; GDAL 1.11.2
Original 3857 (converted to geojson):
{"type": "FeatureCollection","crs": { "type": "name", "properties": { "name": "urn
4326 output via QGIS Save As
{"type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn
Result of ogr2ogr -f 'GeoJSON' -s_srs "+EPSG:3857" -t_srs "EPSG:4326" ./out.geojson ./in.shp
{"type": "FeatureCollection","crs": { "type": "name", "properties": { "name": "urn
أكثر...