S2 Layer Example¶
Google S2 geometry cells visualization using deck.gl S2Layer.
In [ ]:
Copied!
# %pip install anymap-ts
# %pip install anymap-ts
In [ ]:
Copied!
from anymap_ts import DeckGLMap
from anymap_ts import DeckGLMap
Define S2 cell data¶
In [ ]:
Copied!
# Sample S2 cell tokens (around San Francisco area)
s2_data = [
{"token": "80858c", "value": 100},
{"token": "80858d", "value": 200},
{"token": "80858e", "value": 150},
{"token": "80858f", "value": 300},
{"token": "808590", "value": 250},
{"token": "808591", "value": 180},
{"token": "808594", "value": 220},
{"token": "808595", "value": 270},
]
# Sample S2 cell tokens (around San Francisco area)
s2_data = [
{"token": "80858c", "value": 100},
{"token": "80858d", "value": 200},
{"token": "80858e", "value": 150},
{"token": "80858f", "value": 300},
{"token": "808590", "value": 250},
{"token": "808591", "value": 180},
{"token": "808594", "value": 220},
{"token": "808595", "value": 270},
]
Create map with S2 layer¶
In [ ]:
Copied!
m = DeckGLMap(center=[-122.4, 37.75], zoom=8, pitch=45)
m.add_basemap("CartoDB.DarkMatter")
m.add_s2_layer(
data=s2_data,
get_s2_token="token",
get_fill_color=[51, 136, 255, 180],
get_elevation="value",
extruded=True,
elevation_scale=100,
pickable=True,
)
m
m = DeckGLMap(center=[-122.4, 37.75], zoom=8, pitch=45)
m.add_basemap("CartoDB.DarkMatter")
m.add_s2_layer(
data=s2_data,
get_s2_token="token",
get_fill_color=[51, 136, 255, 180],
get_elevation="value",
extruded=True,
elevation_scale=100,
pickable=True,
)
m
Export to HTML¶
In [ ]:
Copied!
m.to_html("s2_layer_example.html")
m.to_html("s2_layer_example.html")