Description Usage Arguments Details Value Examples
View source: R/ls7FolderToVar.R
ls7FolderToVar computes a remote sensing index from the
spectral bands of a time series of Landsat-7 images. The images are specified
by the path to the folder that stores the imagery (resulting from the
lsMosaic function). The function returns a RasterStack
with the time series of images of the remote sensing index.
1 2 3 4 5 6 7 8 9 | ls7FolderToVar(
src,
fun,
AppRoot,
getStack = FALSE,
overwrite = FALSE,
verbose = FALSE,
...
)
|
src |
the path to the folder with the Landsat-7 multispectral imagery. |
fun |
a |
AppRoot |
the directory of the outcoming time series. |
getStack |
logical argument. If |
overwrite |
logical argument. If |
verbose |
logical argument. If |
... |
arguments for nested functions.
|
The function requires the definition of the src and fun
arguments. The src is usually the path resulting from
lsMosaic. The fun argument can be any function from this
package beginning with “var” (varNDVI, varEVI,
etc.). Custom functions can also be implemented. Caution! It is mandatory to
use level-2 products to get accurate derived variables.
this function does not return anything, unless getStack = TRUE
which then returns a RasterStack with the time series of with the
index.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | ## Not run:
# load a spatial polygon object of Navarre
data(ex.navarre)
# main output directory
wdir <- file.path(tempdir(),"Path_for_downloading_folder")
print(wdir)
# download Landsat-7 images
lsDownSearch(satellite = "ls7",
username = "username",
password = "password",
startDate = as.Date("01-01-2018", "%d-%m-%Y"),
endDate = as.Date("20-01-2018", "%d-%m-%Y"),
extent = ex.navarre,
untar = TRUE,
AppRoot = wdir)
# folder with the Landsat-7 untared images
wdir.ls7 <-file.path(wdir,"Landsat7")
wdir.ls7.untar <- file.path(wdir.ls7, "untar")
# mosaic the Landsat-7 images
lsMosaic(wdir.ls7.untar,
AppRoot = wdir.ls7,
out.name = "Navarre",
extent = ex.navarre,
gutils = TRUE)
# folder with the mosaicked images
wdir.ls7.navarre <- file.path(wdir.ls7, "Navarre")
# generate NDVI images of Navarre
wdir.ls7.var <- file.path(wdir.ls7, "Navarre_Variables")
dir.create(wdir.ls7.var)
ls7FolderToVar(wdir.ls7.navarre,
fun = varNDVI,
AppRoot = wdir.ls7.var,
overwrite = TRUE)
files.ls7.ndvi <- list.files(file.path(wdir.ls7.var,"NDVI"),
pattern = "\\.tif$",
full.names = TRUE,
recursive = TRUE)
img.ls7.ndvi <- raster(files.ls7.ndvi[1])
spplot(img.ls7.ndvi)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.