Download EE thumbnail images and read them as stars objects. This function is a wrapper around ee$Image()$getThumbURL().

ee_as_thumbnail(x, region, dimensions, vizparams = NULL, crs = 4326,
  quiet = FALSE)

Arguments

x

EE Image object

region

Geospatial region of the image (c(E,S,W,N) numeric vector, EE Geometry, or sfg). By default, the whole image is used.

dimensions

A number or pair of numbers in format XY.

vizparams

A list that contains the visualization parameters.

crs

The EE Image projection e.g. 'EPSG:3857'. Defaults to WGS84 ('EPSG:4326').

quiet

logical; suppress info messages.

Value

An sf object

Details

The argument dimensions will define the "from" & "to" parameters of the stars object to be generated. It must be a single numeric value or a two-element vector. If not defined, 256 is taken by default as the dimension of x (from 1 to 256), and y will be computed by proportional scaling. Huge images might cause plodding connections. See Client vs Server for details.

The vizparams set up the number of bands. In ee_as_thumbnail just is possible export one (G) or three band (RGB) images, additional parameters can be passed on to control color, intensity, the max(min) value, etc. See below for a more compressible list of all the parameters that admit ee_as_thumbnail.

ParameterDescriptionType
bandsComma-delimited list of three band names to be mapped to RGBlist
minValue(s) to map to 0number or list of three numbers, one for each band
maxValue(s) to map to 1number or list of three numbers, one for each band
gainValue(s) by which to multiply each pixel valuenumber or list of three numbers, one for each band
biasValue(s) to add to each DNnumber or list of three numbers, one for each band
gammaGamma correction factor(s)number or list of three numbers, one for each band
paletteList of CSS-style color strings (single-band images only)comma-separated list of hex strings
opacityThe opacity of the layer (0.0 is fully transparent and 1.0 is fully opaque)number

Use ee$Image()$geometry()$projection()$crs()$getInfo() for getting the CRS of an Earth Engine Image.

Examples

library(rgee) library(stars)
#> Loading required package: abind
#> Loading required package: sf
#> Linking to GEOS 3.7.1, GDAL 2.4.0, PROJ 5.2.0
ee_Initialize() nc = st_read(system.file("shp/arequipa.shp", package="rgee"))
#> Reading layer `arequipa' from data source `/tmp/RtmpQd4Uh9/temp_libpath739d4b3f58dc/rgee/shp/arequipa.shp' using driver `ESRI Shapefile' #> Simple feature collection with 1 feature and 2 fields #> geometry type: POLYGON #> dimension: XY #> bbox: xmin: -75.07333 ymin: -17.28501 xmax: -70.80408 ymax: -14.63274 #> epsg (SRID): 4326 #> proj4string: +proj=longlat +datum=WGS84 +no_defs
dem_palette <- c("#008435", "#1CAC17", "#48D00C", "#B3E34B", "#F4E467", "#F4C84E", "#D59F3C", "#A36D2D", "#C6A889", "#FFFFFF") ndvi_palette <- c("#FC8D59", "#FC8D59", "#FC9964", "#FED89C", "#FFFFBF", "#FFFFBF", "#DAEF9F", "#9DD46A", "#91CF60", "#91CF60") # Example 01 - SRTM AREQUIPA-PERU image <- ee$Image("CGIAR/SRTM90_V4") region <- nc$geometry[[1]] arequipa_dem <- ee_as_thumbnail(x = image, region = region, vizparams = list(min = 0, max = 5000))
#> Loading required namespace: stringi
#> Registered S3 method overwritten by 'crul': #> method from #> as.character.form_file httr
#> Registered S3 method overwritten by 'geojsonlint': #> method from #> print.location geojsonio
#> dimensions is missing, 256 is taken by default as dimension of x (from 1 to 256). #> Getting the thumbnail image from Earth Engine ... please wait
arequipa_dem <- arequipa_dem * 5000 plot(arequipa_dem[nc], col = dem_palette, breaks = "equal", reset = FALSE, main = "SRTM - Arequipa")
#> although coordinates are longitude/latitude, st_intersects assumes that they are planar
suppressWarnings(plot(nc, col = NA, border = "black", add = TRUE, lwd = 1.5))