Learn R Programming

spatialEco (version 2.0-1)

sieve: Sieve raster data

Description

Removes contiguous cells < specified query area

Usage

sieve(x, a, unit = c("m", "km", "ha"))

Value

A terra SpatRaster with < a set to NA

Arguments

x

An integer terra SpatRaster

a

Query area to remove

unit

The unit to use for area query options are c("m", "km", "ha")

Examples

Run this code
# \donttest{
library(terra)
elev <- rast(system.file("extdata/elev.tif", package="spatialEco"))
m <- matrix(c(100,200,1,200,300,2,300,400,3,400,
       500,4, 500,600,5), ncol=3, byrow=TRUE)
  x <- classify(elev, m)

# Sieve to a MMU of 60km
sv <- spatialEco::sieve(x, a = 60, unit = "km")
  plot(c(x, sv))
# } 

Run the code above in your browser using DataLab