Skip to content

ee_extract() function fails : "Error in ee$Image$reduceRegions" #395

@AlexCarrascosa

Description

@AlexCarrascosa

Hi there!

I'm using rgee to obtain historical values from MODIS images in specific locations. I include the output of ee_Initialize() below just to show that rgee is configured correctly and the software versions (Python version is 3.13.5).

── rgee 1.1.7.9 ───────────────────────────────────────────────────────────────── earthengine-api 1.6.4 ──
✔ user: [email protected]
✔ Google Drive credentials: FOUND
✔ GCS credentials: FOUND
✔ Initializing Google Earth Engine: DONE!
✔ Earth Engine account: projects/ee-XXXXXX/assets/Par_modis
✔ Python Path: C:/Users/XXXX/AppData/Local/r-miniconda/envs/rgee/python.exe
────────────────────────────────────────────────────────────────────────────────────────────

The ImageCollection() function seems to work well, but I start having problems when I try to extract values from raster images based on the locations of vectorial points. I always recibe the error "Error in ee$Image$reduceRegions(image = img, collection = ee_y, reducer = fun, : RuntimeError: argument was not used (image = img)"

 PAR_images <- ee$ImageCollection("MODIS/062/MCD18C2")$
 filterDate(start, end)$
    select(c("GMT_0000_PAR", "GMT_0300_PAR", "GMT_0600_PAR", "GMT_0900_PAR",
            "GMT_1200_PAR", "GMT_1500_PAR", "GMT_1800_PAR", "GMT_2100_PAR"))

 coords <- st_read('C:/-------------/Coords.shp') %>% select(geometry)
 coords_ee <- sf_as_ee(coords)

 img1 <- PAR_images$first()$select("GMT_1200_PAR")
 PAR_values <- rgee::ee_extract(x = img1, y = coords_ee, scale = 1000, sf = F, via = "drive")

   --- Error in ee$Image$reduceRegions(image = img, collection = ee_y, reducer = fun, :
         RuntimeError: argument was not used (image = img)
         Run `reticulate::py_last_error()` for details. ----

I always get the same error, no matter what I change... It doesn't matter if I use via = drive or via = gcs. The same thing happens if I use other types of image collections, such as Sentinel2 images. And it's not related to the shapefile point file either, because I've even tried loading some coordinates manually. Below is a map just to show that both the MODIS image and the vector layer of points open correctly.

Map$addLayer(PAR_images$first()$select("GMT_1200_PAR"), imageVisParam, "PAR 12:00 (first image)")
Map$addLayer(coords_ee, list(color = "black", pointSize = 3), "Sampling Points")
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions