Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

extract_lsm

extract_lsm


Description

Extract metrics

Usage

extract_lsm(
  landscape,
  y,
  extract_id,
  metric,
  name,
  type,
  what,
  directions,
  progress,
  verbose,
  ...
)

## S3 method for class 'RasterLayer'
extract_lsm(
  landscape,
  y,
  extract_id = NULL,
  metric = NULL,
  name = NULL,
  type = NULL,
  what = NULL,
  directions = 8,
  progress = FALSE,
  verbose = TRUE,
  ...
)

## S3 method for class 'RasterStack'
extract_lsm(
  landscape,
  y,
  extract_id = NULL,
  metric = NULL,
  name = NULL,
  type = NULL,
  what = NULL,
  directions = 8,
  progress = FALSE,
  verbose = TRUE,
  ...
)

## S3 method for class 'RasterBrick'
extract_lsm(
  landscape,
  y,
  extract_id = NULL,
  metric = NULL,
  name = NULL,
  type = NULL,
  what = NULL,
  directions = 8,
  progress = FALSE,
  verbose = TRUE,
  ...
)

## S3 method for class 'stars'
extract_lsm(
  landscape,
  y,
  extract_id = NULL,
  metric = NULL,
  name = NULL,
  type = NULL,
  what = NULL,
  directions = 8,
  progress = FALSE,
  verbose = TRUE,
  ...
)

## S3 method for class 'list'
extract_lsm(
  landscape,
  y,
  extract_id = NULL,
  metric = NULL,
  name = NULL,
  type = NULL,
  what = NULL,
  directions = 8,
  progress = FALSE,
  verbose = TRUE,
  ...
)

Arguments

landscape

Raster* Layer, Stack, Brick, SpatRaster (terra), stars, or a list of rasterLayers.

y

2-column matrix with coordinates, SpatialPoints, SpatialLines or sf point geometries.

extract_id

Vector with id of sample points. If not provided, sample points will be labelled 1...n.

metric

Abbreviation of metrics (e.g. 'area').

name

Full name of metrics (e.g. 'core area')

type

Type according to FRAGSTATS grouping (e.g. 'aggregation metrics').

what

Selected level of metrics: either "patch", "class" or "landscape". It is also possible to specify functions as a vector of strings, e.g. what = c("lsm_c_ca", "lsm_l_ta").

directions

The number of directions in which patches should be connected: 4 (rook's case) or 8 (queen's case).

progress

Print progress report.

verbose

Print warning messages.

...

Arguments passed to calculate_lsm().

Details

This functions extracts the metrics of all patches the spatial object(s) y (e.g. spatial points) are located within. Only patch level metrics are possible to extract. Please be aware that the output is sligthly different to all other lsm-function of landscapemetrics. Returns a tibble with chosen metrics and the ID of the spatial objects.

Value

tibble

See Also

Examples

points <- matrix(c(10, 5, 25, 15, 5, 25), ncol = 2, byrow = TRUE)
extract_lsm(landscape, y = points)
extract_lsm(landscape, y = points, type = "aggregation metric")

points_sp <- sp::SpatialPoints(points)
extract_lsm(landscape, y = points_sp, what = "lsm_p_area")

## Not run: 
# use lines (works only if rgeos is installed)
x1 <- c(1, 5, 15, 10)
y1 <- c(1, 5, 15, 25)

x2 <- c(10, 25)
y2 <- c(5, 5)

sample_lines <- sp::SpatialLines(list(sp::Lines(list(sp::Line(cbind(x1, y1)),
sp::Line(cbind(x2, y2))), ID = "a")))
extract_lsm(landscape, y = sample_lines, what = "lsm_p_area")

## End(Not run)

landscapemetrics

Landscape Metrics for Categorical Map Patterns

v1.5.2
GPL-3
Authors
Maximillian H.K. Hesselbarth [aut, cre] (<https://orcid.org/0000-0003-1125-9918>), Marco Sciaini [aut] (<https://orcid.org/0000-0002-3042-5435>), Jakub Nowosad [aut] (<https://orcid.org/0000-0002-1057-3721>), Sebastian Hanss [aut] (<https://orcid.org/0000-0002-3990-4897>), Laura J. Graham [ctb] (Input on package structure), Jeffrey Hollister [ctb] (Input on package structure), Kimberly A. With [ctb] (Input on package structure), Florian Privé [ctb] (Original author of underlying C++ code for get_nearestneighbour() function), Project Nayuki [ctb] (Original author of underlying C++ code for get_circumscribingcircle and lsm_p_circle), Matt Strimas-Mackey [ctb] (Bugfix in sample_metrics())
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.