ee_imagecollection_to_local: Save an EE ImageCollection in their local system

Description Usage Arguments Details Value See Also Examples

View source: R/ee_imagecollection.R

Description

Save an EE ImageCollection in their local system

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
ee_imagecollection_to_local(
  ic,
  region,
  dsn = NULL,
  via = "drive",
  container = "rgee_backup",
  scale = NULL,
  maxPixels = 1e+09,
  lazy = FALSE,
  public = TRUE,
  add_metadata = TRUE,
  timePrefix = TRUE,
  quiet = FALSE,
  ...
)

Arguments

ic

ee$ImageCollection to be saved in the system.

region

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

dsn

Character. Output filename. If missing, a temporary file will be created for each image.

via

Character. Method to export the image. Two method are implemented: "drive", "gcs". See details.

container

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

scale

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

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.

lazy

Logical. If TRUE, a future::sequential object is created to evaluate the task in the future. See details.

public

Logical. If TRUE, a public link to the image is created.

add_metadata

Add metadata to the stars_proxy object. See details.

timePrefix

Logical. Add current date and time (Sys.time()) as a prefix to files to export. This parameter helps to avoid exported files with the same name. By default TRUE.

quiet

Logical. Suppress info message

...

Extra exporting argument. See ee_image_to_drive and

Details

ee_imagecollection_to_local supports the download of ee$Images by two different options: "drive" (Google Drive) and "gcs" ( Google Cloud Storage). In both cases ee_imagecollection_to_local works as follow:

For getting more information about exporting data from Earth Engine, take a look at the Google Earth Engine Guide - Export data.

Value

If add_metadata is FALSE, a character vector containing the filename of the images downloaded. Otherwise a list adding information related to the exportation (see details).

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## 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
# one by once
ic_drive_files_1 <- ee_imagecollection_to_local(
  ic = collection,
  region = geometry,
  scale = 250,
  dsn = file.path(tmp, "drive_")
)

# all at once
ic_drive_files_2 <- ee_imagecollection_to_local(
  ic = collection,
  region = geometry,
  scale = 250,
  lazy = TRUE,
  dsn = file.path(tmp, "drive_")
)

# From Google Drive to client-side
doqq_dsn <- ic_drive_files_2 %>% ee_utils_future_value()
sapply(doqq_dsn, '[[', 1)

## End(Not run)

csaybar/rgee documentation built on March 11, 2021, 5:48 a.m.