共用方式為


geo_s2cell_to_polygon()

適用於:✅Microsoft網狀架構Azure 數據✅總管 Azure 監視器✅Microsoft Sentinel

計算代表 S2 單元格矩形區域的多邊形。

深入瞭解 S2 單元格

語法

geo_s2cell_to_polygon(s2cell)

深入瞭解 語法慣例

參數

姓名 類型​​ 必要 描述
s2cell string ✔️ S2 單元格標記值,因為它是由geo_point_to_s2cell()計算。 S2 單元格標記的最大字串長度為 16 個字元。

傳回

GeoJSON 格式和動態數據類型的多邊形。 如果 s2cell 無效,查詢會產生 Null 結果。

注意

S2 單元格邊緣為球形地理區域。

範例

print s2cellPolygon = geo_s2cell_to_polygon("89c259")

輸出

s2cellPolygon
{
“type”: “Polygon”,
“coordinates”: [[-74.030012249838478, 40.8012684339439], [-74.030012249838478, 40.7222262918358], [-73.935982114337421, 40.708880489804564], [-73.935982114337421, 40.787917134506841], [-74.030012249838478, 40.8012684339439]]
}

下列範例會組合 S2 單元格多邊形的 GeoJSON 幾何集合。

datatable(lng:real, lat:real)
[
    -73.956683, 40.807907,
    -73.916869, 40.818314,
    -73.989148, 40.743273,
]
| project s2_hash = geo_point_to_s2cell(lng, lat, 10)
| project s2_hash_polygon = geo_s2cell_to_polygon(s2_hash)
| summarize s2_hash_polygon_lst = make_list(s2_hash_polygon)
| project bag_pack(
    "type", "Feature",
    "geometry", bag_pack("type", "GeometryCollection", "geometries", s2_hash_polygon_lst),
    "properties", bag_pack("name", "S2 Cell polygons collection"))

輸出

資料行1
{
“type”: “Feature”,
“geometry”: {“type”: “GeometryCollection”, “geometries”: [
{“type”: “Polygon”, “coordinates”: [[[-74.030012249838478, 40.880202851376716], [-74.030012249838478, 40.8012684339439], [-73.935982114337421, 40.787917134506841], [-73.935982114337421, 40.866846163445771], [-74.030012249838478, 40.880202851376716]]]},
{“type”: “Polygon”, “coordinates”: [[[-73.935982114337421, 40.866846163445771], [-73.935982114337421, 40.787917134506841], [-73.84190634076248, 40.774477568182071], [-73.84190634076248, 40.853401155678846], [-73.935982114337421, 40.866846163445771]]},
{“type”: “Polygon”, “coordinates”: [[[-74.030012249838478, 40.8012684339439], [-74.030012249838478, 40.7222262918358], [-73.935982114337421, 40.708880489804564], [-73.935982114337421, 40.787917134506841], [-74.030012249838478, 40.8012684339439]]}]
},
“properties”: {“name”: “S2 Cell polygons collection”}
}

下列範例會傳回 Null 結果,因為 s2cell 令牌輸入無效。

print s2cellPolygon = geo_s2cell_to_polygon("a")

輸出

s2cellPolygon