Opened 6 years ago

Closed 3 years ago

#3984 closed defect (fixed)

intersections between valid geometry and raster throw TopologyException

Reported by: turntwo463 Owned by: pramsey
Priority: high Milestone: PostGIS GEOS
Component: postgis Version: 3.1.x
Keywords: intersections, Cc:

Description

A significant proportion of intersections between polygons and raster often fail with ERROR: GEOSIntersects: TopologyException: side location conflict. The polygons are valid when checked with ST_IsValid.

An example query that can reproduce this is the following:

SELECT rid, rast, filename, ST_Intersection(rast,

ST_GeomFromText('MULTIPOLYGON (((586930.2651485216 4532526.288145695, 586929.162455693 4532515.09231752, 586919.2106084262 4532516.072488924,

586920.6808655312 4532531.000259823, 586926.9007700728 4532530.387652696, 586930.2651485216 4532526.288145695)))', 26918))

FROM processing.dem where ST_Intersects(rast,

ST_GeomFromText('MULTIPOLYGON (((586930.2651485216 4532526.288145695, 586929.162455693 4532515.09231752, 586919.2106084262 4532516.072488924,

586920.6808655312 4532531.000259823, 586926.9007700728 4532530.387652696, 586930.2651485216 4532526.288145695)))', 26918))

The dem table was loaded using the following:

raster2pgsql -c -I -s 26918 "C:\temp\USGS_NED_one_meter_x58y454_NJ_SdL5_2014_IMG_2015.img" -F -t 25x25 processing.dem | psql -d mydb -h 127.0.0.1 -p 5432 -U the_admin

The dem table can be downloaded from:

https://prd-tnm.s3.amazonaws.com/StagedProducts/Elevation/1m/IMG/USGS_NED_one_meter_x58y454_NJ_SdL5_2014_IMG_2015.zip

Version information for PostGIS is:

POSTGIS="2.3.2 r15302" GEOS="3.6.1-CAPI-1.10.1 r4317" PROJ="Rel. 4.9.1, 04 March 2015" GDAL="GDAL 2.1.3, released 2017/20/01" LIBXML="2.7.8" LIBJSON="0.12" TOPOLOGY RASTER

Change History (4)

comment:1 by robe, 6 years ago

Component: rasterpostgis
Milestone: PostGIS 2.3.6PostGIS GEOS
Owner: changed from Bborie Park to pramsey

hmm this sounds more like a GEOS problem than a raster one.

If both pass ST_ISValid, then raster has done it's job. I'm going to flip this to GEOS and try to test with 3.6.2 to see if it has same issue.

comment:2 by turntwo463, 6 years ago

Any update on this? I've tried this now with the latest version of PostGIS and still get an error:

ERROR: GEOSIntersects: TopologyException: side location conflict at 586918.99999999942 4532531.9999253498 CONTEXT: PL/pgSQL function _st_intersects(geometry,raster,integer) line 22 at RETURN PL/pgSQL function st_intersection(geometry,raster,integer) line 5 at assignment SQL function "st_intersection" statement 1 SQL state: XX000

Perhaps a precision issue?

POSTGIS="2.4.3 r16312" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.3, released 2017/11/20" LIBXML="2.7.8" LIBJSON="0.12" LIBPROTOBUF="1.2.1" TOPOLOGY RASTER

comment:3 by Algunenano, 5 years ago

Priority: criticalhigh

comment:4 by pramsey, 3 years ago

Resolution: fixed
Status: newclosed
Version: 2.3.x3.1.x

GEOS 3.9 should get this.

Note: See TracTickets for help on using tickets.