Skip to content

Non-contributing areas and missing river segment in network topology script #37

@kasra-keshavarz

Description

@kasra-keshavarz

Problem statement

Sometimes, geofabrics do not have any river segment for basins that are non-contributing. An example is the coastal hillslope catchments of MERIT-Basins dataset. In this case, the create_network_topology_file.py throws an error and complains about the mismatch in the length of shp_basin and she_river.

Temporary solution

As a temporary solution, I have added the following lines just before creating the topology netcdf file:

# finding basins without a river network - Non-contributing areas
missing_seg = shp_basin[~shp_basin[river_seg_id].isin(shp_river[river_seg_id])]
missing_ids = missing_seg[basin_hru_id]
last_seg_id = shp_river[river_seg_id].astype(int).max()

# assinging fictitious ids to river segements of NCA basins in the `shp_basin`
missing_seg_ids = range(last_seg_id + 1, last_seg_id + len(missing_ids) + 1)
shp_basin.loc[shp_basin[basin_hru_id].isin(missing_ids), river_seg_id] = missing_seg_ids

# creating fictitious ids for river segments of the NCA basins in the `shp_river`
cols = shp_river.columns.to_list()
fict_seg = pd.DataFrame(data=[[0]*len(cols)]*len(missing_ids), columns=cols)
fict_seg[river_seg_id] = missing_seg_ids
shp_river = gpd.GeoDataFrame(pd.concat([shp_river, fict_seg]))

Long-term solution

Something to discuss...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions