isoline_from_raster: Polygon around gridcells with a value larger than or equal to...

View source: R/functions_raster.R

isoline_from_rasterR Documentation

Polygon around gridcells with a value larger than or equal to the specified threshold

Description

Polygon around gridcells with a value larger than or equal to the specified threshold

Usage

isoline_from_raster(grid, alpha)

Arguments

grid

A two-dimensional raster::RasterLayer, terra::SpatRaster, or stars object.

alpha

A numeric value. Threshold value.

Value

A sf polygon

Examples

r <- stars::st_as_stars(
  data.frame(
    x = rep(1:10, times = 10),
    y = rep(10:1, each = 10),
    value = 1:100
  ),
  dims = c("x", "y")
)

ip1 <- isoline_from_raster(r, alpha = 45)
ip2 <- isoline_from_raster(r, alpha = 87)

if (requireNamespace("grDevices")) {
  plot(r, reset = FALSE)
  plot(ip1, col = NA, border = "black", add = TRUE)
  plot(ip2, col = NA, border = "blue", add = TRUE)
  grDevices::dev.off()
}


DrylandEcology/rSW2st documentation built on Jan. 10, 2024, 6:22 p.m.