[gdal-dev] [ogr2ogr] Anti-meridian issue when reprojecting from a Polar Stereographic projection to a geographic CRS

Andrey VI andrey_vi at list.ru
Sat Oct 25 02:27:48 PDT 2025


New test-case with minimum allowed polygons  test_polys-3_3996.csv :
WKT,ID
"POLYGON ((-1000000 0,0 1000000,0 0,-1000000 0))","1"
"POLYGON ((0 0,0 1000000,1000000 0,0 0))","2"
"POLYGON ((-1000000 0,0 0,0 -1000000,-1000000 0))","3"
"POLYGON ((0 -1000000,0 0,1000000 0,0 -1000000))","4"
 
gdal vector pipeline read test_polys-3_3996.csv --oo KEEP_GEOM_COLUMNS=NO ! reproject -s EPSG:3996 -d EPSG:4326 ! write -f CSV --lco GEOMETRY=AS_WKT test_polys-3_3996-4326.csv
 
Resulting  test_polys-3_3996-4326.csv :
WKT,ID
"POLYGON ((-90 80.910166664287,180.0 80.910166664287,180 90,-90 90,-90 80.910166664287))","1"
"POLYGON ((90.0 80.910166664287,180 90,180.0 80.9101666644451,90.0 80.910166664287))","2"
"POLYGON ((-90 80.910166664287,-90 90,0 90,0.0 80.910166664287,-90 80.910166664287))","3"
"POLYGON ((0.0 80.910166664287,0 90,90 90,90.0 80.910166664287,0.0 80.910166664287))","4"
 
Polygons ID 1 and ID 2 are obviously reprojected incorrectly.
 
Directly reprojected coordinates should look like this ( test_polys-3_3996-4326-direct.csv ):
WKT,ID
"POLYGON ((-90 80.9101666642873,-180 80.9101666642873,0 90,-90 80.9101666642873))","1"
"POLYGON ((0 90,180 80.9101666642873,90 80.9101666642873,0 90))","2"
"POLYGON ((-90 80.9101666642873,0 90,0 80.9101666642873,-90 80.9101666642873))","3"
"POLYGON ((0 80.9101666642873,0 90,90 80.9101666642873,0 80.9101666642873))","4"
 
