-
Hi! I was trying to do the zonal statistic mean for the greenest raster image at the U.S.state level. The output only has state information; nothing shows the zonal mean. The output is this import ee
import geemap
import os
Map = geemap.Map()
countries = ee.FeatureCollection("users/giswqs/public/countries")
Map.addLayer(countries, {}, "countries")
roi = countries.filter(ee.Filter.eq("ISO_A3", "USA"))
Map.addLayer(roi, {}, "roi")
start_date = "2021-01-01"
end_date = "2021-12-31"
l8 = (
ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")
.filterBounds(roi)
.filterDate(start_date, end_date)
)
def addNDVI(image):
ndvi = image.normalizedDifference(["B5", "B4"]).rename("NDVI")
return image.addBands(ndvi)
ndviCollection = l8.map(addNDVI)
greenest = ndviCollection.qualityMosaic('NDVI')
states = ee.FeatureCollection('TIGER/2018/States')
zonal_stats_result = geemap.zonal_statistics(greenest.select('NDVI'), states, scale=1000, statistics_type='MEAN') |
Beta Was this translation helpful? Give feedback.
Answered by
giswqs
Apr 7, 2024
Replies: 1 comment
-
This seems an Earth Engine bug rather than geemap. If you use stats = greenest.select('NDVI').reduceRegions(
collection=countries,
reducer=ee.Reducer.mean(),
scale=1000
) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
giswqs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems an Earth Engine bug rather than geemap. If you use
ee.Image.reduceRegions
withoutgeemap.zonal_stats
, you get the same result.