rsat_derive: Computes a remote sensing index from an 'rtoi'

rsat_deriveR Documentation

Computes a remote sensing index from an rtoi

Description

Combines the bands from multispectral satellite products through simple math to highlight a process or material in the image.

Usage

rsat_derive(x, variable, ...)

## S4 method for signature 'rtoi,character'
rsat_derive(
  x,
  variable,
  product,
  dates,
  fun,
  overwrite = FALSE,
  verbose = FALSE,
  suppressWarnings = TRUE,
  ...
)

Arguments

x

an rtoi as the source of images.

variable

the name of the variable.

...

additional argument for variable deriving

product

the name of the product from which the index is computed.

dates

a vector of dates being considered (optional).

fun

a function that computes the remote sensing index.

overwrite

logical argument. If TRUE, overwrites the existing images with the same name.

verbose

logical argument. If TRUE, the function prints the running steps and warnings.

suppressWarnings

evaluates its expression in a context that ignores all warnings.

Details

The package contemplates some pre-defined indexes, which can be displayed using the show_variables() function. To compute one of those, write its name in the variable argument. Custom indexes can be supplied through the fun argument. The function should use the name of the bands as inputs (red, green, blue, nir, swir1, or swir2) and return a single element. For instance, the Normalized Difference Snow Index would be;

NDSI = function(green, swir1) ndsi <- (green - swir1)/(green + swir1) return(ndsi)

Value

nothing. The derived variables will be save in the hard drive. Use get_stars to get the variables.

Examples

## Not run: 
library(rsat)

# create a copy of pamplona in temp file
file.copy(from=system.file("ex/Pamplona",package="rsat"),
         to=tempdir(),
         recursive = TRUE)

# load example rtoi
pamplona <- read_rtoi(file.path(tempdir(),"Pamplona"))

rsat_list_data(pamplona)
# show prefedined varibles
show_variables()
rsat_derive(pamplona, "NDVI", product = "mod09ga")
# now NDVI is processed
rsat_list_data(pamplona)

# ad-hoc variable
NDSI = function(green, swir1){
ndsi <- (green - swir1)/(green + swir1)
return(ndsi)
}
rsat_derive(pamplona, "NDSI", product = "mod09ga",fun=NDSI)
# now NDVI is processed
rsat_list_data(pamplona)
plot(pamplona, product="mod09ga",variable="NDSI")

## End(Not run)

rsat documentation built on March 18, 2022, 5:40 p.m.