Learn R Programming

RGISTools (version 0.9.7)

genSmoothingCovIMA: Fill data gaps and smooth outliers in a time series of satellite images using covariates

Description

genSmoothingCovIMA runs the image mean anomaly (IMA) algorithm with covariates militino2018improvingRGISTools.

Usage

genSmoothingCovIMA(rStack, cStack, Img2Process = NULL, nDays = 3,
  nYears = 1, fact = 5, fun = mean, aFilter = c(0.05, 0.95),
  snow.mode = FALSE, out.name = "out", ...)

Arguments

rStack

a RasterStack class argument containing a time series of satellite images. Layer names should contain the date of the image in "YYYYJJJ" format.

cStack

a RasterStack class argument containing a time series of covariates.

Img2Process

a vector class argument defining the images to be filled/smoothed.

nDays

a numeric argument with the number of previous and subsequent days that define the temporal neighborhood.

nYears

a numeric argument with the number of previous and subsequent years that define the temporal neighborhood.

fact

a numeric argument with an aggregation factor of the anomalies carried out before the interpolation.

fun

a function used to aggregate the image of anomalies. Both mean(default) or median are acceptted.

aFilter

a vector with the lower and upper quantiles that define the outliers of the anomalies. Ex. c(0.05,0.95).

snow.mode

logical argument. If TRUE, the filling process will be parallelized using the `raster' package.

out.name

the name of the folder containing the filled/smoothed images when saved in the Hard Disk Drive (HDD).

...

arguments for nested functions:

  • AppRoot the path where the filled/smoothed time series of images are saved in GTiff format.

Value

a RasterStack with the filled/smoothed images.

Details

This filling/smoothing method was developed by militino2018improving;textualRGISTools. This technique decomposes a time series of images into a new series of mean and anomaly images. The procedure applies the filling/smoothing algorithm with covariates over the anomaly images. The procedure requires a proper definition of a temporal neighbourhood for the target image and aggregation factor.

References

militino2018improvingRGISTools

Examples

Run this code
# NOT RUN {
set.seed(0)
# load example ndvi and dem data of Navarre
data(ex.ndvi.navarre)
data(ex.dem.navarre)
# plot example data
genPlotGIS(ex.ndvi.navarre)
genPlotGIS(ex.dem.navarre)

# distorts 5% of the original ndvi data by 
# altering 50% its values
for(x in c(2,5)){
  aux <- sampleRandom(ex.ndvi.navarre[[x]],
                      ncell(ex.ndvi.navarre) * 0.05,
                      cells = TRUE,
                      na.rm = TRUE)
  ex.ndvi.navarre[[x]][aux[,1]] <- aux[,2] * 1.5
}
genPlotGIS(ex.ndvi.navarre)

# smoothing the image using the DEM as covariate
smth.ndvi <- genSmoothingCovIMA(rStack = ex.ndvi.navarre,
                                cStack = ex.dem.navarre,
                                Img2Process = c(2,5))
# plot the distorted 1, smoothed 1, 
# distorted 5, smoothed 5 images
plot(stack(ex.ndvi.navarre[[2]],
                 smth.ndvi[[1]],
                 ex.ndvi.navarre[[5]],
                 smth.ndvi[[2]]))
# }

Run the code above in your browser using DataLab