Save an EE ImageCollection in their local system

ee_imagecollection_to_local(
  ic,
  region,
  dsn = NULL,
  via = "getInfo",
  scale = NULL,
  maxPixels = 1e+09,
  container = "rgee_backup",
  quiet = FALSE,
  ...
)

Arguments

ic

ee$ImageCollection to be saved in the system.

region

EE Geometry Rectangle (ee$Geometry$Rectangle). The CRS needs to be the same that the ic argument otherwise it will be forced.

dsn

Character. Output filename. If missing, ee_imagecollection_to_local will create a temporary file.

via

Character. Method to fetch data about the object. Multiple options supported. See details.

scale

Numeric. The resolution in meters per pixel. Defaults to the native resolution of the image assset.

maxPixels

Numeric. The maximum allowed number of pixels in the exported image. The task will fail if the exported region covers more pixels in the specified projection. Defaults to 100,000,000.

container

Character. Name of the folder ('drive') or bucket ('gcs') to be exported into (ignored if via is not defined as "drive" or "gcs").

quiet

logical. Suppress info message

...

Extra exporting argument. See ee_image_to_drive and ee_image_to_gcs.

Value

Character vector containing the filename of the images downloaded.

Details

ee_imagecollection_to_local supports the download of ee$Image by three different options: "getInfo", "drive", and "gcs". When "getInfo" is set in the via argument, ee_imagecollection_to_local will make an REST call to retrieve all the known information about the object. The advantage of use "getInfo" is a direct and faster download. However, there is a limitation of 262144 pixels by request which makes it not recommendable for large images. Instead of "getInfo", the options: "drive" and "gcs" are suitable for large collections since they use an intermediate container. They use Google Drive and Google Cloud Storage respectively. For getting more information about exporting data from Earth Engine, take a look at the Google Earth Engine Guide - Export data.

See also

Other image download functions: ee_as_raster(), ee_as_stars(), ee_as_thumbnail()

Examples

if (FALSE) {
library(rgee)
library(raster)
ee_Initialize(drive = TRUE, gcs = TRUE)

# USDA example
loc <- ee$Geometry$Point(-99.2222, 46.7816)
collection <- ee$ImageCollection('USDA/NAIP/DOQQ')$
  filterBounds(loc)$
  filterDate('2008-01-01', '2020-01-01')$
  filter(ee$Filter$listContains("system:band_names", "N"))

# From ImageCollection to local directory
ee_crs <- collection$first()$projection()$getInfo()$crs
geometry <- collection$first()$geometry(proj = ee_crs)$bounds()
tmp <- tempdir()

## Using getInfo
ic_getinfo_files <- ee_imagecollection_to_local(
  ic = collection,
  region = geometry,
  scale = 100,
  dsn = tmp,
  via = "getInfo",
  quiet = TRUE
)

## Using drive
ic_drive_files <- ee_imagecollection_to_local(
  ic = collection,
  region = geometry,
  scale = 100,
  dsn = file.path(tmp, "drive_"),
  via = "drive"
)

}