Skip to main content
Version: 7.3.0

pointToPolygonDistance

描述

🌐 Description

计算一个点到多边形或多多边形边缘的距离。 对多边形内部的点返回负值。 支持带孔的多边形和多多边形。 孔被视为多边形的外部。

🌐 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

名称类型描述
pointFeature<Point> | Point | Position输入点
polygonOrMultiPolygonFeature<Polygon | MultiPolygon> | Polygon | MultiPolygon输入多边形或多多边形
optionsObject可选参数 (默认 {})
options.unitsUnits结果的单位,例如“千米”、“英里”、“米”
options.method"geodesic" | "planar"结果的方法

返回

🌐 Returns

number 距离(米)(多边形内的点为负值)

安装

🌐 Installation

$ npm install @turf/point-to-polygon-distance

import { pointToPolygonDistance } from "@turf/point-to-polygon-distance";
const result = pointToPolygonDistance(...);
$ npm install @turf/turf

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