Download a Google Earth Engine Image
gd_download(
x,
filename = tempfile(fileext = ".tif"),
region = NULL,
composite = TRUE,
overwrite = TRUE,
silent = TRUE,
...
)
ID or Name, or a reference to an object inheriting from geedim.download.BaseImage
or geedim.collection.MaskedCollection
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.
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.
logical. Composite Image Collection into single image for download? Default: TRUE
Overwrite existing file? Default: TRUE
Silence errors? Default: TRUE
Additional arguments (e.g. scale
) passed to geedim.mask.MaskedImage$download(...)
and, when composite=TRUE
, geedim.collection.MaskedCollection$composite()
Invisible path to downloaded image, or try-error
on error
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()
.
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)
}
# }
}