When using ee.reduceRegions() I try to estimate the mean values of copernicus landcover values within all features in a feature collection I get 'null' as a result for all reducers I have tried (mean, min, first, etc). However when I use ee.reduceRegion() (notice no 's') I get a result for the mean value for the entire feature collection. How do I get mean values for each feature? Here is a reproducible example:
// Load input imagery: Copernicus land cover.
var image = ee.Image('COPERNICUS/Landcover/100m/Proba-V-C3/Global/2019');
print(image)
// Load a FeatureCollection of counties in Maine.
var maineCounties = ee.FeatureCollection('TIGER/2016/Counties')
.filter(ee.Filter.eq('STATEFP', '23'));
print(maineCounties)
var clip = image.clip(maineCounties);
Map.addLayer(clip, {}, "Tree Cover");
// Add reducer output to the Features in the collection.
var maineMeansFeatures = image.reduceRegions({
collection: maineCounties,
reducer: ee.Reducer.mean(),
scale: 1000,
});
// Print the first feature, to illustrate the result.
print(ee.Feature(maineMeansFeatures.first()).select(image.bandNames()));
// Reduce the region. The region parameter is the Feature geometry.
var meanDictionary = image.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: maineCounties.geometry(),
scale: 1000,
maxPixels: 1e9
});
print(meanDictionary)