knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Install R packages

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

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


KWB-R/kwb.satellite documentation built on May 29, 2022, 9:08 p.m.