lcp_graph_surface: Construct a graph for least-cost paths analysis of movement...

View source: R/lcps.R

lcp_graph_surfaceR Documentation

Construct a graph for least-cost paths analysis of movement from a point on a Raster*

Description

This function constructs a graph for least-cost paths analysis. This function is specifically designed for situations in which the aim is to calculate least-cost distances between points on a raster.

Usage

lcp_graph_surface(surface, cost, verbose = TRUE)

Arguments

surface

A raster for which to construct the graph. There are some constraints on the form of this raster if the costs of movement between cells are derived from lcp_costs (see below).

cost

A sparse dsCMatrix-class matrix that defines the cost of movement between connected cells on the surface (see lcp_costs).

verbose

A logical function that defines whether or not to print messages to the console to relay function progress.

Details

This is a wrapper for the makegraph function.

Value

The function returns a named list that defines the graph (see makegraph)

Author(s)

Edward Lavender

Examples

#### Step (1): Define cost surface
# We will consider the distances between connected cells in the example
# ... 'dat_gebco' raster as a measure of cost. For this, we will focus on a
# ... specific area (for speed), within which we need to
# ... we need to regularise the resolution:
boundaries <- raster::extent(707884.6, 709884.6, 6253404, 6255404)
blank <- raster::raster(boundaries, res = c(5, 5))
r <- raster::resample(dat_gebco, blank)
# Define costs
costs <- lcp_costs(r)

#### Step (2): Make graph for LCP analysis
graph <- lcp_graph_surface(surface = r, cost = costs$dist_total)

#### Step (3): Implement LCP analysis around point on Raster*
# ... e.g., via lcp_from_point()


edwardlavender/flapper documentation built on Jan. 22, 2025, 2:44 p.m.