Atlaslog
Atlaslog / Turf.js / Tutorial / Point, line and polygon relationships
Turf.js · Tutorial

Point, line and polygon relationships

Quick answer

This tutorial maps predicates to geometry pairs: booleanPointInPolygon, booleanPointOnLine, booleanContains, booleanWithin, booleanIntersects, booleanDisjoint, booleanTouches and booleanOverlap. It highlights the boundary rule, where edge points count as inside unless ignoreBoundary: true is passed, and the strict all-or-nothing semantics of contains and within. You will be able to choose the correct predicate and speed up bulk tests.

Last verified 2026-11-03 · Turf.js 7.x · Cite this page
Key points
Example
var poly = turf.polygon([[[116.35, 39.86], [116.45, 39.86], [116.45, 39.94],
                          [116.35, 39.94], [116.35, 39.86]]]);

var onEdge = turf.point([116.35, 39.90]);

console.log(turf.booleanPointInPolygon(onEdge, poly));                          // true
console.log(turf.booleanPointInPolygon(onEdge, poly, { ignoreBoundary: true })); // false
var x = turf.polygon([[[116.40, 39.88], [116.48, 39.88], [116.48, 39.96],
                      [116.40, 39.96], [116.40, 39.88]]]);

console.log(turf.booleanIntersects(poly, x));   // true,有重叠
console.log(turf.booleanDisjoint(poly, x));     // false
console.log(turf.booleanTouches(poly, x));      // false,重叠不在边界
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Point, line and polygon relationships. https://www.jingweizhi.com/en/turf/tutorials/relations.html (accessed 2026-11-03).