Description Usage Arguments Details Value See Also Examples
View source: R/ee_as_thumbnail.R
Wrapper function around ee$Image$getThumbURL
to create a stars or
RasterLayer R object from a
EE thumbnail image.
1 2 3 4 5 6 7 8 | ee_as_thumbnail(
image,
region,
dimensions,
vizparams = NULL,
raster = FALSE,
quiet = FALSE
)
|
image |
EE Image object to be converted into a stars object. |
region |
EE Geometry Rectangle ( |
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. |
vizparams
set up the details of the thumbnail image. With
ee_as_thumbnail
only is possible 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 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 |
An stars or Raster object depending on the raster
argument.
Other image download functions:
ee_as_raster()
,
ee_as_stars()
,
ee_imagecollection_to_local()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | ## Not run:
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")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.