EEcollectionToMultiband: Convert a GEE collection to multiband image

View source: R/EEcollectionToMultiband.R

EEcollectionToMultibandR Documentation

Convert a GEE collection to multiband image

Description

Convert a GEE collection to multiband image

Usage

EEcollectionToMultiband(
  collection,
  dates,
  band,
  group_type,
  groups,
  reducer = NULL,
  unmask = FALSE
)

Arguments

collection

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

dates

A character vector with two elements c(start, end). Format must be "yyyy-mm-dd".

band

Select a specific band from the collection. Only one band from the collection can be processed at a time.

group_type

The type of grouping we want to perform. This has to be a temporal grouping, either: 'day', 'week', 'month', or 'year'.

groups

An integer vector with values for the group. e.g. 2008:2019 will group data into years from 2008 to 2019.

reducer

The summarizing function applied to each group. If reducer is NULL, then the collection is transformed into a multiband image without applying any reduction (each image goes to a 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

This function transforms an image collection made of a number of images, each representing a variable at different times (e.g. NDVI measures in different months) into a multiband image. Each band in the new image represent a different time. The advantage of a multiband image over an image collection is that we can annotate data with all the bands of an image on a single function call, saving time and data traffic between our machine and GEE servers.

Examples

## Not run: 
# Create a multi-band image with mean NDVI for each year
multiband <- EEcollectionToMultiband(collection = "MODIS/006/MOD13A2",
                                     dates = c("2008-01-01", "2020-01-01"),
                                     band = "NDVI",                       # You can find what bands are available from GEE catalog
                                     group_type = "year",
                                     groups = 2008:2019,
                                     reducer = "mean",
                                     unmask = FALSE)

Find mean (mean) NDVI for each pentad and year
ee_data <- ee$FeatureCollection(assetId)  # assetId must correspond to an asset in your GEE account
pentads_ndvi <- addVarEEimage(ee_data, multiband, "mean")


## End(Not run)

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