REM Module
This module can be used to automatically produce aesthetically pleasing visualizations of river relative elevation models (REMs) from an input DEM.
River centerlines used to create REMs are automatically retrieved from the OpenStreetMap (OSM) API. If a desired river segment is not listed on OSM, a new river centerline can be created/edited at: https://www.openstreetmap.org/edit (clear the ./cache folder after using the OSM editor to get the updated centerline).
For very large/high resolution DEMs, interpolation can take a long time. While this module is designed to work well using the default settings on a variety of datasets, interpolation can be sped up by changing the following parameters from default values:
decreasing interp_pts
increasing k
increasing eps
increasing workers (if more CPU threads are available)
- class riverrem.REMMaker.REMMaker(dem, out_dir='./', interp_pts=1000, k=None, eps=0.1, workers=4, cache_dir='./.cache')
Handler to automatically make a river REM from an input DEM.
- Parameters
dem (str) – path to input DEM raster.
out_dir (str) – output file directory. Defaults to current working directory.
interp_pts (int) – maximum number of points to use for interpolation of river centerline elevation. Actual number of points is limited by number of DEM pixels along centerline, so less points may be used for lower resolution DEMs.
k (int) – number of nearest neighbors to use for IDW interpolation. If None, an appropriate value is estimated.
eps (float) – fractional error tolerance for finding nearest neighbors in KD tree query. Higher values allow faster interpolation at the expense of accuracy.
workers (int) – number of CPU threads to use for interpolation. -1 uses all threads.
cache_dir (str) – cache directory
- make_rem()
Make a relative elevation model (REM). Note that this method creates a raw REM raster and doesn’t apply color-relief/shading for visualization.
- Returns
path to output REM raster.
- Return type
str
- make_rem_viz(cmap='mako_r', z=2, blend_percent=25, make_png=True, make_kmz=False, *args, **kwargs)
Create REM visualization by blending the REM color-relief with a DEM hillshade to make a pretty finished product.
- Parameters
cmap (str) – name of matplotlib/seaborn named colormap to use for REM coloring. Note the applied colormap is logarithmically scaled in order to emphasize elevations differences close to the river centerline.
z (float >1) – z factor for exaggerating vertical scale differences of hillshade.
blend_percent (float [0-100]) – Percent weight of hillshdae in blended image, color-relief takes opposite weight.
This method also accepts any arguments for the RasterViz module’s make_hillshade_color method.
- Returns
path to output raster
- Return type
str