Given a LcpFinder
, returns a matrix that
summarizes all of the LCPs that have been calculated by the
LcpFinder
.
# S4 method for LcpFinder
summarize_lcps(x)
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
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.
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.
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)
#> id xmin xmax ymin ymax value area lcp_cost lcp_dist
#> 1 6364 14500 14750 15750 16000 0.966 62500 8481.750 13471.78
#> 2 6365 14750 15000 15750 16000 0.863 62500 8468.179 13471.78
#> 3 3994 3750 4000 18500 18750 0.780 62500 8223.767 18223.11
#> 4 3992 3750 4000 18750 19000 0.557 62500 8108.320 17889.65
#> 5 3986 3750 4000 19000 19250 0.582 62500 8025.839 17734.64
#> 6 3984 3750 4000 19250 19500 0.626 62500 7980.157 17643.15