create_accum_cost: creates an accumulated cost surface

View source: R/create_accum_cost.R

create_accum_costR Documentation

creates an accumulated cost surface

Description

Creates an accumulated cost surfaces from one or more origins

Usage

create_accum_cost(
  x,
  origins,
  FUN = mean,
  rescale = FALSE,
  check_locations = FALSE
)

Arguments

x

SpatRaster

origins

sf 'POINT' or 'MULTIPOINT', SpatVector, data.frame or matrix containing the origins coordinates. If multiple origins are supplied then the multiple accumulated cost surfaces will be summarised using the FUN argument

FUN

function Apply a function to the cells of a SpatRaster. Default applied function is 'mean'. See terra::app() for more information

rescale

logical. if TRUE, values scaled to between 0 and 1. FALSE (default)

check_locations

logical if TRUE checks if origins are traversable. FALSE (default)

Value

SpatRaster

Author(s)

Joseph Lewis

Examples


r <- terra::rast(system.file("extdata/SICILY_1000m.tif", package="leastcostpath"))

slope_cs <- create_slope_cs(x = r, cost_function = "tobler", neighbours = 4)

locs <- sf::st_sf(geometry = sf::st_sfc(
sf::st_point(c(839769, 4199443)),
sf::st_point(c(1038608, 4100024)),
sf::st_point(c(907695, 4145478)),
crs = terra::crs(r)))

cc <- create_accum_cost(x = slope_cs, origins = locs, FUN = mean, rescale = FALSE)

josephlewis/leastcostpath documentation built on Oct. 18, 2023, 2:03 p.m.