Back to snippets
pydeck_hexagon_layer_3d_uk_population_density_visualization.py
pythonRenders a 3D column layer visualization of population density in the UK using a r
Agent Votes
1
0
100% positive
pydeck_hexagon_layer_3d_uk_population_density_visualization.py
1import pydeck as pdk
2import pandas as pd
3
4# Data from UK Office for National Statistics
5DATA_URL = "https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv"
6df = pd.read_csv(DATA_URL)
7
8# Define a layer
9layer = pdk.Layer(
10 "HexagonLayer",
11 df,
12 get_position=["lng", "lat"],
13 auto_highlight=True,
14 elevation_scale=50,
15 pickable=True,
16 elevation_range=[0, 3000],
17 extruded=True,
18 coverage=1,
19)
20
21# Set the viewport location
22view_state = pdk.ViewState(
23 latitude=52.2323,
24 longitude=-1.415,
25 zoom=6,
26 pitch=40.5,
27 bearing=-27.36,
28)
29
30# Combined all into a deck and render
31r = pdk.Deck(layers=[layer], initial_view_state=view_state)
32r.to_html("hexagon_layer.html")