Learn R Programming

rgee (version 1.0.5)

ee_imagecollection_to_local: Save an EE ImageCollection in their local system

Description

Save an EE ImageCollection in their local system

Usage

ee_imagecollection_to_local(
  ic,
  region,
  dsn = NULL,
  via = "drive",
  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 two different options: "drive" that use Google Drive and "gcs" that use Google Cloud Storage. Previously, it is necessary to install the R packages googledrive or googleCloudStorageR 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

Run this code
# NOT RUN {
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 drive
ic_drive_files <- ee_imagecollection_to_local(
  ic = collection,
  region = geometry,
  scale = 100,
  dsn = file.path(tmp, "drive_")
)

# }

Run the code above in your browser using DataLab