Package Exports
- @turf/point-to-polygon-distance
- @turf/point-to-polygon-distance/package.json
Readme
@turf/point-to-polygon-distance
pointToPolygonDistance
Calculates the distance from a point to the edges of a polygon or multi-polygon. Returns negative values for points inside the polygon. Handles polygons with holes and multi-polygons. A hole is treated as the exterior of the polygon.
Parameters
polygonOrMultiPolygon(Feature<(Polygon | MultiPolygon)> | Polygon | MultiPolygon) Input polygon or multipolygonoptionsObject Optional parameters (optional, default{})options.unitsUnits Units of the result e.g. "kilometers", "miles", "meters"options.method("geodesic"|"planar") Method of the result
- Throws Error If input geometries are invalid
Returns number Distance in meters (negative values for points inside the polygon)
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Installation
Install this single module individually:
$ npm install @turf/point-to-polygon-distanceOr install the all-encompassing @turf/turf module that includes all modules as functions:
$ npm install @turf/turf