Point-in-polygon (PIP)
A test that checks whether a point lies inside a polygon (often used for geofencing and joins).
Category: Topology · Also known as: point in polygon, PIP test, point-in-polygon
Definition (expanded)
Point-in-polygon (PIP) is the classic spatial test: is point P inside polygon A? Details matter: points on the boundary may be treated differently depending on the predicate (Contains vs Covers) and how holes are represented.
Examples
PIP in PostGIS (contains)
Coordinates are lon, lat when using EPSG:4326.
SQL
SELECT ST_Contains(ST_GeomFromText('POLYGON((12 55, 12.2 55, 12.2 55.2, 12 55.2, 12 55))', 4326), ST_Point(12.1, 55.1));Common mistakes
- Confusing boundary behavior (a point on the edge may be false for ST_Contains).
- Forgetting holes: points inside a hole are NOT inside the polygon area.
Related terms
Contains (spatial predicate)True if geometry A completely contains geometry B (B is inside A, not just touching the edge).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).PolygonA closed area geometry defined by an exterior ring and optional interior rings (holes).Hole (Interior Ring)An interior ring inside a polygon that subtracts area (a cut-out).