geo_distance_2points()

适用于:✅Azure 数据资源管理器Azure MonitorMicrosoft Sentinel

计算地球上两个地理空间坐标之间的最短距离(米)。

语法

geo_distance_2points( , p1_longitude, p1_latitude, p2_longitude, p2_latitude[ use_spheroid ])

详细了解语法约定

参数

客户 类型​​ 必需 说明
p1_longitude real ✔️ 第一个地理空间坐标的经度值(度)。 有效值在 [-180, +180] 范围内。
p1_latitude real ✔️ 第一个地理空间坐标的纬度值(度)。 有效值在 [-90, +90] 范围内。
p2_longitude real ✔️ 第二个地理空间坐标的经度值(度)。 有效值在 [-180, +180] 范围内。
p2_latitude real ✔️ 第二个地理空间坐标的纬度值(度)。 有效值在 [-90, +90] 范围内。
use_spheroid bool 如果将 false 球体用作 测地基准 ,用于测量距离。 如果使用 true 球体测量距离。 如果未指定,则使用默认值 false

返回

地球上两个地理位置之间的最短距离(以米为单位)。 如果坐标无效,查询将生成 null 结果。

注意

  • 对按照 WGS-84 坐标参考系统表示的地理空间坐标进行解释。
  • 大多数应用程序应使用球体 ('use_spheroid' = false) 测量距离,这更高性能。 如果需要额外的精度,“use_spheroid”选项可以设置为“true”,对于额外的精度,这可能更与更大的距离更相关,这可能会因地球曲率而受到影响。

示例

下面的示例查找西雅图与洛杉矶之间的最短距离。

西雅图与洛杉矶之间的距离。

print distance_in_meters = geo_distance_2points(-122.407628, 47.578557, -118.275287, 34.019056)

输出

distance_in_meters
1546754.35197381

以下示例将查找从西雅图到伦敦的最短路径的近似值。 该线路由沿线串分布的距其 500 米范围内的坐标组成。

range i from 1 to 1000000 step 1
| project lng = rand() * real(-122), lat = rand() * 90
| where lng between(real(-122) .. 0) and lat between(47 .. 90)
| where geo_distance_point_to_line(lng,lat,dynamic({"type":"LineString","coordinates":[[-122,47],[0,51]]})) < 500
| render scatterchart with (kind=map)

输出

西雅图到伦敦的 LineString 的屏幕截图。

以下示例将查找两个坐标之间的最短距离在 1 米到 11 米之间的所有行。

StormEvents
| extend distance_1_to_11m = geo_distance_2points(BeginLon, BeginLat, EndLon, EndLat)
| where distance_1_to_11m between (1 .. 11)
| project distance_1_to_11m

输出

distance_1_to_11m
10.5723100154958
7.92153588248414

下面的示例由于坐标输入无效而返回 null 结果。

print distance = geo_distance_2points(300,1,1,1)

输出

距离