Skip to content

Commit cf80d56

Browse files
committed
Merge branch 'kaitak-ags3-tutorial-bed-17' into dev
2 parents d77065d + e1a2685 commit cf80d56

File tree

3 files changed

+311
-6
lines changed

3 files changed

+311
-6
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# /// script
2+
# requires-python = ">=3.12"
3+
# dependencies = [
4+
# "folium==0.19.5",
5+
# "mapclassify==2.8.1",
6+
# "matplotlib==3.9.4",
7+
# "pandas==2.2.3",
8+
# "shapely==2.0.7",
9+
# ]
10+
# ///
11+
12+
import marimo
13+
14+
__generated_with = "0.13.2"
15+
app = marimo.App(width="medium")
16+
17+
18+
@app.cell(hide_code=True)
19+
def _():
20+
from pathlib import Path
21+
22+
import geopandas as gpd
23+
import marimo as mo
24+
import pandas as pd
25+
import pyogrio
26+
from shapely import Point
27+
28+
return Path, Point, gpd, mo, pd, pyogrio
29+
30+
31+
@app.cell
32+
def _(Path):
33+
gpkg_path = Path(
34+
r"S:\Shared drives\Bedrock\Case Studies\A2TunnelMaastricht\data\A2_Maastricht.gpkg"
35+
)
36+
return (gpkg_path,)
37+
38+
39+
@app.cell(hide_code=True)
40+
def _(gpd, gpkg_path, pyogrio):
41+
gpkg_layers = gpd.list_layers(gpkg_path)
42+
43+
brgi_geodb = {}
44+
for layer in gpkg_layers["name"]:
45+
brgi_geodb[layer] = pyogrio.read_dataframe(gpkg_path, layer=layer)
46+
47+
gpkg_layers
48+
return (brgi_geodb,)
49+
50+
51+
@app.cell(hide_code=True)
52+
def _(brgi_geodb, mo):
53+
sel_brgi_table = mo.ui.dropdown(brgi_geodb, value="Project")
54+
mo.md(f"Select the Bedrock GI table you want to explore: {sel_brgi_table}")
55+
return (sel_brgi_table,)
56+
57+
58+
@app.cell(hide_code=True)
59+
def _(pd, sel_brgi_table):
60+
df = pd.DataFrame(sel_brgi_table.value.copy())
61+
if "geometry" in df.columns:
62+
df = df.assign(geometry=df.geometry.astype(str))
63+
64+
df
65+
return
66+
67+
68+
@app.cell(hide_code=True)
69+
def _(Point, sel_brgi_table):
70+
if "geometry" in sel_brgi_table.value.columns:
71+
gdf = sel_brgi_table.value.copy()
72+
gdf = gdf["geometry"].apply(lambda geom: Point(geom.coords[0]))
73+
map = gdf.explore()
74+
else:
75+
map = f"The {sel_brgi_table.selected_key} table doesn't contain GIS geometry."
76+
77+
map
78+
return
79+
80+
81+
if __name__ == "__main__":
82+
app.run()

0 commit comments

Comments
 (0)