ee_imagecollection_to_local {rgee} | R Documentation |
Save an EE ImageCollection to the local system.
Description
Save an EE ImageCollection to the local system.
Usage
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 to the system. |
region |
EE Geometry (ee$Geometry$Polygon). The
CRS needs to be the same that the |
dsn |
Character. Output filename. If missing, a temporary file will be created for each image. |
via |
Character. Method to export the image. Two methods are available: "drive", "gcs". See details. |
container |
Character. Name of the folder ('drive') or bucket ('gcs')
to be exported into (ignored if |
scale |
Numeric. The resolution in meters per pixel. Defaults to the native resolution of the image. |
maxPixels |
Numeric. The maximum allowable number of pixels in the exported image. If the exported region covers more pixels than the specified limit in the given projection, the task will fail. Defaults to 100,000,000. |
lazy |
Logical. If TRUE, a |
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 ( |
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
using two different options: "drive"
(Google Drive) and "gcs"
(
Google Cloud Storage). In both cases, ee_imagecollection_to_local
works as follow:
1. A task is initiate (i.e.,
ee$batch$Task$start()
) to transfer theee$Image
from Earth Engine to the intermediate container specified in the argumentvia
.2. If the argument
lazy
is TRUE, the task will not be monitored. This is useful to lunch several tasks simultaneously and calls them later usingee_utils_future_value
orfuture::value
. At the end of this step, theee$Images
are stored on the path specified in the argumentdsn
.3. Finally, if the
add_metadata
argument is set to TRUE, a list containing the following elements will be appended to thedsn
argument.if via is "drive":
ee_id: Name of the Earth Engine task.
drive_name: Name of the Image in Google Drive.
drive_id: Id of the Image in Google Drive.
drive_download_link: Download link to the image.
if via is "gcs":
ee_id: Name of the Earth Engine task.
gcs_name: Name of the Image in Google Cloud Storage.
gcs_bucket: Name of the bucket.
gcs_fileFormat: Format of the image.
gcs_public_link: Download link to the image.
gcs_URI: gs:// link to the image.
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, ee_imagecollection_to_local
will
return a character vector containing the filename of the images downloaded.
Otherwise, if add_metadata is TRUE, will return a list with extra information
related to the exportation (see details).
See Also
Other image download functions:
ee_as_raster()
,
ee_as_rast()
,
ee_as_stars()
,
ee_as_thumbnail()
Examples
## 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)