This works:
(with geometry being a Polygon and sent3 an ImageCollection):
var image = sent3.filterBounds(roi).first();
var mask = image.select("Oa07_radiance").mask().rename('mask');
var area = ee.Image.pixelArea().multiply(mask).rename('area');
var sumDictionarypolygon1 = mask.addBands(area).reduceRegion({
reducer: ee.Reducer.sum(),
geometry: roi,
scale: 300,
maxPixels: 1e9
});
print('sum for pol 1 mask, scale=300', sumDictionarypolygon1);
While this does not (roi being a Feature containing a geometry)
var rois = ee.FeatureCollection("users/guillaumh/embalsescba"),
sent3 = ee.ImageCollection("COPERNICUS/S3/OLCI");
var roi = rois.toList(99).get(26);
print(roi);
var image = sent3.filterBounds(roi).first();
var mask = image.select("Oa07_radiance").mask().rename('mask');
var area = ee.Image.pixelArea().multiply(mask).rename('area');
var sumDictionarypolygon1 = mask.addBands(area).reduceRegion({
reducer: ee.Reducer.sum(),
geometry: ee.Geometry(roi),
scale: 300,
maxPixels: 1e9
});
print('sum for pol 1 mask, scale=300', sumDictionarypolygon1);
The error is:
Dictionary (Error)
Feature, argument 'geometry': Invalid type. Expected type: Geometry. Actual type: Feature.
Why cannot I extract the geometry from the feature? It seems ee.Geometry( ) does not do anything.