Search code examples
rrgee

rgee: radar vegetation index


I'd like to create a temporal mean for the Radar vegetation index - RVI in a target roi. In my example:

library(tidyverse)
library(rgee)
library(sf)
ee_Initialize(drive=TRUE)

# Define a Region of interest
roi <-ee$Geometry$Point(-52.19032,-30.25413)$buffer(500)
    
# Sentinel-1 dataset into the Earth Engine’s public data archive ------------              
s1 <- ee$ImageCollection("COPERNICUS/S1_GRD")

# Radar vegetation index - RVI
 
RVI = function(img){
    img_band_selected <- image$expression(
        expression = '4*vh/(vv+vh)',
        opt_map =  list(
            'vv' = image$select('VV'),
            'vh' = image$select('VH')
        )
    )
        return(img_band_selected)
    }

s1_roi  <- s1$
   filterBounds(roi)$
   filter(ee$Filter$date(as.character(as.Date("2019-12-04")), as.character(as.Date("2020-01-03"))))$$filter(ee$Filter$listContains("transmitterReceiverPolarisation", "VV"))
$filter(ee$Filter$listContains("transmitterReceiverPolarisation","VH"))$filter(ee$Filter$eq("instrumentMode", "IW"))$
   map(RVI)

#Extract average radar vegetation index (RVI) values 
ee_mean<- ee_extract(
     x = s1_roi,
     y = RVI,
     scale = 10,
     fun = ee$Reducer$mean(),
     via = "drive"
    )
ee_mean

Error in py_call_impl(callable, dots$args, dots$keywords) : 
TypeError: 'ImageCollection' object is not callable

But the output is not OK and almost doesn't have examples with vegetation index for Sentinel-1 band C in rgee.

Please any help with it?


Solution

  • If you change image by img in function and correct x and y objects called in ee_extract, your script works!!

    library(tidyverse)
    library(rgee)
    library(sf)
    ee_Initialize(drive=TRUE)
    
    # Define a Region of interest
    roi <-ee$Geometry$Point(-52.19032,-30.25413)$buffer(500)
    
    # Sentinel-1 dataset into the Earth Engine’s public data archive ------------              
    s1 <- ee$ImageCollection("COPERNICUS/S1_GRD")$filter(ee$Filter$listContains("transmitterReceiverPolarisation", "VV"))$filter(ee$Filter$listContains("transmitterReceiverPolarisation","VH"))$filter(ee$Filter$eq("instrumentMode", "IW"))
    
    # Radar vegetation index - RVI
    
    RVI = function(img){
      img_band_selected <- img$expression(
        expression = '4*vh/(vv+vh)',
        opt_map =  list(
          'vv' = img$select('VV'),
          'vh' = img$select('VH')
        )
      )
      return(img_band_selected)
    }
    
    s1_roi  <- s1$filterBounds(roi)$filter(ee$Filter$date(as.character("2019-12-04"), as.character("2020-01-03")))$map(RVI)
    
    #Extract average radar vegetation index (RVI) values 
    ee_mean<- ee_extract(
      x = s1_roi,
      y = roi,
      scale = 10,
      fun = ee$Reducer$mean(),
      via = "drive"
    )
    ee_mean
    
      S1B_IW_GRDH_1SDV_20191210T084832_20191210T084857_019300_024710_A03C_constant
    1                                                                     2.426008
      S1B_IW_GRDH_1SDV_20191222T084832_20191222T084857_019475_024CA1_193D_constant
    1                           
    
                                          2.434232