summarize_lcps: Get a matrix summarizing all LCPs found by a 'LcpFinder'

summarize_lcpsR Documentation

Get a matrix summarizing all LCPs found by a LcpFinder

Description

Given a LcpFinder, returns a matrix that summarizes all of the LCPs that have been calculated by the LcpFinder.

Usage

## S4 method for signature 'LcpFinder'
summarize_lcps(x)

Arguments

x

a LcpFinder

Details

Note that this function returns all of the paths that have been calculated. Finding one LCP likely involves finding other LCPs as well. Thus, even if the LcpFinder has been used to find one LCP, others have most likely been calculated. This function returns all of the LCPs that have been calculated so far.

Value

Returns a nine-column matrix with one row for each LCP (and therefore one row per destination cell). The columns are as follows:

  • id: the ID of the destination cell

  • xmin, xmax, ymin, ymax: the extent of the destination cell

  • value: the value of the destination cell

  • area: the area of the destination cell

  • lcp_cost: the cumulative cost of the LCP to this cell

  • lcp_dist: the cumulative distance of the LCP to this cell - note that this is not straight-line distance, but instead the distance along the path

See Also

lcp_finder() creates the LcpFinder object used as input to this function. find_lcp() returns the LCP between the start point and another point. find_lcps() calculates all LCPs whose cost-distance is less than some value.

Examples

library(quadtree)
habitat <- terra::rast(system.file("extdata", "habitat.tif", package="quadtree"))

qt <- quadtree(habitat, split_threshold = .1, adj_type = "expand")

start_pt <- c(19000, 25000)
end_pt <- c(33015, 38162)

# find LCP from 'start_pt' to 'end_pt'
lcpf <- lcp_finder(qt, start_pt)
lcp <- find_lcp(lcpf, end_pt)

# retrieve ALL the paths that have been calculated
paths <- summarize_lcps(lcpf)
head(paths)

quadtree documentation built on Aug. 29, 2023, 5:11 p.m.