# NOT RUN {
library(rgee)
library(raster)
ee_reattach()
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"
)
# }
Run the code above in your browser using DataLab