[geos-devel] [GEOS] #737: TopologyException for Valid geoemtries

GEOS geos-trac at osgeo.org
Wed Jul 22 15:25:35 PDT 2015

#737: TopologyException for Valid geoemtries
 Reporter:  bladeoflight16  |      Owner:  geos-devel@…
     Type:  defect          |     Status:  new
 Priority:  major           |  Milestone:  3.4.3
Component:  Default         |    Version:  3.4.2
 Severity:  Unassigned      |   Keywords:
 I have 2 supposedly valid geometries. When I try to take the difference
 between them:

 WITH geom1 (g) AS
 Q1JB$$, 'base64')))),
 geom2 (g) AS
 2hZBkmQdFpBDUkE=$$, 'base64'))))
 --SELECT ST_IsValidDetail(geom1.g), ST_IsValidDetail(geom2.g)
 SELECT ST_Difference(geom1.g, geom2.g)
 FROM geom1, geom2;

 (Sorry for all the nasty base64. I wanted to make sure they come through
 exactly. You can leave the whitespace there in PostgreSQL. {{{DECODE}}}
 strips it out it properly; in fact, {{{ENCODE}}} is what generated it.)

 I get the following error:

 ERROR: GEOSDifference: TopologyException: found non-noded intersection
 between LINESTRING (374438 4.78778e+06, 374529 4.78777e+06) and LINESTRING
 (374529 4.78777e+06, 374466 4.78778e+06) at 374526.95988686144
 SQL state: XX000

 You can confirm that they're reported as valid geometries by
 commenting/uncommenting the {{{SELECT}}} lines appropriately.

 Note that the {{{geom1}}} geometry is actually the output from a
 different, successful {{{ST_Difference}}}, so it's not actually valid,
 there's a bug in what it outputs.

 If you pull up the geometries, you'll find this is not squeaky clean data.
 It comes from data that is taken over several years, and for every year, I
 need to figure out what the most current data is. Sometimes the data is
 retaken, so I need to cut out old overlaps but bring in data from new
 locations. I've done a ton of work trying to automatically clean this data
 some, but I still run into these errors all the time. Expect more reports
 as I run into them.

 I assumed this is a GEOS problem based on the error message. If not, I
 will happily report elsewhere.

 Full PostGIS version, if it's of any help or I should look at upgrading

 {{{POSTGIS="2.1.4 r12966" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0,
 6 March 2012" GDAL="GDAL 1.9.2, released 2012/10/08" LIBXML="2.7.6"

 GEOS is the latest version, in spite of PostGIS being a little bit behind.
 I was trying to reproduce with a newer version of PostGIS, but
 PostgreSQL's apt repository contains an outdated GEOS. I don't have time
 right now to install all that again, but it is worth noting that this
 issue does ''not'' reproduce on GEOS 3.3.3. (Full version of that install
 is {{{POSTGIS="2.1.7 r13414" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.7.1, 23
 September 2009" GDAL="GDAL 1.9.0, released 2011/12/29" LIBXML="2.8.0"

Ticket URL: <https://trac.osgeo.org/geos/ticket/737>
GEOS <http://trac.osgeo.org/geos>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).

More information about the geos-devel mailing list