[gdal-dev] Difference between ogr2ogr and Python reprojection

Scott public at postholer.com
Tue Mar 14 11:27:42 PDT 2023


While I don't have a direct answer to your question I might ask, why use 
20 lines of python code when 1 line of ogr2ogr gives the correct result?


On 3/14/23 11:15, Dion-Degodez,Nicolas (ECCC) wrote:
> _Context_
> 
> We are trying to reproject a GeoJSON polygon to EPSG:4326.
> 
> In some cases, depending on whether we use the ogr2ogr command line or 
> the equivalent in python, the resulting polygon is different.
> 
> In those situations, the command line gives us the appropriate polygon, 
> whereas the python code gives us a distorted polygon.
> 
> _Question_
> 
> Any idea why there is a difference between the command line and the 
> python results? Is there a mistake in our interpretation of the code/how 
> we converted it in python?
> 
> _Sample GeoJSON_: https://pastebin.com/hUiVVjFv 
> <https://pastebin.com/hUiVVjFv>
> 
> Proj4: "+proj=stere +lat_0=90 +lat_ts=60 +lon_0=264 +x_0=0 +y_0=0 
> +R=6371229 +units=m +no_defs"
> 
> _Command line that works_: ogr2ogr -s_srs "+proj=stere +lat_0=90 
> +lat_ts=60 +lon_0=264 +x_0=0 +y_0=0 +R=6371229 +units=m +no_defs" -t_srs 
> EPSG:4326 result_command_line.json geojson.json
> 
> Result: https://pasteboard.co/cTpZBRamEYv8.jpg 
> <https://pasteboard.co/cTpZBRamEYv8.jpg>
> 
> _Python code_ (we would expect the same output as the command line): 
> https://pastebin.com/QgWDBL1W <https://pastebin.com/QgWDBL1W>
> 
> Result: https://pasteboard.co/8iSv0vbnQlHw.jpg 
> <https://pasteboard.co/8iSv0vbnQlHw.jpg>
> 
> Thank you!
> 
> Nicolas D.
> 
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list