Opened 4 years ago
Closed 4 years ago
#4713 closed defect (fixed)
Degenerated polygons from ST_Difference
Reported by: | José de Paula Rodrigues Neto Assis | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS GEOS |
Component: | postgis | Version: | 3.0.x |
Keywords: | Cc: | José de Paula Rodrigues Neto Assis |
Description
When trying to do a ST_Difference between two fairly complex MultiPolygons, the result is a MultiPolygon composed of rectangles and triangles, looking like overly simplified shapes.
- Database version: PostgreSQL 12.3
- OS/Architecture: Gentoo Linux, AMD64 (also reproduced with CentOS 8/PGDG repo)
- PostGIS version: 3.0.1
- GEOS version: 3.8.1
- GDAL version: 3.1.0
- PROJ version: 7.0.1
The table definitions are as follows:
CREATE TABLE tb_test_a ( id integer PRIMARY KEY, geom geometry(MultiPolygon,4674) ); CREATE TABLE tb_test_b ( id integer PRIMARY KEY, geom geometry(MultiPolygon,4674) );
They have a single record each, with a different geometry in each case, which I'm attaching to this report; they are both ST_Valid() MultiPolygons.
This is what generates the degenerated polygons:
SELECT ST_Difference(a.geom, b.geom) geom FROM tb_test_a a, tb_test_b b
If I wrap both geometries with ST_MakeValid(ST_SnapToGrid()), I get the expected results:
SELECT ST_Difference( ST_MakeValid(ST_SnapToGrid(a.geom, 0.0000000001)), ST_MakeValid(ST_SnapToGrid(b.geom, 0.0000000001)) ) geom FROM tb_test_a a, tb_test_b b
I have to make ST_MakeValid after snapping because of self-intersection errors.
I've also seen cases of ST_Intersection failing the same way (generating too simplified results) with similarly complex source MultiPolygons (but not with the attached data).
Attachments (4)
Change History (7)
by , 4 years ago
Attachment: | dump_teste_diff.backup added |
---|
by , 4 years ago
Attachment: | result_st_difference_a_b.png added |
---|
Preview of ST_Difference - this is the bug
comment:1 by , 4 years ago
Cc: | added |
---|
comment:2 by , 4 years ago
Milestone: | PostGIS 3.1.0 → PostGIS GEOS |
---|
comment:3 by , 4 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
As of GEOS 3.9, the output is a valid polygon.
PostgreSQL 12.0 database dump of the bug data