geo_distance_point_to_line()geo_distance_point_to_line()

计算地球上坐标和直线之间的最短距离。Calculates the shortest distance between a coordinate and a line on Earth.

语法Syntax

geo_distance_point_to_line(longitude, latitude, lineString) geo_distance_point_to_line(longitude, latitude, lineString)

参数Arguments

  • longitude:地理空间坐标经度值(度)。longitude: Geospatial coordinate longitude value in degrees. 有效值为 [-180, +180] 范围内的实数。Valid value is a real number and in the range [-180, +180].
  • latitude:地理空间坐标纬度值(度)。latitude: Geospatial coordinate latitude value in degrees. 有效值为 [-90, +90] 范围内的实数。Valid value is a real number and in the range [-90, +90].
  • lineString:采用 GeoJSON 格式动态数据类型的直线。lineString: Line in the GeoJSON format and of a dynamic data type.

返回Returns

地球上坐标和直线之间的最短距离(米)。The shortest distance, in meters, between a coordinate and a line on Earth. 如果坐标或 lineString 无效,则查询将生成 null 结果。If the coordinate or lineString are invalid, the query will produce a null result.

备注

  • WGS-84 坐标参考系统表示方法对地理空间坐标进行解释。The geospatial coordinates are interpreted as represented by the WGS-84 coordinate reference system.
  • 用于测量地球上的距离的大地基准是一个球体。The geodetic datum used to measure distance on Earth is a sphere. 直线边缘是球体上的测地线。Line edges are geodesics on the sphere.

LineString 定义和约束LineString definition and constraints

dynamic({"type":"LineString","coordinates": [ [lng_1,lat_1], [lng_2,lat_2] ,..., [lng_N,lat_N] ]})dynamic({"type": "LineString","coordinates": [ [lng_1,lat_1], [lng_2,lat_2] ,..., [lng_N,lat_N] ]})

  • LineString 坐标数组必须至少包含两个条目。LineString coordinates array must contain at least two entries.
  • 如果 longitude 是 [-180, +180] 范围内的实数,而 latitude 是 [-90, +90] 范围内的实数,则坐标 [longitude,latitude] 必须有效。Coordinates [longitude,latitude] must be valid where longitude is a real number in the range [-180, +180] and latitude is a real number in the range [-90, +90].
  • 边缘长度必须小于 180 度。Edge length must be less than 180 degrees. 将选择两个顶点之间的最短边缘。The shortest edge between the two vertices will be chosen.

提示

为了获得更好的性能,请使用文字直线。For better performance, use literal lines.

示例Examples

以下示例查找北拉斯维加斯机场和附近道路之间的最短距离。The following example finds the shortest distance between North Las Vegas Airport and a nearby road.

北拉斯维加斯机场与道路之间的距离

print distance_in_meters = geo_distance_point_to_line(-115.199625, 36.210419, dynamic({ "type":"LineString","coordinates":[[-115.115385,36.229195],[-115.136995,36.200366],[-115.140252,36.192470],[-115.143558,36.188523],[-115.144076,36.181954],[-115.154662,36.174483],[-115.166431,36.176388],[-115.183289,36.175007],[-115.192612,36.176736],[-115.202485,36.173439],[-115.225355,36.174365]]}))
distance_in_metersdistance_in_meters
3797.888872533343797.88887253334

美国南海岸的暴风雨事件。Storm events in south coast US. 按距离定义的海岸线最多 5 公里筛选事件。The events are filtered by a maximum distance of 5 km from the defined shore line.

美国南海岸的暴风雨事件

let southCoast = dynamic({"type":"LineString","coordinates":[[-97.18505859374999,25.997549919572112],[-97.58056640625,26.96124577052697],[-97.119140625,27.955591004642553],[-94.04296874999999,29.726222319395504],[-92.98828125,29.82158272057499],[-89.18701171875,29.11377539511439],[-89.384765625,30.315987718557867],[-87.5830078125,30.221101852485987],[-86.484375,30.4297295750316],[-85.1220703125,29.6880527498568],[-84.00146484374999,30.14512718337613],[-82.6611328125,28.806173508854776],[-82.81494140625,28.033197847676377],[-82.177734375,26.52956523826758],[-80.9912109375,25.20494115356912]]});
StormEvents
| project BeginLon, BeginLat, EventType
| where geo_distance_point_to_line(BeginLon, BeginLat, southCoast) < 5000
| render scatterchart with (kind=map) // map rendering available in Kusto Explorer desktop

纽约出租车接客。NY taxi pickups. 按距离定义的直线最多 0.1 米筛选接客事件。Pickups are filtered by maximum distance of 0.1 m from the defined line.

美国南海岸的暴风雨事件

nyc_taxi
| project pickup_longitude, pickup_latitude
| where geo_distance_point_to_line(pickup_longitude, pickup_latitude, dynamic({"type":"LineString","coordinates":[[-73.97583961486816,40.75486445336327],[-73.95215034484863,40.78743027428638]]})) <= 0.1
| take 50
| render scatterchart with (kind=map) // map rendering available in Kusto Explorer desktop

由于 LineString 输入无效,以下示例将返回 null 结果。The following example will return a null result because of the invalid LineString input.

print distance_in_meters = geo_distance_point_to_line(1,1, dynamic({ "type":"LineString"}))
distance_in_metersdistance_in_meters

由于坐标输入无效,以下示例将返回 null 结果。The following example will return a null result because of the invalid coordinate input.

print distance_in_meters = geo_distance_point_to_line(300, 3, dynamic({ "type":"LineString","coordinates":[[1,1],[2,2]]}))
distance_in_metersdistance_in_meters