[postgis-users] TopologyException: found non-noded intersection

Lars Aksel Opsahl lop at skogoglandskap.no
Fri Aug 17 02:01:00 PDT 2012



In the attached file it's 2 rows.


I import the data with shp2pgsql


“shp2pgsql -c -s 4258 -i -I g1_and_g2.shp test_sql.g1_and_g2 | psql -hd4t -Upostgres -d sl_help”


The server Centos 6.3 with postgis_full_version

------------------------------------------------------------------------------------------------------------

POSTGIS="2.0.1 r9979" GEOS="3.3.5-CAPI-1.7.5" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.6" TOPOLOGY


The two geometries are both valid and is of type MultiPolygon


I need the find difference between the 2 rows but it fails with TopologyException


Just to show type of geos.


SELECT

ST_GeometryType(g1.geo) as g1_type,

ST_GeometryType(g2.geo) as g2_type,

ST_IsValid(g1.geo) as g1_valid,

ST_IsValid(g2.geo) as g2_valid

FROM

(SELECT geom as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g1' ) as g1,

(SELECT geom as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g2' ) as g2

g1_type | g2_type | g1_valid | g2_valid

-----------------+-----------------+----------+----------

ST_MultiPolygon | ST_MultiPolygon | t | t

(1 row)



Here are some commands that I have tested and the results.



select ST_Difference(g1.geo, g2.geo) from

(SELECT geom as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g1' ) as g1,

(SELECT geom as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g2' ) as g2;


ERROR: GEOSDifference: TopologyException: found non-noded intersection between LINESTRING (10.8002 59.4661, 10.8 59.4661) and LINESTRING (10.8001 59.4661, 10.8001 59.4661) at 10.800071629184332 59.466074451376585



select ST_Difference(g1.geo, g2.geo) from

(SELECT ST_Buffer(geom,0) as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g1' ) as g1,

(SELECT ST_Buffer(geom,0) as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g2' ) as g2;


ERROR: GEOSDifference: TopologyException: found non-noded intersection between LINESTRING (11.002 59.661, 11.002 59.6602) and LINESTRING (11.002 59.661, 11.002 59.6608) at 11.001972619901519 59.660870467723484



select ST_Difference(g1.geo, g2.geo) from

(SELECT ST_SnapToGrid(geom,0.000001) as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g1' ) as g1,

(SELECT ST_SnapToGrid(geom,0.000001) as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g2' ) as g2;


NOTICE: Self-intersection at or near point 11.020199045252591 59.638104976139537

st_difference

---------------

(0 rows)



select ST_Difference(g1.geo, g2.geo) from

(SELECT ST_SimplifyPreserveTopology(geom,0.000001) as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g1' ) as g1,

(SELECT ST_SimplifyPreserveTopology(geom,0.000001) as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g2' ) as g2;


ERROR: GEOSDifference: TopologyException: found non-noded intersection between LINESTRING (11.002 59.6583, 11.002 59.6583) and LINESTRING (11.002 59.6585, 11.002 59.6583) at 11.001950938642137 59.658266054048291



select ST_Union(g1.geo, g2.geo) from

(SELECT geom as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g1' ) as g1,

(SELECT geom as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g2' ) as g2;


ERROR: GEOSUnion: TopologyException: found non-noded intersection between LINESTRING (10.8002 59.4661, 10.8 59.4661) and LINESTRING (10.8001 59.4661, 10.8001 59.4661) at 10.800071629184332 59.466074451376585



select ST_Intersection(g1.geo, g2.geo) from

(SELECT geom as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g1' ) as g1,

(SELECT geom as geo FROM test_sql.g1_and_g2 WHERE geo_name = 'geo_name_g2' ) as g2;


ERROR: Error performing intersection: TopologyException: found non-noded intersection between LINESTRING (10.8002 59.4661, 10.8 59.4661) and LINESTRING (10.8001 59.4661, 10.8001 59.4661) at 10.800071629184332 59.466074451376585


I have also tested with "WHERE ST_IsValid(g1.geo)  AND ST_IsValid(g2.geo)" but does not change anything.


Should I just report this as bug ?


Or is a another way to handle this problem ?



Lars
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TopoError.zip
Type: application/zip
Size: 845243 bytes
Desc: TopoError.zip
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120817/189528a6/attachment.zip>


More information about the postgis-users mailing list