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")
}
Run the code above in your browser using DataLab