addVarEEimage: Add variable from Google Earth Engine Image

View source: R/addVarEEimage.R

addVarEEimageR Documentation

Add variable from Google Earth Engine Image

Description

Add variable from Google Earth Engine Image

Usage

addVarEEimage(ee_pentads, image, reducer, bands = NULL, unmask = FALSE)

Arguments

ee_pentads

A feature collection with the pentads we want to annotate. We need to upload an sf object with the pentads to GEE.

image

Either a character string with the name of the image we want to use or an GEE image produced with ee$Image(). See GEE catalog.

reducer

A character string specifying the function apply when extracting values for each pentad. It is common to use "mean", "sum" or "count". But there are many other, see 'ee.Reducer' under Client Libraries at https://developers.google.com/earth-engine/apidocs.

bands

Select specific bands from the image. If not specified, pentads will be annotated with all bands (one column for each band).

unmask

GEE masks missing values, which means they are not used for computing means, counts, etc. Sometimes we might want to avoid this behaviour and use 0 instead of NA. If so, set unmask to TRUE.

Value

A dataframe similar to ee_pentads with variables added from the bands selected from collection. Note that following rgee the name of the new variables will be the selected band (bands or else all bands from collection followed by the spatial reducer reducer.

Examples

## Not run: 
# Load the remote data asset
ee_data <- ee$FeatureCollection(assetId)  # assetId must correspond to an asset in your GEE account

# Annotate with surface water occurrence image
pentads_tmmn <- addVarEEimage(ee_pentads = ee_data,
                              image = "JRC/GSW1_3/GlobalSurfaceWater",
                              reducer = "mean",
                              bands = "occurrence")

## End(Not run)

AfricaBirdData/ABAP documentation built on Aug. 4, 2024, 4:41 p.m.