[postgis-users] ST_Intersection Problems

BladeOfLight16 bladeoflight16 at gmail.com
Thu Jul 11 19:09:58 PDT 2013


TL;DR Version:

ST_Intersection is blowing up with errors about "non-noded intersections"
and "no outgoing dirEdge" on my polygons. A bunch of sordid details about
my data later, what can I try to make it stop throwing TopologyExceptions?

Some gory details:

The data I have comes from GPS, and it hasn't been cleaned up very much (if
at all). Blame my client for that; I don't have any control over that end
of things. Rather, I'm doing a lot of processing on that front. I'm calling
ST_IsValid on every polygon that comes into the database, and if
ST_MakeValid doesn't fix a bad shape, the shape doesn't make it into the
database or is removed. So anything that isn't valid according to
ST_IsValid either doesn't make it to the database or gets removed. (It's a
Python scripted import process from shapefiles using GDAL 1.9.2.)

Anyway, I keep getting TopologyExceptions when intersecting multipolygons.
The main one I've seen is "Found a non-noded intersection" between two line
segments. Sometimes, it reports a pair of line segments that are identical
(same pair of endpoints) or with all 4 endpoints the same. I suppose it
could be rounding them off before printing them out, but I'm not sure. I
know my data isn't great, but it seems to me that ST_Intersection should be
able to deal with non-noded intersecting boundaries on a pair of polygons
that are known to be valid even if there really are non-identical line
segments here. I've also just seen a new error about "no outgoing dirEdge".
I'm pretty sure these exceptions bubble up from GEOS. I can't imagine that
ST_Intersection is just this broken, but I don't know what could be wrong
with my data. Are the errors saying that my input polygons are invalid? I
don't even know what "no outgoing dirEdge" means. I've worked around some
of these problems by trying out various processing functions, but they seem
to keep cropping up on new shapes all the time.

Here's a couple of examples messages:
Error performing intersection: TopologyException: found non-noded
intersection between LINESTRING (401718 4.79501e+06, 401985 4.79478e+06)
and LINESTRING (401881 4.79487e+06, 401881 4.79487e+06) at
401881.39639593894 4794871.2533254148
Error performing intersection: TopologyException: found non-noded
intersection between LINESTRING (399455 4.79789e+06, 399457 4.79789e+06)
and LINESTRING (399457 4.79789e+06, 399457 4.79789e+06) at
399457.27424822841 4797894.8998478195
Error performing intersection: TopologyException: found non-noded
intersection between LINESTRING (397437 4.79996e+06, 397440 4.79996e+06)
and LINESTRING (397440 4.79996e+06, 397437 4.79996e+06) at
397439.75892231759 4799961.016094767
Error performing intersection: TopologyException: no outgoing dirEdge found
at 399581.34970068082 4796536.1357847052

Full version info:
PostgreSQL 9.2.4 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 4.6.3
20120306 (Red Hat 4.6.3-2), 64-bit
This is actually Amazon Linux, and this is from the Amazon repo.

POSTGIS="2.0.2 r10789" GEOS="3.3.8-CAPI-1.7.8" PROJ="Rel. 4.8.0, 6 March
2012" GDAL="GDAL 1.9.2, released 2012/10/08" LIBXML="2.7.8" RASTER
PostGIS, GEOS, proj, and GDAL were all built from source. (At the time, I
wasn't aware of PostgreSQL's yum repository, but it and the ELGIS repo have
out of date GDAL, if I recall correctly.) No configuration options except
to tell PostGIS where to find GEOS when I built it. I did get
proj-datumgrid-1.5.zip and put the contents in a nad directory with proj.

At one time, I tried upgrading to a nightly build of GEOS 3.4, but since
that didn't solve my "non-noded intersection" errors at the time, I
abandoned it. At that time, the errors were coming from ST_Union on a bunch
of line work, in fact. When upgrading didn't work, I ended up taking my
line work, breaking it down into individual segments (as in 2 points per
segment), and eliminating duplicate line segments (according to ST_Equals).
After that, the union worked, which strengthens the argument that the
problem has to do with duplicate line segments somewhere, at least in my
mind.

Is this some kind of known issue? It is caused by some known potential
problem in my data? Maybe I did something wrong when building? Maybe
ST_Valid isn't catching some things? I'd appreciate any suggestions, even
wild and way out there ones. I'm pretty desperate. Thank you, and my
apologies for the long read.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130711/d7848e90/attachment.html>


More information about the postgis-users mailing list