Skip to content

Fix ee_min and max Value() to use image$reduceRegion() - #12

Open
Wycology wants to merge 1 commit into
r-earthengine:masterfrom
Wycology:fix-ee_minValue_and_ee_maxValue
Open

Fix ee_min and max Value() to use image$reduceRegion()#12
Wycology wants to merge 1 commit into
r-earthengine:masterfrom
Wycology:fix-ee_minValue_and_ee_maxValue

Conversation

@Wycology

@Wycology Wycology commented Nov 4, 2025

Copy link
Copy Markdown

This PR fixes ee_minValue() and ee_maxValue() which broke after recent rgee updates.
The function now calls reduceRegion() as a method on the image object instead of passing image= as an argument.
This is compatible with current rgee versions and Earth Engine API.
I tested the function on a MODIS NDVI image clipped to Kenya and it returns the expected minimum value.

devtools::load_all()
library(rgee)
ee_Initialize()

roi <- ee$Geometry$Rectangle(
  35.35, -0.36,
  35.36, -0.35
)

ndvi <- ee$ImageCollection("MODIS/061/MOD13Q1")$
  filterDate("2025-10-01", "2025-11-01")$
  select("NDVI")$
  mean()$
  multiply(0.0001)$
  clip(roi)

ee_maxValue(ndvi)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant