When performing Spatial Contains query I am not getting expected results.
I have below use case where I want only those small polygons as shown in first image namely (1,2,3,4,5,6,7,8,9) whose geometry which lie within big polygons as shown in second image (let's assume polygon 1) should get highlighted.
When I am performing spatial query in PostgreSQL using PostGIS I am using ST_Contains(geometry geomA, geometry geomB) method which clearly states as per documentation "Returns TRUE if geometry B is completely inside geometry A. A contains B if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A" I am getting only polygon 3 as shown in third image below. However, I am expecting all polygons in first image from 1-9 should get highlighted
if no points of B lie in the exterior of A
. Is the boundary or A exterior or interior?A subtlety of the definition is that a geometry does not contain its boundary. This implies that polygons and lines do not contain lines and points lying in their boundary.
Need some more thinking to understand what it really means.select ST_contains( ST_GeomFromText('POLYGON (( 300 380, 420 480, 420 260, 300 380 ))'), ST_GeomFromText('POLYGON (( 360 380, 420 480, 420 260, 360 380 ))'))
(two triangles having two corners in common). I bet there are square-nanometer overlap areas in the data.