rsat_derive {rsat} | R 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 |
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 |
overwrite |
logical argument. If |
verbose |
logical argument. If |
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)