# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
wdir <- file.path(tempdir(),"Path_for_downloading_folder")
print(wdir)
# search and download the images from Landsat-8 between
# 2011 and 2013 in the region of Navarre
sres <- ls8Search(startDate = as.Date("01-01-2018", "%d-%m-%Y"),
endDate = as.Date("20-01-2018", "%d-%m-%Y"),
extent = ex.navarre,
browseAvaliable = "Y",
AppRoot = wdir)
# download 1 image
lsDownload(searchres = sres[1,],
username = "username",
password = "password",
AppRoot = wdir,
untar = TRUE)
# download 4 images
lsDownload(searchres = sres[1:4,],
username = "username",
password = "password",
AppRoot = wdir,
untar = TRUE)
# download all the images
lsDownload(searchres = sres,
username = "username",
password = "password",
AppRoot = wdir,
untar = TRUE)
# search and download the images from Landsat-7 between
# 2011 and 2013 in the region of Navarre
wdir <- file.path(tempdir(),"Path_for_downloading_folder")
print(wdir)
sres <- ls7Search(startDate = as.Date("01-01-2018", "%d-%m-%Y"),
endDate = as.Date("20-01-2018", "%d-%m-%Y"),
extent = ex.navarre,
browseAvaliable = "Y",
AppRoot = wdir)
# download 1 image
lsDownload(searchres = sres[1,],
username = "username",
password = "password",
untar = TRUE,
AppRoot = wdir)
# download 4 images
lsDownload(searchres = sres[1:4,],
username = "username",
password = "password",
untar = TRUE,
AppRoot = wdir)
# download all the images
lsDownload(searchres = sres,
username = "username",
password = "password",
untar = TRUE,
AppRoot = wdir)
# removes the metadata to free memory space
lsRemoveMetadata()
# select Landsat-7 RGB bands
wdir.ls7 <- file.path(wdir,"Landsat7")
files.ls7 <- list.files(wdir.ls7,
pattern = "\\.TIF$",
full.names = TRUE,
recursive = TRUE)[c(6,5,4)]
files.ls7.rgb <- stack(files.ls7)
qrange <- c(0.001, 0.999)
img.ls7.rgb <- varRGB(files.ls7.rgb[[1]],
files.ls7.rgb[[2]],
files.ls7.rgb[[3]],
qrange)
plotRGB(img.ls7.rgb)
# }
Run the code above in your browser using DataLab