Download a Google Earth Engine Image

gd_download(
  x,
  filename = tempfile(fileext = ".tif"),
  region = NULL,
  composite = TRUE,
  overwrite = TRUE,
  silent = TRUE,
  ...
)

Arguments

x,

ID or Name, or a reference to an object inheriting from geedim.download.BaseImage or geedim.collection.MaskedCollection

filename

path to output file, defaults to temporary GeoTIFF file path; if composite=FALSE then this path should be to a parent directory. File names will be calculated from the internal name of the image and the requested scale.

region

a GeoJSON-like list, or other R spatial object describing region of interest, see gd_region() and gd_bbox() for details. NULL region (default) will download the whole image.

composite

logical. Composite Image Collection into single image for download? Default: TRUE

overwrite

Overwrite existing file? Default: TRUE

silent

Silence errors? Default: TRUE

...

Additional arguments (e.g. scale) passed to geedim.mask.MaskedImage$download(...) and, when composite=TRUE, geedim.collection.MaskedCollection$composite()

Value

Invisible path to downloaded image, or try-error on error

Details

The region argument is optional for downloading images. When downloading a composite Image Collection, you must specify region, scale and crs arguments. When downloading an image collection as a set of GeoTIFF files (composite=FALSE), then filename is the destination directory, and scale must be specified. The default resampling method in geedim is resampling="near" (Nearest Neighbor). Other options for resampling include: "average", "bicubic", "bilinear". See gd_resampling_methods().

Examples

if (FALSE) { # gd_is_initialized()
# \donttest{
 r <- gd_bbox(
   xmin = -121,
   xmax = -120.5,
   ymin = 38.5,
   ymax = 39
 )

if (gd_is_initialized()) {
 x <- gd_image_from_id('CSP/ERGo/1_0/Global/SRTM_topoDiversity')
 tf <- tempfile(fileext = ".tif")

 # fast sample download at 10x aggregation (900m v.s. 90m)
 img <- gd_download(x, filename = tf,
                    region = r, scale = 900,
                    overwrite = TRUE, silent = FALSE)

 if (requireNamespace("terra")) {
   library(terra)
   f <- rast(img)
   plot(f[[1]])
   # inspect object
   f
 }
 unlink(tf)
}
# }
}