Opened 3 years ago

Closed 3 years ago

#4843 closed defect (wontfix)

GEOS TopologyException in ST_Intersection of line/polygon

Reported by: ezimanyi Owned by: pramsey
Priority: medium Milestone: PostGIS 3.1.2
Component: postgis Version: 2.5.x -- EOL
Keywords: GEOS ST_Intersection Cc:

Description

I have loaded into PostGIS OSM data from Belgium. I have synthetically generated trips on the road network and I need to project the trips (LINESTRING) to the municipalities (POLYGON). When I perform an intersection of one trip and one municipality (whose name is Anderlecht) I get an error from GEOS. A have isolated the trip and the municipality that generates the error in CSV files. This is how to reproduce the error

$ createdb geoserror
$ psql geoserror

# create extension postgis
# create table trip(tripgeo geometry);
# copy trip(tripgeo) from '/path/to/file/trip.csv' CSV HEADER;
# create table municipality(municgeo geometry);
# copy municipality(municgeo) from '/path/to/file/municipality.csv' CSV HEADER;
# select st_intersects(municgeo, tripgeo) from municipality, trip;
 st_intersects
---------------
 t
(1 row)

# select st_intersection(municgeo, tripgeo) from municipality, trip;
2021-02-09 16:06:13.040 CET [6575] ERROR:  lwgeom_intersection: GEOS Error: TopologyException: found non-noded intersection between LINESTRING (476752 6.59276e+06, 476752 6.59275e+06) and LINESTRING (476753 6.59276e+06, 476752 6.59275e+06) at 476752.16199349175 6592757.7807903718
2021-02-09 16:06:13.040 CET [6575] STATEMENT:  select st_intersection(municgeo, tripgeo) from municipality, trip;
ERROR:  lwgeom_intersection: GEOS Error: TopologyException: found non-noded intersection between LINESTRING (476752 6.59276e+06, 476752 6.59275e+06) and LINESTRING (476753 6.59276e+06, 476752 6.59275e+06) at 476752.16199349175 6592757.7807903718

# select postgis_full_version();
POSTGIS="2.5.5" [EXTENSION] PGSQL="130" GEOS="3.8.0-CAPI-1.13.1 " PROJ="Rel. 6.3.1, February 10th, 2020" GDAL="GDAL 3.0
.4, released 2020/01/28" LIBXML="2.9.10" LIBJSON="0.13.1" RASTER


Attachments (3)

municipality.csv (35.2 KB ) - added by ezimanyi 3 years ago.
trip.csv (376.6 KB ) - added by ezimanyi 3 years ago.
geoserror.png (188.4 KB ) - added by ezimanyi 3 years ago.

Download all attachments as: .zip

Change History (7)

by ezimanyi, 3 years ago

Attachment: municipality.csv added

by ezimanyi, 3 years ago

Attachment: trip.csv added

by ezimanyi, 3 years ago

Attachment: geoserror.png added

comment:1 by ezimanyi, 3 years ago

Enclosed also the visualization of the trip and the municipality in QGIS.

comment:2 by mdavis, 3 years ago

This looks like the usual overlay robustness error. PostGIS 3.0 with GEOS 3.9 introduced major improvements in overlay (ST_Intersection, etc). Can you try out that version?

If that's not possible, then there are a few hacks to try and get it to work. One is to snap one or both geometries to a small grid - this can sometimes change the data just enough to get it to work.

comment:3 by mdavis, 3 years ago

Keywords: ST_Intersection added; ST_Intersects removed
Summary: GEOS errorGEOS TopologyException in ST_Intersection of line/polygon

comment:4 by pramsey, 3 years ago

Resolution: wontfix
Status: newclosed

I'm going to close this out as "wontfix" because an upgrade to GEOS 3.9 should fix it.

Note: See TracTickets for help on using tickets.