ST_Covers
What is ST_Covers?
ST_Covers is a PostGIS spatial predicate that returns true when no point of geometry B lies in the exterior of geometry A. It is the boundary-inclusive sibling of ST_Contains — a point on A's boundary is still "covered" by A.
1ST_Covers(geometry geomA, geometry geomB) → boolean
2ST_Covers(geography geogA, geography geogB) → booleanIt is the inverse of ST_CoveredBy: ST_Covers(A, B) ↔ ST_CoveredBy(B, A).
When would you use ST_Covers?
Use ST_Covers whenever you want the natural "is inside or on the edge" semantics. It is the recommended predicate for point-in-polygon queries because it avoids the boundary ambiguity of ST_Contains — a geocoded address that lands exactly on an administrative border will still match the expected polygon.
1SELECT a.id, d.name
2FROM addresses a
3JOIN districts d ON ST_Covers(d.geom, a.geom);FAQs
Why prefer ST_Covers over ST_Contains for point-in-polygon joins?
ST_Contains requires the point to lie strictly in the polygon's interior — a point on the boundary is not contained. ST_Covers accepts boundary contact, so you don't miss edge cases where coordinates happen to land exactly on a shared line. It's usually the right default for addresses, sensors, or any data that may be snapped to administrative borders.
Does ST_Covers use spatial indexes?
Yes. The bounding-box operator ~ (A's bbox contains B's bbox) is used as an index filter before the exact predicate runs. For large joins, create a GiST index on the geometry columns and the planner will use it automatically.
Does ST_Covers work on geography?
Yes. There is a dedicated geography overload that computes the relation on the sphere, which is correct for continental- or global-scale data in EPSG:4326. Cast with ::geography if your column is geometry.
Is ST_Covers in the OGC spec?
No, ST_Covers / ST_CoveredBy are extensions added by PostGIS (and also present in Oracle Spatial and others) to provide useful boundary-inclusive semantics. The OGC Simple Features spec only defines ST_Contains and ST_Within.