Skip to content
On this page

计算点到线段的距离(pointToLineDistance)

js
npm install @turf/point-to-line-distance

计算一个点和一条LineString之间的最小距离,即点和LineString的任何线段之间的最小距离。

Returns the minimum distance between a Point and a LineString , being the distance from a line the minimum distance between the point and any segment of the LineString.

参数

参数类型描述
pt(Feature <Point>/Array )Feature or Geometry
lineFeature <LineString>GeoJSON Feature or Geometry
optionsObject配置项

配置项(Options)

Prop类型默认值描述
unitsstringkilometers你可以选择:degrees(角度) radians(弧度) miles(英里) 或者 kilometers(千米)
methodstringgeodesic是用测地线(球面)法计算距离还是用平面(平面)法计算距离。可选:geodesicplanar

返回(Returns)

number - 点与线之间的距离

示例