Friday, 16 December 2016

Using reducer over space and time in Google Earth Engine?


I am trying to use in Google Earth Engine a reducer (histogram) on an ImageCollection, computing it for multiple shapes for each image.


For a given image, I use reduceRegions(..., ee.Reducer.mean()) and this work, returning a feature collection with property mean.


However, when I try to apply this to all the image of the ImageCollection, using map(), it still returns a FeatureCollection, but the mean property is empty.


How can I solve this? Why is my result good on an image, but weird on an ImageCollection



var rec1 = ee.Geometry.Polygon([[[-89.78276, 40.160312], [-89.78293, 40.153424],
[-89.77108, 40.153424], [-89.77117, 40.160377]]]);

var rec2 = ee.Geometry.Polygon([[[-89.782848, 40.15335], [-89.782848, 40.14607],
[-89.774522, 40.14607],[-89.774265, 40.15322]]]);

var featCol = ee.FeatureCollection([ee.Feature(rec1), ee.Feature(rec2)]);

/// get ImageCollection, and Image
var CDL= ee.ImageCollection("USDA/NASS/CDL")

var CDL_2015 = ee.Image('USDA/NASS/CDL/2015');


/// For one image: works
var fieldStats_oneIm = CDL_2015.select("cropland").reduceRegions({
collection: featCol,
reducer: ee.Reducer.mean(),
scale: 30
});




/// For all images: does not work?
var fieldStats_ImCol = CDL.map(function(image) {return
image.select("cropland").reduceRegions({
collection: featCol,
reducer: ee.Reducer.mean(),
scale: 30
})});




print(fieldStats_oneIm, "fieldStats_oneIm")
print(fieldStats_ImCol, "fieldStats_ImCol")


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...