Skip to main content
Version: Next

booleanPointInPolygon

Description

Determines if a point lies within a polygon. The polygon can be convex or concave, or contain holes.

Parameters

NameTypeDescription
pointPosition | Point | Feature<Point>Point possibly within the polygon.
polygonFeature<Polygon | MultiPolygon>Polygon to search within.
options?ObjectOptional parameters. (default {})
options.ignoreBoundary?booleanIf set to true, a point lying on the polygon boundary is not considered to be within the polygon. (default false)

Returns

boolean True if the point lies within the polygon, false otherwise.

Examples

var pt = turf.point([-77, 44]);
var poly = turf.polygon([
[
[-81, 41],
[-81, 47],
[-72, 47],
[-72, 41],
[-81, 41],
],
]);

turf.booleanPointInPolygon(pt, poly);
//= true

Installation

$ npm install @turf/boolean-point-in-polygon

import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
const result = booleanPointInPolygon(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.booleanPointInPolygon(...);