sample_lsm: sample_lsm

Description Usage Arguments Details Value See Also Examples

View source: R/sample_lsm.R

Description

Sample metrics

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
sample_lsm(landscape, y, shape, size, return_raster, verbose, progress,
  ...)

## S3 method for class 'RasterLayer'
sample_lsm(landscape, y, shape = "square", size,
  return_raster = FALSE, verbose = TRUE, progress = FALSE, ...)

## S3 method for class 'RasterStack'
sample_lsm(landscape, y, shape = "square", size,
  return_raster = FALSE, verbose = TRUE, progress = FALSE, ...)

## S3 method for class 'RasterBrick'
sample_lsm(landscape, y, shape = "square", size,
  return_raster = FALSE, verbose = TRUE, progress = FALSE, ...)

## S3 method for class 'stars'
sample_lsm(landscape, y, shape = "square", size,
  return_raster = FALSE, verbose = TRUE, progress = FALSE, ...)

## S3 method for class 'list'
sample_lsm(landscape, y, shape = "square", size,
  return_raster = FALSE, verbose = TRUE, progress = FALSE, ...)

Arguments

landscape

Raster* Layer, Stack, Brick or a list of rasterLayers.

y

2-column matrix with coordinates, SpatialPoints, SpatialLines or SpatialPolygons.

shape

String specifying plot shape. Either "circle" or "square"

size

Approximated size of sample plot. Equals the radius for circles or half of the side-length for squares in mapunits. For lines size equals the width of the buffer.

return_raster

Logical if the clipped raster of the sample plot should be returned

verbose

Print warning messages.

progress

Print progress report.

...

Arguments passed on to calculate_lsm().

Details

This function samples the selected metrics in a buffer area (sample plot) around sample points, sample lines or within provided SpatialPolygons. The size of the actual sampled landscape can be different to the provided size due to two reasons. Firstly, because clipping raster cells using a circle or a sample plot not directly at a cell center lead to inaccuracies. Secondly, sample plots can exceed the landscape boundary. Therefore, we report the actual clipped sample plot area relative in relation to the theoretical, maximum sample plot area e.g. a sample plot only half within the landscape will have a percentage_inside = 50. Please be aware that the output is sligthly different to all other lsm-function of landscapemetrics.

The metrics can be specified by the arguments what, level, metric, name and/or type (combinations of different arguments are possible (e.g. level = "class", type = "aggregation metric"). If an argument is not provided, automatically all possibilities are selected. Therefore, to get all available metrics, don't specify any of the above arguments.

Value

tibble

See Also

list_lsm
calculate_lsm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# use a matrix
sample_points <- matrix(c(10, 5, 25, 15, 5, 25), ncol = 2, byrow = TRUE)
sample_lsm(landscape, y = sample_points, size = 15, what = "lsm_l_np")

# use sp points
points_sp <- sp::SpatialPoints(sample_points)
sample_lsm(landscape, y = points_sp, size = 15, what = "lsm_l_np", return_raster = TRUE)

## 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")))
sample_lsm(landscape, y = sample_lines, size = 10, what = "lsm_l_np")

# use polygons
poly_1 <-  sp::Polygon(cbind(c(2.5, 2.5, 17.5, 17.5),
                           c(-2.5, 12.5, 12.5, -2.5)))
poly_2 <-  sp::Polygon(cbind(c(7.5, 7.5, 23.5, 23.5),
                           c(-7.5, 23.5, 23.5, -7.5)))
poly_1 <- sp::Polygons(list(poly_1), "p1")
poly_2 <- sp::Polygons(list(poly_2), "p2")
sample_plots <- sp::SpatialPolygons(list(poly_1, poly_2))

sample_lsm(landscape, y = sample_plots, what = "lsm_l_np")

## End(Not run)

r-spatialecology/landscapemetrics documentation built on April 30, 2019, 6:01 a.m.