Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive rivers from DEM rather than OSM #154

Open
Tracked by #227
barneydobson opened this issue May 9, 2024 · 1 comment
Open
Tracked by #227

Derive rivers from DEM rather than OSM #154

barneydobson opened this issue May 9, 2024 · 1 comment
Labels
feature Adding a new functionality, small or large

Comments

@barneydobson
Copy link
Collaborator

barneydobson commented May 9, 2024

The OSM rivers layer seems a bit temperamental - the ones that it has are accurate but it is missing obvious ones. Something like pysheds and presumably pyflwdir enable river creation - this might be more reliable.

Also should be something to handle no rivers present - I guess related to #125 . It also seems that this error is now out of date so the try/except isn't working.

@barneydobson barneydobson added the feature Adding a new functionality, small or large label May 9, 2024
@barneydobson
Copy link
Collaborator Author

barneydobson commented May 30, 2024

Below might be outdated - see also code in #191

Can be done by adding to geospatial_utilities.py/derive_subbasins_streamorder

    streams_feat = flw.streams(min_sto=streamorder)
    gdf_streams = gpd.GeoDataFrame.from_features(streams_feat, crs=grid.crs)
    
    return gdf_bas, gdf_streams

Can be done by adding to graph_utilities.py/clip_to_catchments

        subbasins, streams = go.derive_subbasins_streamorder(addresses.elevation,
                                subcatchment_derivation.subbasin_streamorder)
        
        # Insert rivers
        streams['edge_type'] = 'river'
        streams['id'] = [f'subbasin-river-{ix}' for ix in range(len(streams))]
        streams['length'] = streams['geometry'].length
        streams = streams[['geometry','edge_type','id','length']]
        G.add_edges_from([(u, v, d) for u, v, d in streams.itertuples(index=False)])

Initial check of this is promising - though probably will also need to include the rivers in the SWMM model as the generated rivers can go quite deep into the catchments - maybe this is not so difficult with #84

And a test:

def test_derive_subbasins():
    """Test the derive_subbasins_streamorder function."""
    elevation_fid = Path(__file__).parent / 'test_data' / 'elevation.tif'
    basins, streams = go.derive_subbasins_streamorder(elevation_fid,3)
    assert basins.shape[0] == 5
    assert streams.shape[0] == 6
    assert (streams.strord >= 3).all()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding a new functionality, small or large
Projects
None yet
Development

No branches or pull requests

1 participant