modDownSearch: Search and download MODIS images

Description Usage Arguments Details Value Examples

View source: R/modDownSearch.R

Description

modDownSearch 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
modDownSearch(
  product,
  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.

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:

  • dates a vector with the capturing dates being searched. This argument is mandatory if startDate and endDate are not defined.

  • startDate a Date class object with the starting date of the study period. This argument is mandatory if dates is not defined.

  • endDate a Date class object with the ending date of the study period. This argument is mandatory if dates is not defined.

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

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

  • region 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

modDownSearch searches via NASA’s Common Metadata Repository and downloads the imagert from 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.

Value

this function does not return anything. It saves the imagery as 'tar.gz’ (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
26
27
28
## Not run: 
# load a spatial polygon object of Navarre
data(ex.navarre)
wdir <- file.path(tempdir(),"Path_for_downloading_folder")
print(src)
modDownSearch(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 = wdir,
              extract.tif = TRUE,
              collection = 6,
              extent = ex.navarre)
wdir.mod.tif <- file.path(wdir,"Modis","MOD09GA","tif")
files.mod <- list.files(wdir.mod.tif,
                        pattern = "\\.tif$",
                        full.names = TRUE,
                        recursive = TRUE)[c(16,19,18)]
img.mod <- stack(files.mod)
qrange <- c(0.001, 0.999)
img.mod.rgb <- varRGB(img.mod[[1]], 
                      img.mod[[2]],
                      img.mod[[3]],
                      qrange)
plotRGB(img.mod.rgb)

## End(Not run)

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