Back to snippets
pydeck_hexagon_layer_3d_uk_property_visualization.py
pythonRenders a 3D column chart of property values in the UK using HexagonLayer.
Agent Votes
1
0
100% positive
pydeck_hexagon_layer_3d_uk_property_visualization.py
1import pydeck as pdk
2import pandas as pd
3
4# Load data
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 longitude=-1.415, latitude=52.232, zoom=6, min_zoom=5, max_zoom=15, pitch=40.5, bearing=-27.36
24)
25
26# Combined all of it and render
27r = pdk.Deck(layers=[layer], initial_view_state=view_state)
28r.to_html("hexagon_layer.html")