<html><body><div id="zimbraEditorContainer" style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000" class="30"><div>Dear Darafei,<br></div><div><br data-mce-bogus="1"></div><div>in preparation of filing the ticket, I tested the ST_Union on my selected, supposedly problematic geometries. Interestingly, the ST_Union worked without a problem on my small selection table. I aborted the ticket creation because I can't file this as a reproducible bug.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>My (then unnecessarily complicated workaround) of course worked fine, too. That means, I am able to get my work done, unfortunately, I still don't know what the original problem was.</div><div><br data-mce-bogus="1"></div><div>I am willing to let it rest and mark it as mysterious behaviour of a large dataset, as long as nobody has a specific interest to go to the bottom of the problem?<br data-mce-bogus="1"></div><div><br></div><div>Thanks a lot again for the idea with the wrapper to extract to problematic rows.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Kind regards,<br data-mce-bogus="1"></div><div>Birgit<br data-mce-bogus="1"></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>Von: </b>"Birgit Laggner" <birgit.laggner@thuenen.de><br><b>An: </b>"PostGIS Users Discussion" <postgis-users@lists.osgeo.org><br><b>Gesendet: </b>Mittwoch, 19. September 2018 09:47:41<br><b>Betreff: </b>Re: [postgis-users] GEOSUnaryUnion: TopologyException: found non-noded intersection BUT geom is valid<br></div><div><br></div><div data-marker="__QUOTED_TEXT__"><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>Dear Darafei,<br></div><br><div>good idea to write a wrapper to ferret out the offending rows. I had to change it a bit because I don't use ST_Union(geometry, geometry) but the aggregate ST_Union(geometry). Since I am not very experienced in writing aggregates, I modified the wrapper that it fits for ST_Union(geometry[]) and used it in my query with ST_Union_Fails(array_agg(geom)).</div><br><div>I have found 3 groups with a total of 923 geometries which returned an error with ST_Union.<br></div><br><div>As soon as I get access to my old userID, I will file the them as a ticket.<br></div><br><div>In the meantime I will try to union the problematic geometries in a loop one at a time with st_makevalid after each loop - maybe that will work as a workaround, now I could reduce the number of geometries dramatically.<br></div><br><br><div>Thank you very much for your help!<br></div><br><div>Kind regards,<br></div><div>Birgit<br></div><br><br><br><hr id="zwchr"><div><b>Von: </b>"Darafei \"Komяpa\" Praliaskouski" <me@komzpa.net><br><b>An: </b>"PostGIS Users Discussion" <postgis-users@lists.osgeo.org><br><b>Gesendet: </b>Mittwoch, 19. September 2018 02:46:42<br><b>Betreff: </b>Re: [postgis-users] GEOSUnaryUnion: TopologyException: found non-noded intersection BUT geom is valid<br></div><br><div><div dir="ltr">Hi,<br><div>This is not supposed to happen. </div><br><div>Can you please isolate the offending rows unioning them pairwise and file them as a ticket? Here's a handy helper function that returns True if Union failed:</div><br><div><pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"DejaVu Sans Mono""><span style="color:rgb(204,120,50);font-weight:bold">create or replace function </span><span style="color:rgb(255,198,109);font-style:italic">st_union_fails</span>(geom1 <span style="color:rgb(204,120,50);font-weight:bold">geometry</span><span style="color:rgb(204,120,50)">, </span>geom2 <span style="color:rgb(204,120,50);font-weight:bold">geometry</span>)<br> <span style="color:rgb(204,120,50);font-weight:bold">returns boolean<br></span><span style="color:rgb(204,120,50);font-weight:bold">as </span><span style="color:rgb(106,135,89)">$$<br></span><span style="color:rgb(204,120,50);font-weight:bold">begin<br></span><span style="color:rgb(204,120,50);font-weight:bold"> begin<br></span><span style="color:rgb(204,120,50);font-weight:bold"> </span>geom1 = <span style="color:rgb(255,198,109);font-style:italic">ST_Union</span>(Geom1<span style="color:rgb(204,120,50)">, </span>geom2)<span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(204,120,50);font-weight:bold">return false</span><span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(204,120,50);font-weight:bold">exception when others<br></span><span style="color:rgb(204,120,50);font-weight:bold"> then<br></span><span style="color:rgb(204,120,50);font-weight:bold"> return true</span><span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50)"> </span><span style="color:rgb(204,120,50);font-weight:bold">end</span><span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(204,120,50);font-weight:bold">end</span><span style="color:rgb(204,120,50)">;<br></span><span style="color:rgb(106,135,89)">$$<br></span><span style="color:rgb(204,120,50);font-weight:bold">language </span>plpgsql<span style="color:rgb(204,120,50)">;</span></pre></div><br><br></div><br><div class="gmail_quote"><div dir="ltr">вт, 18 сент. 2018 г. в 16:25, Birgit Laggner <<a href="mailto:birgit.laggner@thuenen.de" target="_blank">birgit.laggner@thuenen.de</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div id="m_2151994923472200391zimbraEditorContainer" style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:#000000" class="m_21519949234722003912"><div>Dear discussion group,<br></div><br><div>I am trying to ST_Union several polygons and get a TopologyException (GEOSUnaryUnion: TopologyException: found non-noded intersection between LINESTRING (3.56442e+06 5.42679e+06, 3.56442e+06 5.42679e+06) and LINESTRING (3.56442e+06 5.42679e+06, 3.56442e+06 5.42679e+06) at 3564420.7944701263 5426786.9800475985).<br></div><div>I have tested with ST_Valid and all polygons in the datasets are valid.<br></div><br><div>The dataset is pretty large (53.5 Mio. polygons) and will probably get grouped into around 8.7 Mio resulting geometries during ST_Union.<br><br></div><div>If I try to ST_Union the geometries near the point ST_Union mentions in the error message (ST_Buffer with up to 100 metres), everything works fine. I am out of ideas how to find the problematic geometry or at least how to work around the TopologyException.<br></div><br><div>My PostGIS version is: "POSTGIS="2.3.3 r15473" GEOS="3.5.1-CAPI-1.9.1 r4246" SFCGAL="1.2.2" PROJ="Rel. 4.9.2, 08 September 2015" GDAL="GDAL 1.11.3, released 2015/09/16" LIBXML="2.9.3" LIBJSON="0.11.99" TOPOLOGY RASTER"<br></div><br><br><div>I would be very glad if anyone would come up with ideas how to solve my problem.<br></div><br><div>Thanks a lot in advance!<br></div><br><div>Regards,<br></div><div>Birgit<br></div><br><br></div></div>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br></blockquote></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Darafei Praliaskouski<br>Support me: <a href="http://patreon.com/komzpa" target="_blank">http://patreon.com/komzpa</a><br></div></div>
<br>_______________________________________________<br>postgis-users mailing list<br>postgis-users@lists.osgeo.org<br>https://lists.osgeo.org/mailman/listinfo/postgis-users<br></div></div><br>_______________________________________________<br>postgis-users mailing list<br>postgis-users@lists.osgeo.org<br>https://lists.osgeo.org/mailman/listinfo/postgis-users<br></div></div></body></html>