File size: 939 Bytes
b0cc0f3 40dec40 b0cc0f3 40dec40 b0cc0f3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import duckdb
import pydeck as pdk
con = duckdb.connect('processed_dashboard.db', read_only=True)
con.load_extension('spatial')
def build_and_save(scenario_key):
df = con.sql(f"""
SELECT lat, lon, scenario_{scenario_key}_units AS units
FROM parcels_with_scenarios
WHERE scenario_{scenario_key}_units > 0
LIMIT 20000
""").df()
layer = pdk.Layer(
"ColumnLayer",
data=df,
get_position=["lon", "lat"],
get_elevation="units",
elevation_scale=1,
radius=50,
get_fill_color=[255, 100, 0, 150],
pickable=True
)
view_state = pdk.ViewState(latitude=34.05, longitude=-118.25, zoom=10, pitch=45)
deck = pdk.Deck(layers=[layer], initial_view_state=view_state)
deck.to_html(f"deck_{scenario_key}.html", notebook_display=False)
print(f"Saved deck_{scenario_key}.html")
for s in ["low", "med", "high"]:
build_and_save(s) |