hydroweight: Generate inverse distance-weighted rasters

View source: R/hydroweight.R

hydroweightR Documentation

Generate inverse distance-weighted rasters

Description

hydroweight::hydroweight() generates distance-weighted rasters for targets on a digital elevation model raster. Examples of targets include single points, areas such as lakes, or linear features such as streams. The function outputs a list of length(weighting_scheme) and an accompanying *.rds file of distance-weighted rasters for targets (target_O is a point/area target as in iFLO and target_S is a stream/waterbody target as in iFLS in Peterson et al. 2011 https://doi:10.1111/j.1365-2427.2010.02507.x). IMPORTANTLY, this function acts on a single set of targets but can produce multiple weights. The distance-weighted rasters, can be used for generating distance-weighted landscape statistics using hydroweight::hydroweight_attributes() (e.g., % urban cover weighted by flow distance to a point). See https://github.com/bkielstr/hydroweight for workflows.

Usage

hydroweight(
  hydroweight_dir = NULL,
  target_O = NULL,
  target_S = NULL,
  target_uid = NULL,
  OS_combine = NULL,
  clip_region = NULL,
  dem = NULL,
  flow_accum = NULL,
  weighting_scheme = NULL,
  inv_function = function(x) {     (x * 0.001 + 1)^-1 }
)

Arguments

hydroweight_dir

character. File path for read/write.

target_O

sf, RasterLayer, or character (with extension, e.g., "target.shp") of file found in hydroweight_dir of ESRI Shapefile type or GeoTiFF type only. Target for iEucO or iFLO.

target_S

sf, RasterLayer, or character (with extension, e.g., "target.shp") of file found in hydroweight_dir of ESRI Shapefile type or GeoTiFF type only. Target for iEucS or iFLS.

target_uid

character. Unique identifier to precede exported list *.rds (i.e., "target_uid"_inv_distances.rds)

OS_combine

logical. Should target_O and target_S be merged as targets for iEucS, iFLS, and/or HAiFLS? Use TRUE or FALSE. This allows cells surrounding target_O to flow directly into target_O rather than be forced through target_S.

clip_region

numeric, sf, RasterLayer, or character (with extension, e.g., "clip_region.shp") of file found in hydroweight_dir of ESRI Shapefile type or GeoTiFF type only. Region over which distances are calculated. If numeric, sf::sf_buffer() produces a default buffer of crs-specific numeric width around target_O, exports, then clips using whitebox; if sf, exports and clips using whitebox; and if character, loads the file, converts to sf, exports, and clips using whitebox.

dem

character (with extension, e.g., "dem.tif") of file found in hydroweight_dir of GeoTiFF type. Digital elevation model raster.

flow_accum

character (with extension, e.g., "flow_accum.tif") of file found in hydroweight_dir of GeoTiFF type. Flow accumulation raster (units: # of cells).

weighting_scheme

character. One or more weighting schemes: c("lumped", "iEucO", "iEucS", "iFLO", "iFLS", "HAiFLO", "HAiFLS")

inv_function

function. Inverse function used in raster::calc() to convert distances to inverse distances. Default: (X * 0.001 + 1)^-1 assumes projection is in distance units of m and converts to distance units of km.

Details

Spatial layers should align (i.e., identical coordinate reference systems - CRS). Through processing, targets are converted to the resolution and CRS of the digital elevation model/flow accumulation CRS. TEMP-* files are generated in hydroweight_dir depending on processing step and can be overwritten.

For weighting_scheme:

"lumped" indicates all weights = 1

"iEucO" indicates Euclidean distance to target_O

"iEucS" indicates Euclidean distance to target_S

"iFLO" indicates d8 flow-path distance to target_O

"iFLS" indicates d8 flow-path distance to target_S

"HAiFLO" indicates d8 hydrologically-active (proportional to flow accumulation) flow-path distance to target_O

"HAiFLS" indicates d8 hydrologically-active (proportional to flow accumulation) flow-path distance to target_S

Value

A named list of distance-weighted rasters and accompanying *.rds in hydroweight_dir


bkielstr/hydroweight documentation built on April 14, 2025, 6:03 p.m.