-
Notifications
You must be signed in to change notification settings - Fork 1
4.4 indicator.R
Technically it is a wrapper for the gdal_calc taking care of running it in parallel and some data preparation steps.
Used to compute indicators which can be expressed (and effectively computed) using a single numpy expression.
Many indicators can be computed at once.
A standard set of configFilePath
, regionName
, startDate
and endDate
.
Reads data from the rawDir
and stores results into the rawDir
.
Output file names use input bands date and the output band name as specified in the indicator bandName
configuration parameter, e.g. for the configuration as the one at the bottom of this page and available input bands:
2018-04-12_B04_{tile}.tif
2018-04-12_B08_{tile}.tif
2018-04-12_CLOUDMASK_{tile}.tif
2018-04-17_B04_{tile}.tif
2018-04-17_B08_{tile}.tif
2018-04-17_CLOUDMASK_{tile}.tif
two output files will be created for every tile (2 input date * 1 indicator per date
):
2018-04-12_NDVI_{tile}.tif
2018-04-17_NDVI_{tile}.tif
Depending on the equation
complexity (see the configuration section below) the performance bottleneck may be either storage speed (simple equations) or CPU (complex ones).
-
indicatorSkipExisting
should already existing output images be skipped (TRUE
) or reprocessed anyway (FALSE
). -
indicatorIndicators
configuration property being a list of indicators to be computed. Each indicator is described by:-
bandName
output indicator (band) name, e.g.NDVI
. -
resolution
output data resolution. If some input rasters are in a different resolution, they will be automatically resampled. -
mask
name of a band to be used as a valid pixels mask. -
factor
output data scalling factor. Output data are saved using the 2B integer type (values ranging from -32768 to 32767). Thefactor
parameter allows to rescale values coming from theequation
computations into this range, e.g. for NDVI10000
is a goodfactor
. -
bands
list of input bands/indicators. Should be a named vector with every band/indicator denoted by a single capital letter, e.g.c('A' = 'B04', 'B' = 'B08')
. -
equation
a numpy equation computing the indicator. Remember that:- If input data are integers you may need to cast the to floats to avoid strange results (e.g. getting only value of 0 while computing an NDVI), e.g.
(A.astype(float) - B) / (+ A + B)
. - Make sure you will never divide by zero. Add a neglectably small constant when needed, e.g.
'(A.astype(float) - B) / (0.0000001 + A + B)
.
- If input data are integers you may need to cast the to floats to avoid strange results (e.g. getting only value of 0 while computing an NDVI), e.g.
-
A complete configuration for computing an NDVI (at a 10 m resolution and using a mask named CLOUDMASK
) looks as follows:
indicatorSkipExisting = TRUE
indicatorIndicators = list(
list(bandName = 'NDVI', resolution = 10, mask = 'CLOUDMASK', factor = 10000, bands = c('A' = 'B04', 'B' = 'B08'), equation = '(A.astype(float) - B) / (0.0000001 + A + B)')
)