--- title: "Google Earth Engine" author: "Michael Rustler" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Google Earth Engine} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ## Install R packages ```{r install, eval = FALSE} pkgs_cran <- c("rgee", "reticulate") install.packages(pkgs_cran, repos = "https://cloud.r-project.org") ### Downgrade to last one supplied by R package "rgee" reticulate::py_install('earthengine-api==0.1.248') ``` ## Use ```{r use, eval = FALSE} library(rgee) rgee::ee_Initialize() # it will work now! createTimeBand <-function(img) { year <- ee$Date(img$get('system:time_start'))$get('year')$subtract(1991L) ee$Image(year)$byte()$addBands(img) } img <- ee$ImageCollection('ECMWF/ERA5_LAND/HOURLY')$ filterBounds(ee$Geometry$Point(117, 40))$ select('total_precipitation')$ first() vizParams <- list( bands = 'total_precipitation', min = 0, max = 0.0000005, gamma = 0.01 ) Map$setCenter(117, 40, 10) # You can see it m1 <- Map$addLayer(img, vizParams, 'first') m1 ```