Learn R Programming

rgee (version 0.2.0)

ee_as_thumbnail: Create a stars object based on an EE thumbnail image

Description

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

Usage

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

Arguments

x

EE Image object

region

EE Geometry Rectangle (ee$Geometry$Rectangle)

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'. WGS84 by default ('EPSG:4326').

quiet

logical; suppress info messages.

Value

An sf object

Details

The argument dimensions will define the stars object parameters "from" & "to". 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 scales down proportionally. Huge images might cause plodding connections. See Client vs Server for more details.

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

Parameter Description Type
bands Comma-delimited list of three band names to be mapped to 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 (DN) 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 images only) comma-separated list of hex strings
opacity The 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

Run this code
# NOT RUN {
library(rgee)
library(stars)

ee_reattach() # reattach ee as a reserved word
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"
)
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]] %>%
  st_bbox() %>%
  st_as_sfc() %>%
  st_set_crs(4326) %>%
  sf_as_ee()

arequipa_dem <- ee_as_thumbnail(x = image, region = region,
                                vizparams = list(min = 0, max = 5000))
arequipa_dem <- arequipa_dem * 5000

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))
# }

Run the code above in your browser using DataLab