from mikeio1d import Res1D
Res1D - export to shapefile
Export res1d results to shapefiles.
Export to GeoDataFrame
= Res1D("../data/network.res1d")
res = res.network.to_geopandas()
gdf gdf.plot()
= Res1D("../data/network.res1d")
res = res.network.to_geopandas()
gdf gdf.head()
group | name | geometry | tag | |
---|---|---|---|---|
0 | Node | 1 | POINT (-687934.6 -1056500.699) | NaN |
1 | Node | 2 | POINT (-687914.8 -1056556.399) | NaN |
2 | Node | 3 | POINT (-687907.899 -1056507) | NaN |
3 | Node | 4 | POINT (-687918.199 -1056576.199) | NaN |
4 | Node | 5 | POINT (-687835.5 -1056565.2) | NaN |
Plotting results
= res.reaches.to_geopandas(agg='max')
df_reaches ='max_Discharge', cmap="RdYlGn_r", legend=True) df_reaches.plot(column
= res.nodes.to_geopandas(agg='max')
df_nodes = df_reaches.plot(color="gray", zorder=-1)
ax =ax, column='max_WaterLevel', legend=True) df_nodes.plot(ax
= Res1D("../data/catchments.res1d")
res = res.catchments.to_geopandas('max')
df_catchments ='max_TotalRunOff', cmap='Blues', legend=True, alpha=0.75) df_catchments.plot(column
Interactive maps
map = df_reaches.explore(column="max_Discharge", legend=True, tiles="cartodb positron", tooltip=["name", "max_Discharge"], popup=True)
map
Make this Notebook Trusted to load map: File -> Trust Notebook
# save a distributable html map
map.save("results.html")
Export to shapefile
for df in [df_reaches, df_nodes, df_catchments]:
= [col[:10] for col in df.columns]
df.columns
"reaches.shp")
df_reaches.to_file("nodes.shp")
df_nodes.to_file("catchments.shp") df_catchments.to_file(
from pathlib import Path
= []
files_to_delete for p in ("results.html", "reaches*", "nodes*", "catchments*"):
= [*files_to_delete, *Path.glob(Path.cwd(), p)]
files_to_delete
for f in files_to_delete:
f.unlink()