binary_layer | R Documentation |
Helper function to make a binary raster layer from input target.
binary_layer(target, fun = "equals", value, layer = 1)
target |
SpatRaster target (see |
fun |
character indicating which function to use to compare layer to value. One of 'equals', 'gt', 'gte', 'lt', 'lte' or 'in'. Default: 'equals'. |
value |
numeric value in target. see Details. |
layer |
default 1, see |
Find all pixels given the function ('fun') matching the value ('value') and return a binary raster.
value' may only be length 1 if 'fun' is one of: 'equals', 'gt', 'gte', 'lt', 'lte'.
'value' may be greater than length 1 only if 'fun' is: 'in'.
A binary raster SpatRaster
(see terra::rast()
) with two values:
TRUE
if pixel matches 'value' provided given the provided function
FALSE
if pixel does not match 'value' provided given the provided function
library(terra)
clearwater_lc_path <- system.file("extdata",
"clearwater_lake_land_cover.tif", package = "camtrapmonitoring")
clearwater_lake_land_cover <- rast(clearwater_lc_path)
bin <- binary_layer(target = clearwater_lake_land_cover,
fun = 'equals', value = 18)
plot(bin)
# fun = 'in'
bin <- binary_layer(target = clearwater_lake_land_cover,
fun = 'in', value = c(1, 2))
plot(bin)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.