Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/csaybar/rgee_documentation
https://github.com/csaybar/rgee_documentation
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/csaybar/rgee_documentation
- Owner: csaybar
- Created: 2020-01-28T07:02:19.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-27T16:17:13.000Z (almost 5 years ago)
- Last Synced: 2024-10-12T19:10:57.758Z (3 months ago)
- Size: 8.79 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 1) Load libraries
```r
library(rgee)
library(sf)
library(cptcity)
library(mapview)
library(leaflet)
```Initialize earthengine
```r
ee_Initialize()
```## 2) Map visualization with ee_map
Load color palete
```r
cpt_pal = cpt(pal = "mpl_inferno")
```
Load SRTM satellite image and create a visualization on leaflet.
```r
image <- ee$Image('CGIAR/SRTM90_V4')
ee_map(image,
vizparams = list(min = 0, max = 5000, palette= cpt_pal),
zoom_start = 2,
objname = 'SRTM90_V4')
```## 3) Sf map
Loading a shapefile file with sf library and color palete
```r
nc = st_read(system.file("shape/nc.shp", package="sf"))
cpt_pal <- cpt(pal = "wkp_schwarzwald_wiki_schwarzwald_cont")
nc_ee <- nc %>%
st_transform(4326) %>%
sf_as_ee(check_ring_dir = TRUE)
```
Clipping a image with a sf object
```r
clip_image <- image$clip(nc_ee)
```
Visualizing the clip image with the st object
```r
mapview(nc, alpha.regions = 0, legend = FALSE) +
ee_map(clip_image,
vizparams = list(min = 0, max = 1000, palette= cpt_pal),
zoom_start = 6,
objname = 'SRTM',
quiet = TRUE)
```## 4) Extract values from Earth Engine to sf
```r
nc_dem <- ee_extract(clip_image,nc_ee,id = "FIPSNO") %>%
`names<-`(c("FIPSNO",'SRTM_DEM')) %>%
merge(nc, .)
plot(nc_dem['SRTM_DEM'])
```