RGISTools (version 0.9.7)

modDownload: Search and download MODIS images

Description

modDownload searches and downloads MODIS images concerning a particular location and time interval from the `EarthData' repository. Images are saved as GTiff files in the AppRoot directory.

Usage

modDownload(product, startDate, endDate, username, password, AppRoot,
  collection = 6, nattempts = 5, verbose = FALSE,
  extract.tif = FALSE, ...)

Arguments

product

a character argument with the short name of the MODIS product.

startDate

a Date class object with the starting date of the study period.

endDate

a Date class object with the ending date of the study period.

username

NASA's `EarthData' username.

password

NASA's `EarthData' password.

AppRoot

the directory to save the outcoming time series.

collection

MODIS collection, by default 6.

nattempts

the number of attempts to download an image in case it becomes corrupted.

verbose

logical argument. If TRUE, the function prints running stages and warnings.

extract.tif

logical argument. If TRUE, extracts all the layers from hdf files and saves them as GTiff.

...

arguments for nested functions:

  • lonlat a vector with the longitude/latitude coordinates of the point of interest. This argument is mandatory if polygon or extent are not defined.

  • extent an extent, Raster*, or Spatial* object representing the region of interest with longitude/latitude coordinates. This argument is mandatory if polygon or lonlat are not defined.

  • polygon A list of vectors defining the points of a polygon in longitude/latitude format. This argument is mandatory if lonlat or extent are not defined.

  • Any argument in modExtractHDF function. Ex. bFilter="b01_1".

Details

modDownload uses the NASA<U+2019>s Common Metadata Repository to search and the `EarthData' web service to download the imagery. The catalogue of MODIS products can be found here. The catalogue shows detailed information about the products and their short names. By the time `RGISTools' is released, NASA carries out the maintenance of its website on Wednesdays, which may cause an error when connecting to their server. You can get your `EarthData' credentials here.

Examples

Run this code
# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
src <- paste0(tempdir(),"/Path_for_downloading_folder")
print(src)
modDownload(product = "MOD09GA",
            startDate = as.Date("01-01-2018", "%d-%m-%Y"),
            endDate = as.Date("03-01-2018", "%d-%m-%Y"),
            username = "username",
            password = "password",
            AppRoot = src,
            extract.tif = TRUE,
            collection = 6,
            extent = ex.navarre)
tif.src <- file.path(src,"Modis","MOD09GA","tif")
files <- list.files(tif.src,
                    pattern = "\\.tif$",
                    full.names = TRUE,
                    recursive = TRUE)[c(16,19,18)]
files.stack <- stack(files)
qrange <- c(0.001, 0.999)
imagen <- varRGB(files.stack[[1]], 
                 files.stack[[2]],
                 files.stack[[3]],
                 qrange)
plotRGB(imagen)
# }

Run the code above in your browser using DataCamp Workspace