Res1D - export to shapefile

Export res1d results to shapefiles.

Export to GeoDataFrame

from mikeio1d import Res1D
res = Res1D("../data/network.res1d")
gdf = res.network.to_geopandas()
gdf.plot()

res = Res1D("../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 = Res1D("../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)
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]:
    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")