geo_s2cell_neighbors()

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

计算 S2 单元格邻居。

详细了解 S2 单元格层次结构

语法

geo_s2cell_neighbors(s2cell)

详细了解语法约定

参数

客户 类型​​ 必需 说明
s2cell string ✔️ geo_point_to_s2cell() 计算得出的 S2 单元格令牌值。 S2 单元格令牌的最大字符串长度为 16 个字符。

返回

S2 单元格邻居的数组。 如果 S2 单元格无效,则查询会生成 null 结果。

注意

S2 单元格边缘是球体测地线。

示例

以下示例计算 S2 单元格邻居。

print neighbors = geo_s2cell_neighbors('89c259')

输出

neighbors
["89c25d","89c2f9","89c251","89c257","89c25f","89c25b","89c2f7","89c2f5"]

以下示例计算包含其邻居的输入 S2 单元格的数组。

let s2cell = '89c259';
print cells = array_concat(pack_array(s2cell), geo_s2cell_neighbors(s2cell))

输出

单元格
["89c259","89c25d","89c2f9","89c251","89c257","89c25f","89c25b","89c2f7","89c2f5"]

以下示例计算 S2 单元格多边形 GeoJSON 几何图形集合。

let s2cell = '89c259';
print cells = array_concat(pack_array(s2cell), geo_s2cell_neighbors(s2cell))
| mv-expand cells to typeof(string)
| project polygons = geo_s2cell_to_polygon(cells)
| summarize arr = make_list(polygons)
| project geojson = bag_pack("type", "Feature","geometry", bag_pack("type", "GeometryCollection", "geometries", arr), "properties", bag_pack("name", "polygons"))

输出

geojson
{"type": "Feature","geometry": {"type": "GeometryCollection","geometries": [
{"type": "Polygon","coordinates": [[[ -74.030012249838478, 40.8012684339439],[ -74.030012249838478, 40.7222262918358],[ -73.935982114337421, 40.708880489804564],[ -73.935982114337421, 40.787917134506841],[ -74.030012249838478, 40.8012684339439]]]},
{"type": "Polygon","coordinates": [[[ -73.935982114337421, 40.708880489804564],[ -73.935982114337421, 40.629736433321796],[ -73.841906340776248, 40.616308079144915],[ -73.841906340776248, 40.695446474556284],[ -73.935982114337421, 40.708880489804564]]]},
{"type": "Polygon","coordinates": [[[ -74.1239959854733, 40.893471289549765],[ -74.1239959854733, 40.814531536204242],[ -74.030012249838478, 40.8012684339439],[ -74.030012249838478, 40.880202851376716],[ -74.1239959854733, 40.893471289549765]]]},
{"type": "Polygon","coordinates": [[[ -74.1239959854733, 40.735483949993387],[ -74.1239959854733, 40.656328734184143],[ -74.030012249838478, 40.643076628676461],[ -74.030012249838478, 40.7222262918358],[ -74.1239959854733, 40.735483949993387]]]},
{"type": "Polygon","coordinates": [[[ -74.1239959854733, 40.814531536204242],[ -74.1239959854733, 40.735483949993387],[ -74.030012249838478, 40.7222262918358],[ -74.030012249838478, 40.8012684339439],[ -74.1239959854733, 40.814531536204242]]]},
{"type": "Polygon","coordinates": [[[ -73.935982114337421, 40.787917134506841],[ -73.935982114337421, 40.708880489804564],[ -73.841906340776248, 40.695446474556284],[ -73.841906340776248, 40.774477568182071],[ -73.935982114337421, 40.787917134506841]]]},
{"type": "Polygon","coordinates": [[[ -74.030012249838478, 40.7222262918358],[ -74.030012249838478, 40.643076628676461],[ -73.935982114337421, 40.629736433321796],[ -73.935982114337421, 40.708880489804564],[ -74.030012249838478, 40.7222262918358]]]},
{"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.841906340776248, 40.774477568182071],[ -73.841906340776248, 40.853401155678846],[ -73.935982114337421, 40.866846163445771]]]}]},
"properties": {"name": "polygons"}}

以下示例计算表示 S2 单元格及其邻居的多边形联合。

let s2cell = '89c259';
print cells = array_concat(pack_array(s2cell), geo_s2cell_neighbors(s2cell))
| mv-expand cells to typeof(string)
| project polygons = geo_s2cell_to_polygon(cells)
| summarize arr = make_list(polygons)
| project polygon = geo_union_polygons_array(arr)

输出

polygon
{"type": "Polygon","coordinates": [[[-73.841906340776248,40.695446474556284],[-73.841906340776248,40.774477568182071],[-73.841906340776248,40.853401155678846],[-73.935982114337421,40.866846163445771],[-74.030012249838478,40.880202851376716],[-74.1239959854733,40.893471289549758],[-74.1239959854733,40.814531536204242],[-74.1239959854733,40.735483949993387],[-74.1239959854733,40.656328734184143],[-74.030012249838478,40.643076628676461],[-73.935982114337421,40.629736433321796],[-73.841906340776248,40.616308079144915],[-73.841906340776248,40.695446474556284]]]}

以下示例由于 S2 单元格令牌输入无效而返回 true。

print invalid = isnull(geo_s2cell_neighbors('a'))

输出

无效
1