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 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)
}
Run the code above in your browser using DataLab