Skip to main content
naming
Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

Postgis PostGIS ST_Intersects does not work as expected - it returns false although ST_Covers return true

Source Link

Postgis ST_Intersects does not work as expected - it returns false although ST_Covers return true

I have two polygons such that polygon A (pie-shaped) covers polygon B (rectangle) as shown here: https://wktmap.com/?6aaf8c11.

Why does PostGIS return false for ST_Intersects(A, B), but true for ST_Covers(A, B)? It does not make any sense.

SELECT st_intersects(ST_GeomFromText('POLYGON((16.00061 45.822171,15.99285240563651 45.8293452320342,15.990050859670909 45.82732350122485,15.988282915930574 45.82479740769603,15.987721633066801 45.82201422308267,15.988421953356983 45.8192463848863,16.00061 45.822171))',4326), ST_GeomFromText('POLYGON((15.989 45.82, 15.989 45.82, 15.989 45.82, 15.989 45.82, 15.989 45.82))',4326));
 st_intersects 
---------------
 f
(1 row)
SELECT st_covers(ST_GeomFromText('POLYGON((16.00061 45.822171,15.99285240563651 45.8293452320342,15.990050859670909 45.82732350122485,15.988282915930574 45.82479740769603,15.987721633066801 45.82201422308267,15.988421953356983 45.8192463848863,16.00061 45.822171))',4326), ST_GeomFromText('POLYGON((15.989 45.82, 15.989 45.82, 15.989 45.82, 15.989 45.82, 15.989 45.82))',4326));
 st_covers 
-----------
 t
(1 row)
SELECT PostGIS_version();
            postgis_version            
---------------------------------------
 3.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)

SELECT version();
                                                                version                                                                 
----------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 14.12 (Ubuntu 14.12-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit
(1 row)