Learn R Programming

rgee (version 0.1.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

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. 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.

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 DN 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 reserve 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]]
arequipa_dem <- ee_as_thumbnail(x = image, region = region, vizparams = list(min = 0, max = 5000))
arequipa_dem <- arequipa_dem * 5000
plot(arequipa_dem[nc], col = dem_palette, breaks = "equal", reset = FALSE, main = "SRTM - Arequipa")
suppressWarnings(plot(nc, col = NA, border = "black", add = TRUE, lwd = 1.5))
# }

Run the code above in your browser using DataLab