The ee_grab() function Request and imports data from Earth Engine according to a user defined data request.

ee_grab(data = NULL, targetArea = NULL, verbose = T)

Arguments

data

list of ee_data_image() or ee_data_collection() functions which define the requested data. Multiple functions are passed inside a list, while a single function can be passed directly.

targetArea

character path to a local geo-file that should be used as a targetArea (.shp, .geojson, .kml). If the file is already uploaded, the upload is skipped.

verbose

logical, whether to inform the user about the processing state of the data. Default is set to True.

Value

Object of class sf. ee_grab() returns the targetArea file with the bands of the requested data added as columns.

Details

To define the data request:

use ee_data_image() and ee_data_collection() to define the data.

use targetArea to define the spatial target, in which the data sould be aggregated.

earthEngineGrabR Workflow

Search for dataset in Earth Engine Data Catalog.

Grab data according to a user defines data reuquest.

Search for data

Use Earth Engine's Data Catalog to browse and find datasets you want to grab using the earthEngineGrabR. Once you have found a dataset, use the snippet section to obtain the dataset ID and whether the dataset is an image or a collection of images. The snippet section consists of one line of code (don't open the link) and shows how Earth Engine loads the dataset. If it is an image, the ee.Image(dataset-ID) constructor is used. if it is a collection the ee.ImageCollection(dataset-id) constructor is used instead.

Grab data

ee_grab() requests and imports data from Earth Engine to R. ee_grab() takes two arguments, data and targetArea. data takes a single or a list of ee_data_image() and ee_data_collection() functions, which define the requested data to ee_grab(). If the requested data is an image use ee_data_image(), if it's a collection use ee_data_collection(). targetAreo takes a path to a local geo-file, which defines the spatial target in which the data sould be aggregated.

Internal processing

The ee_grab() processing runs in 4 steps:

1. Upload - The targetArea is uploaded to Google Drive.

2. Request - The data is requested from Google Earth Engine and exported to Google Drive.

3. Download - The data is downloaded from Drive.

4. Import - The data is imported to R and merged.

Examples

# NOT RUN {
# Request a srtm image data product to get topographic data.
# Grab the spatial mean of the elevation band in the polygons of your targetArea. The calculation are based on a 100 meter scale, which means that the original SRTM data product is resampled to 100 * 100 meter Pixel size.

srtm_data <- ee_grab(data = ee_data_image(datasetID = "CGIAR/SRTM90_V4",
                                         spatialReducer = "mean",
                                         scale = 100,
                                         bandSelection = "elevation"
                                         ),
                   targetArea = system.file("data/territories.shp", package = "earthEngineGrabR")
                   )

# Request a chirps collection data product to get precipitation data.
# Grab the yearly precipitation sum for 2016 and get the spatial mean in the polygons of your targetArea.

chirps_data <- ee_grab(data = ee_data_collection(datasetID = "UCSB-CHG/CHIRPS/DAILY",
                                                spatialReducer = "mean",
                                                temporalReducer = "sum",
                                                timeStart = "2016-01-01",
                                                timeEnd = "2016-12-31",
                                                scale = 200
                                                ),
                      targetArea = system.file("data/territories.shp", package = "earthEngineGrabR")
                     )


# }