Create time series of JRC MonthlyHistory surface water observations by region with R + rgee

This code should work:

library(rgee)

ee_Initialize()

geom_nauta <- ee$Geometry$Point(c(-73.47693, -4.44500))$buffer(10000)
surface_water <- ee$ImageCollection("JRC/GSW1_2/MonthlyHistory") %>% 
  ee$ImageCollection$filterDate("2006-01-01", "2006-12-31") %>% 
  ee$ImageCollection$map(function(img) img$updateMask(img$eq(1)))

ee_sw <- ee_extract(
  x = surface_water, 
  y = geom_nauta,
  scale = 30,
  fun = ee$Reducer$count(), 
  sf = FALSE
)

plot(ee_sw %>% as.numeric(), type="l")

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top