index_cube.Rd
This function is called by users to calculate a spectral index and extract zonal
statistics for a sf object containing POLYGONS
or MULTIPOLYGONS
. Any ZM
dimensions
of the sf
object are dropped before calculation. Users can specify the timeframe
of the calculation as "seasonal"
. In this way, the calculation for each year
specified in the years
variables is done separately. This allows users to only
cover specific timeframes within several years. If timeframe is "complete"
it is assumed that the complete timeseries of the input files should be covered
by the temporal resolution specified in the dt
variable.
index_cube(
files = NULL,
format = system.file("sentinel2_l2a_cog.json", package = "mapme.vegetation"),
DB_path = NULL,
dx = NULL,
dy = NULL,
dt = NULL,
srs = NULL,
bbox = NULL,
after = NULL,
before = NULL,
timeframe = "full",
aggregation = "median",
resampling = "bilinear",
tmpagg = FALSE,
index = NULL,
bands = NULL,
label = "",
outdir = ".",
overwrite = F,
mask_layer = NULL,
mask_values = NULL,
mask_invert = FALSE,
chunking = c(1, 256, 256),
threads = 1,
...
)
A character vector with the filepaths to the raster files for which gap-filling and a smoothing function shall be applied.
A charachter vector pointing to a json file with a gdalcubes format description of the input files.
A charachter vector where the gdalcubes data base file indexing the spatiotemporal extents of files. Defaults to NULL which means a temporary file is used. Can be pointed to a file ending in ".db" to speed up later iterations.
A numeric specifying the resolution of the output raster in x dimension
expressed in the map unit specified in epsg.
If epsg
is left
empty it defaults to the map unit of aoi.
A numeric specifying the resolution of the output raster in y dimension
expressed in the map unit specified in epsg
.
If epsg
is left empty it defaults to the map unit of aoi
.
Resolution of the time dimension expressed as ISO8601 string
(e.g. "P16D"
for 16 days).
Target spatial reference system as a string; can be a proj4 definition,
WKT, or in the form "EPSG:XXXX" (see cube_view
)
A numeric vector of lenght four indicating the spatial bounding
box of the query (xmin, ymin, xmax, ymax) in geographic coordinates. Defaults
to `NULL` which will set the spatial extent to global, i.e. c(-180, -90, 180, 90)
.
A length one character vector in the form ` the earliest date (inclusive) included in the temporal extent.
A length one character vector in the form ` the latest date (inclusive) included in the temporal extent.
A character of either "seasonal"
or "complete"
specifying
if the calculation should be applied for the complete time series or for
each year independently. Defaults to "complete"
. If "seasonal"
is specified
the years
variables cannot be left empty.
A character vector specifying the aggregation method for
images of the same time stamp. Must be one of "min"
, "max"
,
"mean"
, "median"
, or "first"
. Defaults to "median"
.
A character specifying the resampling method used to transform
images from their native CRS to the output CRS. Can be any of the methods
supported by gdalwarp (see www.gdal.org/programs/gdalwarp.html).
Defaults to "bilinear"
.
A logical indicating if temporal aggregation of all timestemps should
be performed calling reduce_time
. Defaults to FALSE
.
A character specifying the short name of the index to be calculated.
Available indices can be checked with check_indices()
. Defaults
to NULL. When indices are calculated argument bands must be set to NULL.
A character vector specifying the bands to extract. Defaults to NULL. If specified argument index must be set to NULL.
A character label which is appended to the output files in the
form of <label>_<index>_<timestep>
. Files with the same name in
outdir
will be overwritten without warning.
A character specifying an existing directory where output files
will be written to. Defaults to "."
.
A logical indicating if existing files in outdir should be overwritten.
Name of a layer in the data cube used for masking.
An integer vector with mask values. Masking behaviour
is controlled with the mask_invert
argument.
If TRUE the values specified in mask_values
are
considered valid and pixels with these values are kept. If FALSE pixel
with these values are masked out. Default is FALSE.
Vector of length 3 defining the size of data cube chunks in the
order time, y, x. (see raster_cube
)
Number of cores used for parallel processing
additional arguments to write_tif
Nothing. However a GTiff
and a GPKG
with the zonal statistics are written to
outdir
for every resulting timestep.
See cube_view
for more information.