Loading packages

I this article, I show how to visualize a DEM image in rgee. We start by loading libraries and initializing.

## ── rgee 1.1.6.9999 ────────────────────────────────── earthengine-api 0.1.348 ── 
##  ✔ user: not_defined 
##  ✔ Initializing Google Earth Engine:
 ✔ Initializing Google Earth Engine:  DONE!
## 
 ✔ Earth Engine account: users/wyclifeoluoch 
## ────────────────────────────────────────────────────────────────────────────────

Loading srtm

srtm <- ee$Image("USGS/SRTMGL1_003")

Load area of interest

## Reading layer `SUB_DIS' from data source `D:\R\rgee_pub\data\SUB_DIS.shp' using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 1 field
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: 34.57953 ymin: 1.705011 xmax: 36.22028 ymax: 3.651917
## Geodetic CRS:  WGS 84

Clip srtm to aoi

srtm_clipped <- srtm$clip(aoi)

Display the clipped srtm and zoom to aoi

Map$centerObject(eeObject = aoi, zoom = 8)
## NOTE: Center obtained from the first element.
Map$addLayer(srtm_clipped)

Improve on the visualization

library(rgeeExtra)
Map$centerObject(eeObject = aoi, zoom = 8)
## NOTE: Center obtained from the first element.
Map$addLayer(eeObject = srtm_clipped, visParams = list(
  min = ee_minValue(srtm_clipped),
  max = ee_maxValue(srtm_clipped),
  palette = cptcity::cpt(pal = 'grass_terrain')
))