RiverREM is a Python package for automatically generating river relative elevation model (REM) visualizations from nothing but an input digital elevation model (DEM). The package uses the OpenStreetMap API to retrieve river centerline geometries over the DEM extent. Interpolation of river elevations is automatically handled using a sampling scheme based on raster resolution and river sinuosity to create striking high-resolution visualizations without interpolation artefacts straight out of the box and without additional manual steps. The package also contains a helper class for creating DEM raster visualizations. See the documentation pages for more details.
For more information on REMs and this project see this OpenTopography blog post.
clone this repo and create a conda environment from the env_mpc.yml
:
git clone https://github.com/puzhao8/RiverREM
cd RiverREM
conda env create -n riverrem --file env_mpc.yml
In order to handle dependencies such as GDAL and OSMnx, it is highly recommended to install with conda
instead of pip
for ease of use.
-
Get a DEM for the area of interest. Some sources for free topographic data:
-
Create an REM visualization with default arguments:
from riverrem.REMMaker import REMMaker # provide the DEM file path and desired output directory rem_maker = REMMaker(dem='/path/to/dem.tif', out_dir='/out/dir/') # create an REM rem_maker.make_rem() # create an REM visualization with the given colormap rem_maker.make_rem_viz(cmap='mako_r')
-
Scale up for large or global scale DEM to REM applications based on MPC:
# create a Region of Interest (roi) in https://geojson.io/ or other platform, copy and paster coordinates roi = dict(type = "Polygon", coordinates = [...]) # Planetary computer's STAC URL URL = "https://planetarycomputer.microsoft.com/api/stac/v1" catalog = pystac_client.Client.open(URL) # query by geometry items = catalog.search( intersects=roi, collections=["cop-dem-glo-30"] ).item_collection() # get the list of queried tiles ids = [item['id'][:-4] for item in items.to_dict()['features']] print(f"The total number of dem tiles: {len(ids)}") pprint(ids) # loop over each tile, calculate REM, and save for tile_name in ids: # ids: print() print(tile_name) item_url = f"https://planetarycomputer.microsoft.com/api/stac/v1/collections/cop-dem-glo-30/items/{tile_name}_DEM" # Load the individual item metadata and sign the assets item = pystac.Item.from_file(item_url) signed_item = planetary_computer.sign(item) # Open one of the data assets asset_href = signed_item.assets["data"].href # ds = rioxarray.open_rasterio(asset_href) # ds, ds.values # derive REM from DEM, and save it to "./outputs/" folder rem_maker = REMMaker(dem=asset_href, tile_name=tile_name, out_dir='./outputs') rem_maker.make_rem_viz(cmap='Blues', z=8)
Please follow the script "main_mpc_dem_to_rem.py".
Options for adjusting colormaps, shading, interpolation parameters, and more are detailed in the documentation.
- No river in DEM extent or inaccurate centerline: Use the OSM editor to create/modify river centerline(s). Alternatively, a user-provided centerline can be input to override the OSM centerline. See the documentation for more details.
Submitting issues, bugs, or suggested feature improvements are highly encouraged for this repository.
This is the OpenTopography fork of https://github.com/klarrieu/RiverREM by Kenneth Larrieu. This package was made possible and inspired by the following:
- The beautiful REMs popularized by Daniel Coe
- DahnJ's implementation of REMs using xarray
- Geoff Boeing's OSMnx Python package leveraging the OSM Overpass API
- The UNAVCO Student Internship Program
- The team at OpenTopography for supporting this effort under the following U.S. National Science Foundation award numbers: 1948997, 1948994, 1948857.