Skip to content

Instantly share code, notes, and snippets.

@cosh
Created June 14, 2021 20:53
Show Gist options
  • Save cosh/acbc84f82441f3d41a2b73e8b26d9ae9 to your computer and use it in GitHub Desktop.
Save cosh/acbc84f82441f3d41a2b73e8b26d9ae9 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"type": "Feature",
"geometry": {
"type": "GeometryCollection",
"geometries": [
{
"type": "Polygon",
"coordinates": [
[
[
-74.03001224983848,
40.880202851376716
],
[
-74.03001224983848,
40.8012684339439
],
[
-73.93598211433742,
40.78791713450684
],
[
-73.93598211433742,
40.86684616344577
],
[
-74.03001224983848,
40.880202851376716
]
]
]
},
{
"type": "Polygon",
"coordinates": [
[
[
-73.93598211433742,
40.86684616344577
],
[
-73.93598211433742,
40.78791713450684
],
[
-73.84190634077625,
40.77447756818207
],
[
-73.84190634077625,
40.853401155678846
],
[
-73.93598211433742,
40.86684616344577
]
]
]
},
{
"type": "Polygon",
"coordinates": [
[
[
-74.03001224983848,
40.8012684339439
],
[
-74.03001224983848,
40.7222262918358
],
[
-73.93598211433742,
40.708880489804564
],
[
-73.93598211433742,
40.78791713450684
],
[
-74.03001224983848,
40.8012684339439
]
]
]
}
]
},
"properties": {
"name": "S2 Cell polygons collection"
}
}
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 pack(
"type", "Feature",
"geometry", pack("type", "GeometryCollection", "geometries", s2_hash_polygon_lst),
"properties", pack("name", "S2 Cell polygons collection"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment