From 9200b04733c48d34b97792f1426a0de7a1d9944c Mon Sep 17 00:00:00 2001 From: Stefan Kuethe Date: Thu, 25 Jul 2024 19:10:39 +0200 Subject: [PATCH] Add example using pydeck.Layer --- _experimental/add_pydeck_layer.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 _experimental/add_pydeck_layer.py diff --git a/_experimental/add_pydeck_layer.py b/_experimental/add_pydeck_layer.py new file mode 100644 index 00000000..4d48e1a2 --- /dev/null +++ b/_experimental/add_pydeck_layer.py @@ -0,0 +1,29 @@ +import json + +import pandas as pd +from maplibre import Map, MapOptions +from pydeck import Layer as PyDeckLayer + +UK_ACCIDENTS_DATA = ( + "https://raw.githubusercontent.com/uber-common/" + "deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv" +) + +df = pd.read_csv(UK_ACCIDENTS_DATA) + +layer = PyDeckLayer( + "HexagonLayer", + df, + # UK_ACCIDENTS_DATA, + get_position=["lng", "lat"], + auto_highlight=True, + elevation_scale=50, + pickable=True, + elevation_range=[0, 3000], + extruded=True, + coverage=1, +) + +m = Map(MapOptions(center=(1.415, 52.2323), zoom=6)) +m.add_deck_layers([json.loads(layer.to_json())]) +m.save("/tmp/py-maplibre-express.html")