Opened 6 years ago

Closed 5 years ago

#847 closed defect (wontfix)

Intersection operation results in polygons with "terraced" boundaries

Reported by: bute Owned by: strk
Priority: major Milestone: 3.6.4
Component: Core Version: 3.5.0
Severity: Critical Keywords: intersection terraced steps
Cc:

Description

I suspect that this bug originates in the GEOS library since it occurs in both, PostGIS and QGIS alike.

I extracted and reduced the affected geometry data source to a clean and simple test setup that I attach to this report (steps.zip). The ZIP file includes two GeoJSON files that each contains one MultiPolygon geometry. Both geometries are valid and simple. I tested them in PostGIS 2.4.0 (GEOS version 3.4.2-CAPI-1.8.2).

It is very simple to reproduce the bug with QGIS 2.18.3 (GEOS version 3.5.0-CAPI-1.9.0): Extract the attached ZIP file, load both GeoJSON files (A.geojson and B.geojson) into QGIS and then perform the intersection operation of QGIS (=> Vector => Geoprocessing Tools => Intersection) with layers A and B ("Input layer": A, "Intersect layer": B).

The resulting MultiPolygon geometry will have odd "steps" in its boundary e.g. at coordinates 2731740.84,1240723.47 (see attached screenshot steps.png), though these "steps" are in none of the originating geometries. Now the interesting thing about this is that the steps precisely align along a 1 meter grid (see attached screenshot steps_grid.png).

I worry that this issue will also affect other GEOS users and can cause unpredictable issues in critical scenarios.

Attachments (4)

steps.zip (17.3 KB ) - added by bute 6 years ago.
steps.png (24.7 KB ) - added by bute 6 years ago.
steps_grid.png (25.6 KB ) - added by bute 6 years ago.
steps.sql.tgz (21.3 KB ) - added by darkblueb 5 years ago.

Download all attachments as: .zip

Change History (7)

by bute, 6 years ago

Attachment: steps.zip added

by bute, 6 years ago

Attachment: steps.png added

by bute, 6 years ago

Attachment: steps_grid.png added

comment:1 by robe, 6 years ago

Milestone: 3.6.33.6.4

If you can provide a PostGIS dump table to replicate that owuld help. Dealing with json output is too much effort.

comment:2 by darkblueb, 5 years ago

unzip steps.zip
ogrinfo A.geojson
ogr2ogr -f PostgreSQL PG:dbname=user  -lco GEOMETRY_NAME=geom -nln ageojson A.geojson
ogr2ogr -f PostgreSQL PG:dbname=user  -lco GEOMETRY_NAME=geom -nln bgeojson B.geojson

pg_dump -t ageojson user > ageojson.sql
pg_dump -t bgeojson user > bgeojson.sql

by darkblueb, 5 years ago

Attachment: steps.sql.tgz added

comment:3 by pramsey, 5 years ago

Resolution: wontfix
Status: newclosed

I'm going to close this as "wontfix". Basically you're seeing the operation of the fall-back machinery trying to salvage an overlay operation that failed by reducing precision of the inputs. I guess it had to fall back fairly far.

This is a big problem with hard overlays, because the solutions to overlay issues involve altering the shape of inputs, through snapping and precision reduction to avoid non-deterministic results at full precision. The new overlay code that eventually drops will still have this problem: things will move around sometimes.

Note: See TracTickets for help on using tickets.