hf_appraise: Travel cost between points

View source: R/hf_appraise.R

hf_appraiseR Documentation

Travel cost between points

Description

Estimate the cost of traveling the "shortest" or least-cost path between multiple start and end points. For each from-point, the cost of traveling the shortest path to every to-point is calculated.

Usage

hf_appraise(x, from, to)

Arguments

x

a cost terrain generated by hf_terrain().

from

an sf specifying start locations, must be POINT or MULTIPOINT.

to

an sf specifying end locations, must be POINT or MULTIPOINT.

Value

a data.frame with three columns: from, to, and cost. Values in the from- and to-columns are 1:nrow(from) and 1:nrow(to), respectively.

Examples

library(sf)
library(terra)

fn <- system.file("extdata/red_butte_dem.tif", package = "hiker")
red_butte_dem <- rast(fn)

from <- st_sf(geometry = st_sfc(st_point(c(432000, 4514000)),
                                crs = 26912))

to <- st_sf(geometry = st_sfc(st_point(c(431000, 4515000)),
                              st_point(c(436500, 4518500)),
                              crs = 26912))

terrain <- hf_terrain(red_butte_dem)

hf_appraise(terrain, from, to)


kbvernon/hiker documentation built on Dec. 9, 2022, 11:16 p.m.