pointInPolygon
Quick answer
pointInPolygon tests whether a Point lies inside a Polygon or MultiPolygon and returns a boolean, honouring interior rings as holes. Call turf.pointInPolygon(point, polygon, {ignoreBoundary}); by default points exactly on the boundary count as inside. booleanPointInPolygon is the feature-oriented equivalent and underpins several other boolean relation helpers.
turf.pointInPolygon( point , polygon , options ) → boolean
Key points
- Honours holes, so points inside a ring gap return false.
- options.ignoreBoundary excludes points lying exactly on the edge.
- Accepts Polygon and MultiPolygon inputs without unwrapping.
Example
var inPoly = turf.pointInPolygon || turf.booleanPointInPolygon;
console.log(inPoly(turf.point([116.39, 39.90]), polygon));var park = turf.polygon([[
[116.300, 39.950], [116.360, 39.950], [116.360, 39.995],
[116.300, 39.995], [116.300, 39.950]
]]);
var inside = turf.point([116.330, 39.970]);
var outside = turf.point([116.380, 39.970]);
var onEdge = turf.point([116.300, 39.970]);
console.log(turf.pointInPolygon(inside, park)); // true
console.log(turf.pointInPolygon(outside, park)); // false
console.log(turf.pointInPolygon(onEdge, park)); // true
console.log(turf.pointInPolygon(onEdge, park, { ignoreBoundary: true })); // false
Notes
- Boundary behaviour differs from booleanPointInPolygon when options are omitted.
- Calling it in a tight per-point loop is slow; index or batch instead.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). pointInPolygon. https://www.jingweizhi.com/en/turf/api/point-in-polygon.html (accessed 2026-11-03).