RGISTools (version 1.0.2)

modDownload: Download MODIS images from a search list

Description

modDownload downloads the images from a list of uniform resource locators (URLs) generated by the modSearch function from NASA<U+2019>s `EartData' plataform. The images are saved as GTiff files in the AppRoot directory.

Usage

modDownload(
  searchres,
  AppRoot,
  username = NULL,
  password = NULL,
  nattempts = 5,
  verbose = FALSE,
  extract.tif = FALSE,
  overwrite = FALSE,
  raw.rm = FALSE,
  ...
)

Arguments

searchres

the output from the modSearch function.

AppRoot

the directory where the images will be saved.

username

NASA<U+2019>s `EarthData' username.

password

NASA<U+2019>s `EarthData' password.

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.

overwrite

logical argument. If TRUE, overwrites the existing images with the same name.

raw.rm

logical argument. If TRUE, removes the raw images.

...

argument for nested functions:

  • dates a vector with the capturing dates being considered for downloading.

  • bFilter a vector with the bands to be extracted when extract.tif=TRUE. If not supplied, all bands are extracted.

Value

this function does not return anything. It saves the imagery as `hdf<U+2019> (and GTiff files) in a folder called `raw<U+2019> (`tif<U+2019>) in the AppRoot directory.

Details

modDownload is able to download MODIS Terra and Aqua products. These products are published in the `EarthData' Platform. The platform is supported by the Earth Observing System Data and Information System (EODIS) and managed NASA<U+2019>s Earth Science Data Systems (ESDS). modDownload requires credentianls from an `EarthData' account to access the NASA<U+2019>s web data service, which can be obtained here.

When extract.tif = TRUE, the function decompresses the imagery. If only a subset of bands is required, band names can be provided through the bFilter argument. The band names are specified by <U+201C>B<U+201D> and the two-digit band number (e.g., <U+201C>B01<U+201D>). Image decompression duplicates the information due to the presence of both, compressed and decompressed images. Set raw.rm = TRUE to remove former ones.

Examples

Run this code
# NOT RUN {
# load a spatial polygon object of Navarre
data(ex.navarre)
sres <- modSearch(product = "MYD13A2",
                  startDate = as.Date("01-01-2011", "%d-%m-%Y"),
                  endDate = as.Date("31-12-2013", "%d-%m-%Y"),
                  collection = 6,
                  extent = ex.navarre)
head(sres)
# download the first image in sres
wdir <- file.path(tempdir(),"Path_for_downloading_folder")
print(wdir)
wdir.mod <- file.path(wdir,"Modis","MYD13A2")
wdir.mod.hdf <- file.path(wdir.mod,"hdf")
modDownload(mList[1], 
            username = "username", 
            password = "password",
            AppRoot = wdir.mod.hdf)
# download all images in mList
modDownload(sres, 
            username = "username", 
            password = "password",
            AppRoot = wdir.mod.hdf)
# }

Run the code above in your browser using DataCamp Workspace