Additional vertices can be added to make the shape more regular ( test_polys-3_3996-4326-advanced.csv ):
WKT,ID
"POLYGON ((-90 80.910166664287,-180 80.910166664287,-180 90,-90 90,-90 80.910166664287))","1"
"POLYGON ((90 90,180 90,180 80.9101666644451,90 80.910166664287,90 90))","2"
"POLYGON ((-90 80.910166664287,-90 90,0 90,0 80.910166664287,-90 80.910166664287))","3"
"POLYGON ((0 80.910166664287,0 90,90 90,90 80.910166664287,0 80.910166664287))","4"
>Friday, October 24, 2025 10:42 PM +03:00 from Andrey VI < andrey_vi at list.ru >:
> 
>Actually
>> Polygon ID 2 should be
>> POLYGON ((135 77.17079836679849336, 90 80.91016666428700432,  90 90 , 180 90, 180 80.91016666428700432, 135 77.17079836679849336))
>is  incorrect because the first point of this polygon should be  0 90 . So I think that reprojected geometries should be as in  test_polys-2_3996-4326-proper.csv (attached) :
>WKT,ID
>"POLYGON ((-90 80.910166664287,-135 77.1707983667985,-180 80.910166664287,-180 90,0 90,-90 80.910166664287))","1"
>"POLYGON ((0 90,180 90,180 80.910166664287,135 77.1707983667985,90 80.910166664287,0 90))","2"
>"POLYGON ((-45 77.1707983667985,-90 80.910166664287,0 90,0 80.910166664287,-45 77.1707983667985))","3"
>"POLYGON ((0 80.910166664287,0 90,90 80.910166664287,45 77.1707983667985,0 80.910166664287))","4"
>>Friday, October 24, 2025 7:32 PM +03:00 from Andrey VI via gdal-dev < gdal-dev at lists.osgeo.org >:
>> 
>>Thank you, Even.
>> 
>>I think that I found an issue with re-projection.
>>4 polygons in EPSG:3996 as test_polys-2_3996.csv:
>>WKT,ID
>>"POLYGON ((-1000000 0,-1000000 1000000,0 1000000,0 0,-1000000 0))",1
>>"POLYGON ((0 0,0 1000000,1000000 1000000,1000000 0,0 0))",2
>>"POLYGON ((-1000000 -1000000,-1000000 0,0 0,0 -1000000,-1000000 -1000000))",3
>>"POLYGON ((0 -1000000,0 0,1000000 0,1000000 -1000000,0 -1000000))",4
>> 
>>gdal vector pipeline read test_polys-2_3996.csv --oo KEEP_GEOM_COLUMNS=NO ! reproject -s EPSG:3996 -d EPSG:4326 ! write -f CSV --lco GEOMETRY=AS_WKT test_polys-2_3996-4326.csv
>> 
>>Resulting  test_polys-2_3996-4326.csv :
>>WKT,ID
>>"POLYGON ((-90 80.910166664287,-135 77.1707983667985,180.0 80.910166664287,180 90,-90 90,-90 80.910166664287))","1"
>>"POLYGON ((135.0 77.1707983667985,90.0 80.910166664287,180 90,180.0 80.910166664287,135.0 77.1707983667985))","2"
>>"POLYGON ((-45 77.1707983667985,-90 80.910166664287,-90 90,0 90,0.0 80.910166664287,-45 77.1707983667985))","3"
>>"POLYGON ((0.0 80.910166664287,0 90,90 90,90.0 80.910166664287,45.0 77.1707983667985,0.0 80.910166664287))","4"
>> 
>>It looks like polygons with IDs 1 and 2 were reprojected incorrectly.
>>Polygon ID 1 should be
>>POLYGON ((-90 80.91016666428700432, -135 77.17079836679849336,  -180 80.91016666428700432,  -180 90, -90 90, -90 80.91016666428700432))
>>Polygon ID 2 should be
>>POLYGON ((135 77.17079836679849336, 90 80.91016666428700432,  90 90 , 180 90, 180 80.91016666428700432, 135 77.17079836679849336))
>> 
>> 
>>>Thursday, October 23, 2025 1:39 PM +03:00 from Even Rouault < even.rouault at spatialys.com >:
>>> 
>>>Andrey,
>>>
>>>| With ogr2ogr re-projection now works as expected, but when using gdal
>>>vector pipeline (reproject -d EPSG:4326) it works without any changes.
>>>Is this correct?
>>>
>>>Actually an extra fix for vector reproject was needed:
>>>https://github.com/OSGeo/gdal/pull/13275
>>>
>>>Even
>>>
>>>
>>>--
>>>http://www.spatialys.com
>>>My software is free, but my time generally not. 
>> 
>>--
>>Andrey
>> 
>>_______________________________________________
>>gdal-dev mailing list
>>gdal-dev at lists.osgeo.org
>>https://lists.osgeo.org/mailman/listinfo/gdal-dev 
> 
>--
>Andrey
--
Andrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20251025/3e7ed5d3/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_polys-3_3996.csv
Type: text/csv
Size: 216 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20251025/3e7ed5d3/attachment-0004.csv>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_polys-3_3996-4326.csv
Type: text/csv
Size: 371 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20251025/3e7ed5d3/attachment-0005.csv>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_polys-3_3996-4326-direct.csv
Type: text/csv
Size: 333 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20251025/3e7ed5d3/attachment-0006.csv>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_polys-3_3996-4326-advanced.csv
Type: text/csv
Size: 350 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20251025/3e7ed5d3/attachment-0007.csv>


More information about the gdal-dev mailing list