Apply a named expression to a sits cube or a sits tibble
to be evaluated and generate new bands (indices). In the case of sits
cubes, it materializes a new band in output_dir
using
gdalcubes
.
sits_apply(data, ...)# S3 method for sits
sits_apply(data, ...)
# S3 method for raster_cube
sits_apply(
data,
...,
window_size = 3,
memsize = 1,
multicores = 2,
output_dir = getwd(),
progress = TRUE
)
A sits tibble or a sits cube with new bands, produced according to the requested expression.
Valid sits tibble or cube
Named expressions to be evaluated (see details).
An even number representing the size of the sliding window of sits kernel functions used in expressions (for a list of supported kernel functions, please see details).
Memory available for classification (in GB).
Number of cores to be used for classification.
Directory where files will be saved.
Show progress bar?
w_median()
: returns the median of the neighborhood's values.
w_sum()
: returns the sum of the neighborhood's values.
w_mean()
: returns the mean of the neighborhood's values.
w_sd()
: returns the standard deviation of the neighborhood's
values.
w_var()
: returns the variance of the neighborhood's values.
w_min()
: returns the minimum of the neighborhood's values.
w_max()
: returns the maximum of the neighborhood's values.
Rolf Simoes, rolf.simoes@inpe.br
Felipe Carvalho, felipe.carvalho@inpe.br
Gilberto Camara, gilberto.camara@inpe.br
sits_apply()
allow any valid R expression to compute new bands.
Use R syntax to pass an expression to this function.
Besides arithmetic operators, you can use virtually any R function
that can be applied to elements of a matrix (functions that are
unaware of matrix sizes, e.g. sqrt()
, sin()
,
log()
).
Also, sits_apply()
accepts a predefined set of kernel functions
(see below) that can be applied to pixels considering its
neighborhood. sits_apply()
considers a neighborhood of a
pixel as a set of pixels equidistant to it (including itself)
according the Chebyshev distance. This neighborhood form a
square window (also known as kernel) around the central pixel
(Moore neighborhood). Users can set the window_size
parameter to adjust the size of the kernel window.
The image is conceptually mirrored at the edges so that neighborhood
including a pixel outside the image is equivalent to take the
'mirrored' pixel inside the edge.
sits_apply()
applies a function to the kernel and its result
is assigned to a corresponding central pixel on a new matrix.
The kernel slides throughout the input image and this process
generates an entire new matrix, which is returned as a new band
to the cube. The kernel functions ignores any NA
values
inside the kernel window. Central pixel is NA
just only
all pixels in the window are NA
.
Kernel functions
# Get a time series
# Apply a normalization function
point2 <-
sits_select(point_mt_6bands, "NDVI") %>%
sits_apply(NDVI_norm = (NDVI - min(NDVI)) / (max(NDVI) - min(NDVI)))
Run the code above in your browser using DataLab