sample_raster: Sample points or patches on a categorical raster layer

View source: R/sample_raster.R

sample_rasterR Documentation

Sample points or patches on a categorical raster layer

Description

The function samples points or patches on a categorical raster layer.

Usage

sample_raster(
  raster,
  class,
  nb_pts,
  dist_min = 0,
  edge_size = 0,
  by_patch = TRUE,
  neighborhood = 8,
  surf_min = 0,
  prop_area = TRUE,
  step_max = 1000,
  output = "df",
  desc = TRUE
)

Arguments

raster

A RasterLayer object corresponding to a categorical raster layer

class

An integer value or vector with the value(s) corresponding to the code values of the raster layer within which points will be sampled.

nb_pts

An integer value indicating the number of points to be sampled

dist_min

An integer value indicating the minimum distance separating the sampled points (default = 0).

edge_size

An integer value indicating the width of the edge of the raster layer which is ignored during the sampling (default = 0). It prevents from sampling in the margins of the study area.

by_patch

A logical value indicating whether contiguous patches with cells having the same code value are delineated prior to sampling (default = TRUE). It prevents from sampling several points in the same contiguous patch.

neighborhood

An integer value indicating which cells are considered adjacent when contiguous patches are delineated (it should be 8 (default, Queen's case) or 4 (Rook's case)). This parameter is ignored when by_patch = FALSE.

surf_min

An integer value indicating the minimum surface of a patch considered for the sampling in number of raster cells. This parameter is used whatever the by_patch argument is. Default is 0.

prop_area

A logical value indicating whether sampling in large patches is more likely (default = TRUE). If by_patch = FALSE, this parameter is ignored. When prop_area = TRUE, the probability to sample a given patch is proportional to its area.

step_max

An integer value indicating how many sampling steps are performed to identify a point set satisfying all the conditions before returning an error.

output

A character string indicating the type of returned output:

  • 'data.frame': A data.frame with three/four columns:

    • ID: The point or patch centroid ID

    • x: The point or patch centroid longitude

    • y: The point or patch centroid latitude

    • area: The area of the sampled patch (only if by_patch = TRUE)

  • 'pts_layer': A SpatialPointsDataFrame layer corresponding to the sampled point (points or patch centroids)

  • 'poly_layer': A SpatialPolygonsDataFrame layer corresponding to the sampled patch polygons

desc

A logical value indicating whether the result should be described or not (default = FALSE). If desc = TRUE, then the Gini coefficient of the distances between points and of the patch areas (if by_patch = TRUE) is computed with the gini_coeff. An histogram of the link weights is also described.

Value

A list of object(s) with one or several elements according to the output and desc arguments.

Author(s)

P. Savary


graph4lg documentation built on Feb. 16, 2023, 5:43 p.m.