Contains (spatial predicate)
True if geometry A completely contains geometry B (B is inside A, not just touching the edge).
Category: Topology · Also known as: ST_Contains, contains predicate
Definition (expanded)
Contains is a boolean spatial relationship commonly used in GIS and PostGIS. Many definitions treat boundary-only contact as NOT contained (strict contains). If you want boundary-inclusive behavior, some systems use Covers instead.
Examples
PostGIS contains
SQL
SELECT ST_Contains(a.geom, b.geom) FROM a, b;
Common mistakes
- Expecting points on the boundary to return true (often false for strict contains).
- Mixing up Contains and Within (they are inverses).
Related terms
Within (spatial predicate)True if geometry A lies completely inside geometry B (the inverse of Contains).Intersects (spatial predicate)True when two geometries share any point in common (touching or overlapping).Touches (spatial predicate)True when two geometries touch at the boundary but do not overlap in area (or interior).Disjoint (spatial predicate)True when two geometries share no points at all (no intersection).Point-in-polygon (PIP)A test that checks whether a point lies inside a polygon (often used for geofencing and joins).