gd_download {rgeedim} | R Documentation |
Download a Google Earth Engine Image
Description
Download a Google Earth Engine Image
Usage
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 |
filename |
path to output file, defaults to temporary GeoTIFF file path; if |
region |
a GeoJSON-like list, or other R spatial object describing region of interest, see |
composite |
logical. Composite Image Collection into single image for download? Default: |
overwrite |
Overwrite existing file? Default: |
silent |
Silence errors? Default: |
... |
Additional arguments (e.g. |
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()
.
Value
Invisible path to downloaded image, or try-error
on error
See Also
gd_region()
gd_bbox()
Examples
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)
}