Wrapper function around ee$Image$getThumbURL to create a stars or RasterLayer R object from a EE thumbnail image.

ee_as_thumbnail(
image,
region,
dimensions,
vizparams = NULL,
raster = FALSE,
quiet = FALSE
)

## Arguments

image

EE Image object to be converted into a stars object.

region

EE Geometry Rectangle (ee$Geometry$Rectangle) specifying the region to export.The CRS needs to be the same as the x argument. Otherwise, it will be forced.

dimensions

Numeric vector of length 2. Thumbnail dimensions in pixel units. If a single integer is provided, it defines the size of the image's larger aspect dimension and scales the smaller dimension proportionally. Defaults to 512 pixels for the larger image aspect dimension.

vizparams

A list that contains the visualization parameters. See details.

raster

Logical. Should the thumbnail image be saved as a RasterStack object?

quiet

logical; suppress info messages.

## Value

An stars or Raster object depending on the raster argument.

## Details

vizparams set up the details of the thumbnail image. With ee_as_thumbnail only is possible to export one-band (G) or three-band (RGB) images. Several parameters can be passed on to control color, intensity, the maximum and minimum values, etc. The table below provides all the parameters that admit ee_as_thumbnail.

 Parameter Description Type bands Comma-delimited list of three band (RGB) list min Value(s) to map to 0 number or list of three numbers, one for each band max Value(s) to map to 1 number or list of three numbers, one for each band gain Value(s) by which to multiply each pixel value number or list of three numbers, one for each band bias Value(s) to add to each Digital Number value number or list of three numbers, one for each band gamma Gamma correction factor(s) number or list of three numbers, one for each band palette List of CSS-style color strings (single-band only) comma-separated list of hex strings opacity The opacity of the layer (from 0 to 1) number

Other image download functions: ee_as_raster(), ee_as_stars(), ee_imagecollection_to_local()

## Examples

if (FALSE) {
library(raster)
library(stars)
library(rgee)

ee_Initialize()

nc <- st_read(system.file("shp/arequipa.shp", package = "rgee"))
dem_palette <- c(
"#008435", "#1CAC17", "#48D00C", "#B3E34B", "#F4E467",
"#F4C84E", "#D59F3C", "#A36D2D", "#C6A889", "#FFFFFF"
)

## DEM data -SRTM v4.0
image <- ee$Image("CGIAR/SRTM90_V4") world_region <- ee$Geometry$Rectangle( coords = c(-180,-60,180,60), proj = "EPSG:4326", geodesic = FALSE ) ## world - elevation world_dem <- ee_as_thumbnail( image = image, region = world_region, dimensions = 1024, vizparams = list(min = 0, max = 5000) ) world_dem[world_dem <= 0] <- NA world_dem <- world_dem * 5000 plot( x = world_dem, col = dem_palette, breaks = "equal", reset = FALSE, main = "SRTM - World" ) ## Arequipa-Peru arequipa_region <- nc %>% st_bbox() %>% st_as_sfc() %>% sf_as_ee() arequipa_dem <- ee_as_thumbnail( image = image, region = arequipa_region$buffer(1000)$bounds(), dimensions = 512, vizparams = list(min = 0, max = 5000) ) arequipa_dem <- arequipa_dem * 5000 st_crs(arequipa_dem) <- 4326 plot( x = arequipa_dem[nc], col = dem_palette, breaks = "equal", reset = FALSE, main = "SRTM - Arequipa" ) suppressWarnings(plot( x = nc, col = NA, border = "black", add = TRUE, lwd = 1.5 )) dev.off() ## LANDSAT 8 img <- ee$Image("LANDSAT/LC08/C01/T1_SR/LC08_038029_20180810")$select(c("B4", "B3", "B2")) Map$centerObject(img)
Map$addLayer(img, list(min = 0, max = 5000, gamma = 1.5)) ## Teton Wilderness l8_img <- ee_as_thumbnail( image = img, region = img$geometry()\$bounds(),
dimensions = 1024,
vizparams = list(min = 0, max = 5000, gamma = 1.5),
raster = TRUE
)
crs(l8_img) <- "+proj=longlat +datum=WGS84 +no_defs"
plotRGB(l8_img, stretch = "lin")
}