| 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) |