geo_s2cell_to_polygon()
Applies to: ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Calculates the polygon that represents the S2 Cell rectangular area.
Read more about S2 Cells.
Syntax
geo_s2cell_to_polygon(
s2cell)
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
s2cell | string |
✔️ | S2 cell token value as it was calculated by geo_point_to_s2cell(). The S2 cell token maximum string length is 16 characters. |
Returns
Polygon in GeoJSON Format and of a dynamic data type. If the s2cell is invalid, the query produces a null result.
Note
S2 Cell edges are spherical geodesics.
Examples
print s2cellPolygon = geo_s2cell_to_polygon("89c259")
Output
s2cellPolygon |
---|
{ "type": "Polygon", "coordinates": [[[-74.030012249838478, 40.8012684339439], [-74.030012249838478, 40.7222262918358], [-73.935982114337421, 40.708880489804564], [-73.935982114337421, 40.787917134506841], [-74.030012249838478, 40.8012684339439]]] } |
The following example assembles GeoJSON geometry collection of S2 Cell polygons.
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"))
Output
Column1 |
---|
{ "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.841906340776248, 40.774477568182071], [-73.841906340776248, 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"} } |
The following example returns a null result because of the invalid s2cell token input.
print s2cellPolygon = geo_s2cell_to_polygon("a")
Output
s2cellPolygon |
---|