Download agricultural, environmental, or satellite data for a region and time of interest.
Usage
download(x, ...)
# S4 method for Quickstats
download(x, variable, ringname = NULL)
# S4 method for Cropmaps
download(x, variable = NULL)
# S4 method for Daymet
download(x, variable = NULL)
# S4 method for Satellite
download(x, ringname = NULL)
Arguments
- x
S4 object. The product of interest.
- ...
extra arguments.
- variable
character. The variable of interest.
- ringname
character. A keyring to handle the provider credentials.
Value
For most products, nothing is returned. The data are saved directly in the cronus database. For lightweight data (such as variables of the Quickstats product), the downloaded data are returned.
Details
Currently, the function can download:
The Quickstats product of NASS.
The Cropland Data Layer variable of NASS.
The Daymet product of ORNL.
The MOD09GA and MYD09GA products of MODIS.
The Landsat TM, ETM and 8 products.
The Sentinel-2 MSI and Sentinel-3 Synergy products.
Details concerning the Quickstats product:
The function is a wrapper of the nassqs()
function from the rnassqs
package. In order to download the data, an API key is required; information
can be found in the rnassqs
package vignette.
Details concerning the Daymet product:
The S4 class Daymet
can be used to handle data of the daymet product. It is
a wrapper of the get_daymet()
function from the FedData
package.
Details concerning the satellite sector:
This function uses the rsat::rsat_search()
function to search for available
products in the requested dates. Then, it recursively calls
rsat::rsat_download()
and rsat::rsat_mosaic()
to download and mosaic the
data, before deleting the original hdf files to save disk space. The
satellite data are extracted in GeoTiff format (zipped).
The recursive call of the function has a slight performance impact, but it is
crucial in order to download data over large regions and periods of time.
For example, assume we want to download the MOD09GA product for the state of
Nebraska for one day. The (3) hdf files required combined surpass 250MB of
memory space, while the mosaiced, zipped Geotiff images take about 15MB.
Examples
if (FALSE) {
# Define required variables
region <- Region(name = "nebraska", type = "us state",
div = c(country = "United States", state = "Nebraska"))
date <- date_seq("2002-01-01", "2002-12-31")
## Quickstats Progress
# Create the object
x <- new("Quickstats", region = region, date = date)
# Download the data
data <- download(x, "progress", ringname)
class(data)
class(data[["Corn"]])
head(data$Corn)
# Plot the data
plot(data, crops = "Winter Wheat", year = 2021)
## Cropmaps CDL
# Create the object
x <- new("Cropmaps", region = region, date = date)
# Download the data
download(x, "cdl")
## Daymet
# Create the object
x <- new("Daymet", region = region, date = date)
# Download the data
download(x, c("tmin", "tmax"))
## MOD09GA
# Create the object
x <- new("Mod09ga", region = region, date = date)
# Download the data
download(x, ringname)
}