import mikeio1dRes1D - export to shapefile
Export res1d results to shapefiles.
Export to GeoDataFrame
res = mikeio1d.open("../data/network.res1d")
gdf = res.network.to_geopandas()
gdf.plot()
res = mikeio1d.open("../data/network.res1d")
gdf = res.network.to_geopandas()
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
df_reaches = res.reaches.to_geopandas(agg='max')
df_reaches.plot(column='max_Discharge', cmap="RdYlGn_r", legend=True)
df_nodes = res.nodes.to_geopandas(agg='max')
ax = df_reaches.plot(color="gray", zorder=-1)
df_nodes.plot(ax=ax, column='max_WaterLevel', legend=True)
res = mikeio1d.open("../data/catchments.res1d")
df_catchments = res.catchments.to_geopandas('max')
df_catchments.plot(column='max_TotalRunOff', cmap='Blues', legend=True, alpha=0.75)
Interactive maps
map = df_reaches.explore(column="max_Discharge", legend=True, tiles="cartodb positron", tooltip=["name", "max_Discharge"], popup=True)
mapMake 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]:
df.columns = [col[:10] for col in df.columns]
df_reaches.to_file("reaches.shp")
df_nodes.to_file("nodes.shp")
df_catchments.to_file("catchments.shp")from pathlib import Path
files_to_delete = []
for p in ("results.html", "reaches*", "nodes*", "catchments*"):
files_to_delete = [*files_to_delete, *Path.glob(Path.cwd(), p)]
for f in files_to_delete:
f.unlink()