共用方式為


geo_point_to_geohash()

計算地理位置的地理hash 字串值。

深入瞭解 地理hash

語法

geo_point_to_geohash(經度,緯度,[ 精確度 ])

深入瞭解 語法慣例

參數

姓名 類型​​ 必要 描述
經度 real ✔️ 地理空間座標,以度為單位的經度值。 有效值為實數,且範圍 [-180, +180]。
緯度 real ✔️ 地理空間座標,以度為單位的緯度值。 有效值為實數,且範圍 [-90, +90]。
準確性 int 定義要求的精確度。 支援的值位於範圍 [1, 18]。 如果未指定,則會使用預設值 5

傳回

具有要求正確性長度之指定地理位置的地理hash 字串值。 如果座標或精確度無效,查詢會產生空的結果。

注意

  • Geohash 可以是實用的地理空間叢集工具。
  • Geohash 有 18 個精確度等級,面積覆蓋範圍從最高層級 1 到 0.6 公里 1 到 0.6 μ 18 級不等。
  • 地理哈希的常見前置詞表示彼此點的鄰近性。 共用前置詞越長,兩個位置越近。 精確度值會轉譯為地理混搭長度。
  • Geohash 是平面表面的矩形區域。
  • 以經度 x 和緯度 y 計算的地理hash 字串上叫用 geo_geohash_to_central_point() 函式不一定傳回 x 和 y。
  • 由於地理哈什定義,兩個地理位置可能彼此非常接近,但有不同的地理hash 代碼。

每個精確度值的地理hash 矩形區域涵蓋範圍:

正確性 寬度 高度
1 5000 公里 5000 公里
2 1250 公里 625 公里
3 156.25 公里 156.25 公里
4 39.06 公里 19.53 公里
5 4.88 公里 4.88 公里
6 1.22 公里 0.61 公里
7 152.59 m 152.59 m
8 38.15 m 19.07 公尺
9 4.77 公尺 4.77 公尺
10 1.19 m 0.59 m
11 149.01 公厘 149.01 公厘
12 37.25 公厘 18.63 公厘
13 4.66 公厘 4.66 公厘
14 1.16 公厘 0.58 公厘
15 145.52 μ 145.52 μ
16 36.28 μ 18.19 μ
17 4.55 μ 4.55 μ
18 1.14 μ 0.57 μ

請參閱geo_point_to_s2cell()geo_point_to_h3cell()

如需與其他可用網格系統的比較,請參閱地理空間叢集與 Kusto 查詢語言

範例

下列範例會尋找由 geohash 匯總的美國風暴事件。

StormEvents
| project BeginLon, BeginLat
| summarize by hash=geo_point_to_geohash(BeginLon, BeginLat, 3)
| project geo_geohash_to_central_point(hash)
| render scatterchart with (kind=map)

輸出

依地理hash分組的美國風暴事件的螢幕快照。

下列範例會計算並傳回 geohash 字串值。

print geohash = geo_point_to_geohash(-80.195829, 25.802215, 8)

輸出

geohash
dhwfz15h

下列範例會尋找座標群組。 群組中的每個座標組都位於矩形區域 4.88 公里到 4.88 公里。

datatable(location_id:string, longitude:real, latitude:real)
[
  "A", double(-122.303404), 47.570482,
  "B", double(-122.304745), 47.567052,
  "C", double(-122.278156), 47.566936,
]
| summarize count = count(),                                          // items per group count
            locations = make_list(location_id)                        // items in the group
            by geohash = geo_point_to_geohash(longitude, latitude)    // geohash of the group

輸出

geohash 計數 位置
c23n8 2 [“A”, “B”]
c23n9 1 ["C"]

下列範例會產生空的結果,因為座標輸入無效。

print geohash = geo_point_to_geohash(200,1,8)

輸出

geohash

下列範例會產生空的結果,因為精確度輸入無效。

print geohash = geo_point_to_geohash(1,1,int(null))

輸出

geohash