<HTML><BODY><div class="cl-eieeaqfqlu"><div>Thanks Vedran, but I think this procedure <span lang="en"><span><span>will not help solve the problem. I tried to figure out the cause of the issue and may have found it.</span></span></span><br> </div><div>I created 3 polygons in EPSG:3996 saved as test_polys_3996.csv:</div><div><div><div>WKT,ID</div><div>"POLYGON ((-3368075.98202296 0.0,0.0 3368075.98202296,3368075.98202296 0.0,0.0 -3368075.98202296,-3368075.98202296 0.0),(-2217499.59851296 0.0,0.0 -2217499.59851296,2217499.59851296 0.0,0.0 2217499.59851296,-2217499.59851296 0.0))",1</div><div>"POLYGON ((-2217499.59851296 0.0,0.0 2217499.59851296,2217499.59851296 0.0,0.0 -2217499.59851296,-2217499.59851296 0.0),(0.0 1100597.55599312,-1100597.55599312 0.0,0.0 -1100597.55599312,1100597.55599312 0.0,0.0 1100597.55599312))",2</div><div>"POLYGON ((0.0 -1100597.55599312,-1100597.55599312 0.0,0.0 1100597.55599312,1100597.55599312 0.0,0.0 -1100597.55599312))",3</div><div>IDs 1 and 2 are polygons with ring.</div><div> </div></div></div><div>Then executed 3 commands:</div><div><div><div>ogr2ogr -f CSV --config OGR_WKT_PRECISION=3 -oo KEEP_GEOM_COLUMNS=NO -s_srs EPSG:3996 -t_srs EPSG:4326 -lco GEOMETRY=AS_WKT test_polys_3996-4326.csv test_polys_3996.csv</div><div> </div><div>ogr2ogr -f CSV --config OGR_WKT_PRECISION=3 -oo KEEP_GEOM_COLUMNS=NO -s_srs EPSG:3996 -t_srs EPSG:4326 -wrapdateline -lco GEOMETRY=AS_WKT test_polys_3996-4326_wdl.csv test_polys_3996.csv</div><div> </div><div>ogr2ogr -f CSV --config OGR_WKT_PRECISION=3 -oo KEEP_GEOM_COLUMNS=NO -s_srs EPSG:3996 -t_srs EPSG:4326 -wrapdateline -datelineoffset 180 -lco GEOMETRY=AS_WKT test_polys_3996-4326_wdl_dlo180.csv test_polys_3996.csv</div><pre style="background-color:#ebecef;border-radius:4px;display:inline-block;font-family:"Andale mono","Lucida Console",Monaco,monospace;font-size:15px;font-style:normal;font-weight:normal;line-height:22px;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;min-height:22px;min-width:12px;padding:12px;white-space:pre-wrap"><span style="font-size:13px;line-height:20px">ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring
ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring
ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring
ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring
ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring
ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring</span></pre></div></div><div> </div><div><span lang="en"><span><span>All 3 resulting files had the same content despite different options used:</span></span></span></div><div><div><div>WKT,ID</div><div>"POLYGON ((-90 60.0,180.0 60.0,90.0 60.0,0.0 60.0,-90 60.0),(-90 70.0,0.0 70.0,90.0 70.0,180.0 70.0,-90 70.0))","1"</div><div>"POLYGON ((-90 70.0,180.0 70.0,90.0 70.0,0.0 70.0,-90 70.0),(180.0 80.0,-90 80.0,0.0 80.0,90.0 80.0,180.0 80.0))","2"</div><div>"POLYGON ((-90 80.0,-180 80.0,-180 90,180 90,180.0 80.0,90.0 80.0,0.0 80.0,-90 80.0))","3"</div><div> </div><div>Polygons with IDs 1 and 2 have incorrect geometry. These polygons are not wrapped at anti-meridian.</div><div><div><div>Polygon ID 1 should be</div><div>POLYGON ((180 60, 90 60, 0 60, -90 60, -180 60, -180 70, -90 70, 0 70, 90 70, 180 70, 180 60))</div><div>Polygon ID 2 should be</div><div>POLYGON ((180 70, 90 70, 0 70, -90 70, -180 70, -180 80, -90 80, 0 80, 90 80, 180 80, 180 70))</div><div>Polygon ID 3 <span lang="en"><span><span>has the correct geometry even without -wrapdateline option.</span></span></span></div></div></div><div> </div><div><span lang="en"><span><span>This could mean that -wrapdateline or reprojecting in general does not work right with polygons with rings and OGR produces incorrect geometry for them.</span></span></span></div><div> </div><div>So <span lang="en"><span><span>this looks like an OGR bug to me. But this is my personal opinion as a non-specialist.</span></span> <span><span>Maybe I'm wrong.</span></span></span></div><div> </div></div></div><div> </div><div class="mail-quote-collapse"><blockquote style="border-left:1px solid #0857A6;margin:10px;padding:0 0 0 10px"><span>Wednesday, October 15, 2025 10:46 AM +03:00 from Vedran Stojnović <<a href="https://e.mail.ru/compose/?mailto=mailto%3Aphidrho%40gmail.com">phidrho@gmail.com</a>>:</span><br> <div><div id=""><div class="cl-el2a7j9scp"><div class="js-helper_mr_css_attr js-readmsg-msg_mr_css_attr"><div id="style_17605143720225413937_mr_css_attr"><div id="style_17605143720225413937_BODY_mr_css_attr"><div><div>Hi Andrey,</div><div> </div><div>I am aware that this is not ogr2ogr solution, but you can watch my lecture on this kind of problem and procedure to avoid this problem in QGIS - and then maybe you can apply the same procedure/logic using only ogr2ogr.</div><div> </div><div>See this video, you can skip to around 45 minutes.</div><div><a href="https://www.youtube.com/watch?v=5M-Q0AinuiY&t=2702s">https://www.youtube.com/watch?v=5M-Q0AinuiY&t=2702s</a></div><div> </div></div> <div class="gmail_quote_container_mr_css_attr gmail_quote_mr_css_attr"><div class="gmail_attr_mr_css_attr">uto, 14. lis 2025. u 22:02 Andrey VI via gdal-dev <<a href="https://e.mail.ru/compose/?mailto=mailto%3Agdal-dev%40lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> napisao je:</div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote_mr_css_attr"><div><div><div>Unfortunately, the result is still incorrect.<br>The empty areas are still here around 88-89°N and some polygons are still broken (for example at -67°W, 76°N):</div><div><a href="https://i.ibb.co/CpQGWdpk/Example.png">Example</a>.</div><div>These polygons turned out to be hidden under others, although in the original data all polygons are adjacent but not overlapping. Not sure if this is a result of reported errors or a separate issue.</div> <div><div class="mail-quote-collapse"><blockquote style="border-left:1px solid rgb(8,87,166);margin:10px;padding:0px 0px 0px 10px"><span><span>Tuesday, October 14, 2025 4:48 PM +03:00 from Rahkonen Jukka <<a href="https://e.mail.ru/compose/?mailto=mailto%3Ajukka.rahkonen%40maanmittauslaitos.fi">jukka.rahkonen@maanmittauslaitos.fi</a>>:</span></span><br> <div><div><div id="m_8826303847537462843_mr_css_attr"><div><div><div id="m_8826303847537462843style_17604496941747178434_mr_css_attr"><div id="m_8826303847537462843style_17604496941747178434_BODY_mr_css_attr">Hi,<br><br>This command prints also 6 error lines, but at least the result does not have empty areas:<br><br>ogr2ogr -t_srs epsg:4626 -wrapdateline -datelineoffset 180 foo3.shp polys.shp<br><br>I do not know if the result is correct or not, just that it is different.<br><br>-Jukka Rahkonen-<br><br><br>________________________________________<br>Lähettäjä: gdal-dev <<a href="http:///compose?To=gdal%2ddev%2dbounces@lists.osgeo.org">gdal-dev-bounces@lists.osgeo.org</a>> käyttäjän Andrey VI via gdal-dev <<a href="http:///compose?To=gdal%2ddev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> puolesta<br>Lähetetty: Tiistai 14. lokakuuta 2025 15.50<br>Vastaanottaja: <a href="http:///compose?To=gdal%2ddev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a> <<a href="http:///compose?To=gdal%2ddev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>><br>Aihe: [gdal-dev] [ogr2ogr] Anti-meridian issue when reprojecting from a Polar Stereographic projection to a geographic CRS<br><br>Hello. I can't reproject data from a Polar Stereographic projection (EPSG:3996) to a geographic projection (EPSG:4326) correctly using ogr2ogr. Command:ogr2ogr -t_srs EPSG:4326 -wrapdateline polys_4326.shp polys.shpERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring<br>ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring<br>ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring<br>ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring<br>ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring<br>ERROR 1: IllegalArgumentException: Points of LinearRing do not form a closed linestring As a result some polygons are broken and also some polygons appears with artifacts.[X]The data used and the result (58 MB): <a href="https://drive.google.com/file/d/176jtROjjeTlAQTITAJ75tBT1GwiUzSUm/view?usp=sharing">https://drive.google.com/file/d/176jtROjjeTlAQTITAJ75tBT1GwiUzSUm/view?usp=sharing</a>. How to reproject from a projection naturally crossing the anti-meridian to a geographic CRS without any errors using ogr2ogr?--Andrey</div></div></div></div></div></div></div></blockquote></div></div> <div><div><div>--<br>Andrey VI<br>Sent from <a href="https://trk.mail.ru/c/zzm979">Mail</a></div></div></div></div></div>_______________________________________________<br>gdal-dev mailing list<br><a href="https://e.mail.ru/compose/?mailto=mailto%3Agdal-dev%40lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></blockquote></div><div> </div><br><span class="gmail_signature_prefix_mr_css_attr">-- </span><div class="gmail_signature_mr_css_attr"><div>Srdačan pozdrav / Kind regards,<div>Vedran Stojnović.</div></div></div></div></div></div></div></div></div></blockquote></div><br><div>--<br>Andrey</div></div></BODY></HTML>