<div dir="ltr"><div>Hello,</div><div><br></div><div>What about using gdal.VectorTranslate instead? Normally, shorter code and it works like ogr2ogr</div><div>PS: could be wrong as I didn't tested the exact syntax<br></div><div><br></div><div><br></div><div>from osgeo import gdal<br><br>gdal.VectorTranslate(<br> 'result_command_line.json',<br> 'geojson.json',<br> options='-f GeoJSON -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'<br>)</div><div><br></div><div>Regards</div><div><br></div><div>Thomas Gratier<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 14 mars 2023 à 19:27, Scott <<a href="mailto:public@postholer.com">public@postholer.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">While I don't have a direct answer to your question I might ask, why use <br>
20 lines of python code when 1 line of ogr2ogr gives the correct result?<br>
<br>
<br>
On 3/14/23 11:15, Dion-Degodez,Nicolas (ECCC) wrote:<br>
> _Context_<br>
> <br>
> We are trying to reproject a GeoJSON polygon to EPSG:4326.<br>
> <br>
> In some cases, depending on whether we use the ogr2ogr command line or <br>
> the equivalent in python, the resulting polygon is different.<br>
> <br>
> In those situations, the command line gives us the appropriate polygon, <br>
> whereas the python code gives us a distorted polygon.<br>
> <br>
> _Question_<br>
> <br>
> Any idea why there is a difference between the command line and the <br>
> python results? Is there a mistake in our interpretation of the code/how <br>
> we converted it in python?<br>
> <br>
> _Sample GeoJSON_: <a href="https://pastebin.com/hUiVVjFv" rel="noreferrer" target="_blank">https://pastebin.com/hUiVVjFv</a> <br>
> <<a href="https://pastebin.com/hUiVVjFv" rel="noreferrer" target="_blank">https://pastebin.com/hUiVVjFv</a>><br>
> <br>
> Proj4: "+proj=stere +lat_0=90 +lat_ts=60 +lon_0=264 +x_0=0 +y_0=0 <br>
> +R=6371229 +units=m +no_defs"<br>
> <br>
> _Command line that works_: ogr2ogr -s_srs "+proj=stere +lat_0=90 <br>
> +lat_ts=60 +lon_0=264 +x_0=0 +y_0=0 +R=6371229 +units=m +no_defs" -t_srs <br>
> EPSG:4326 result_command_line.json geojson.json<br>
> <br>
> Result: <a href="https://pasteboard.co/cTpZBRamEYv8.jpg" rel="noreferrer" target="_blank">https://pasteboard.co/cTpZBRamEYv8.jpg</a> <br>
> <<a href="https://pasteboard.co/cTpZBRamEYv8.jpg" rel="noreferrer" target="_blank">https://pasteboard.co/cTpZBRamEYv8.jpg</a>><br>
> <br>
> _Python code_ (we would expect the same output as the command line): <br>
> <a href="https://pastebin.com/QgWDBL1W" rel="noreferrer" target="_blank">https://pastebin.com/QgWDBL1W</a> <<a href="https://pastebin.com/QgWDBL1W" rel="noreferrer" target="_blank">https://pastebin.com/QgWDBL1W</a>><br>
> <br>
> Result: <a href="https://pasteboard.co/8iSv0vbnQlHw.jpg" rel="noreferrer" target="_blank">https://pasteboard.co/8iSv0vbnQlHw.jpg</a> <br>
> <<a href="https://pasteboard.co/8iSv0vbnQlHw.jpg" rel="noreferrer" target="_blank">https://pasteboard.co/8iSv0vbnQlHw.jpg</a>><br>
> <br>
> Thank you!<br>
> <br>
> Nicolas D.<br>
> <br>
> <br>
> _______________________________________________<br>
> gdal-dev mailing list<br>
> <a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
> <a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>