modDownload: Download MODIS images from a search list

Description Usage Arguments Details Value Examples

View source: R/modDownload.R

Description

modDownload downloads the images from a list of uniform resource locators (URLs) generated by the modSearch function from NASA’s ‘EartData’ plataform. The images are saved as GTiff files in the AppRoot directory.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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’s ‘EarthData’ username.

password

NASA’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.

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’s Earth Science Data Systems (ESDS). modDownload requires credentianls from an ‘EarthData’ account to access the NASA’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 “B” and the two-digit band number (e.g., “B01”). Image decompression duplicates the information due to the presence of both, compressed and decompressed images. Set raw.rm = TRUE to remove former ones.

Value

this function does not return anything. It saves the imagery as 'hdf’ (and GTiff files) in a folder called 'raw’ ('tif’) in the AppRoot directory.

Examples

 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
## 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)

## End(Not run)

RGISTools documentation built on July 2, 2020, 3:58 a.m.