getLandsat_data downloads Landsat data queried using getLandsat_query from different sources.

getLandsat_data(records, level = "sr", source = "auto", dir_out = NULL,
  espa_order = NULL, force = FALSE, username = NULL, password = NULL,
  verbose = TRUE)

Arguments

records

data.frame, one or multiple records (each represented by one row), as it is returned by getLandsat_query.

level

character, the requested product level. Defaul is "sr" for surface reflectance. Available levels can be obtained from the "levels_available" field returned for each product by getLandsat_query.

source

character, either:

  • "auto" for automatic selection of data source depending on level

  • "ESPA" to download on-demand products from USGS-EROS ESPA

  • "AWS" to download from Amazon Webservices (Landsat-8 with level="l1" only)

dir_out

character, full path to download target directory. Optional. If not set, getLandsat_data uses the directory to the getSpatialData archive folder. Use set_archive to once define a getSpatialData archive folder.

espa_order

character, optional. A vector of a single or multiple ESPA order IDs. Use this argument, if you want to download items being part of an order that already had been placed by this function or yourself earlier, e.g. in case you arboted the function while it was waiting for the order to be completed. The ESPA order ID is displayed when the order is placed and you recieve it via E-Mail from USGS-EROS. If defined, records is allowed to be undefined.

force

logical. If TRUE, download is forced even if file already exisits in the download directory. Default is FALSE.

username

character, a valid user name to the USGS EROS Registration System (ERS). If NULL (default), the session-wide login credentials are used (see login_USGS for details on registration).

password

character, the password to the specified user account. If NULL (default) and no seesion-wide password is defined, it is asked interactively ((see login_USGS for details on registration).

verbose

logical, if TRUE, details on the function's progress will be visibile on the console. Default is TRUE.

Value

Character vector of paths to the downloaded files.

Note

ESPA is used as source if higher-level products are requested by the user (see level). Since ESPA is an on-demand service, getLandsat_data places an order and then waits for the requested items to be available, before they are downloaded. Therefore, the runtime of the function is depending on how fast an order is being processed by the ESPA server. The ESPA processing time depends on the size of the order and can take up to 48 hours in highly demanding cases! The function status is indicated by the console messages that it is prompting during execution.

See also

Examples

## Load packages library(getSpatialData) library(sf)
#> Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 4.9.3
## set aoi and time range for the query set_aoi(aoi_data[[1]]) time_range <- c("2017-08-01", "2017-08-30") ## Login to USGS ERS
# NOT RUN { login_USGS("username") ## set archive directory set_archive("/path/to/archive/") ## get available products and select one product_names <- getLandsat_names() ## query for records for your AOI, time range and product query <- getLandsat_query(time_range = time_range, name = product_names[7]) ## preview a record getLandsat_preview(query[5,]) #print available levels for a record query[5,]$levels_available ## download record 5 with level "l1" (will direct to AWS automaticaly) files <- getLandsat_data(records = query[5,], level = "l1", source = "auto") ## download record 5 with level "sr" (will be processed on demand by ESPA) files <- getLandsat_data(records = query[5,], level = "sr", source = "auto") # this can take very long, since the function will wait, # until the processing by ESPA is done ## you can abort the function while it is waiting for ESPA and resume later: files <- getLandsat_data(espa_order = "espa-XYZA@host.com-YOUR-ORDER-ID") # the order IDs are displayed and send by mail, use them to resume the task # }