Statistics of Image Regions

To get image statistics in multiple regions stored in a FeatureCollection, you can use image.reduceRegions() to reduce multiple regions at once. The input to reduceRegions() is an Image and a FeatureCollection. The output is another FeatureCollection with the reduceRegions() output set as properties on each Feature. In this example, means of the Landsat 7 annual composite bands in each feature geometry will be added as properties to the input features:

// Load input imagery: Landsat 7 5-year composite.
var image = ee.Image('LE7_TOA_5YEAR/2008_2012');

// Load a FeatureCollection of counties in Maine.
var maineCounties = ee.FeatureCollection('ft:1S4EB6319wWW2sWQDPhDvmSBIVrD3iEmCLYB7nMM')
  .filter(ee.Filter.eq('StateName', 'Maine'));

// Add reducer output to the Features in the collection.
var maineMeansFeatures = image.reduceRegions({
  collection: maineCounties,
  reducer: ee.Reducer.mean(),
  scale: 30,
});

// Print the first feature, to illustrate the result.
print(ee.Feature(maineMeansFeatures.first()).select(image.bandNames()));
    

Observe that new properties, keyed by band name, have been added to the FeatureCollection to store the mean of the composite in each Feature geometry. As a result, the output of the print statement should look something like:

Feature (Polygon, 7 properties)
  type: Feature
  geometry: Polygon, 34 vertices
  properties: Object (7 properties)
    B1: 23.92059069406908
    B2: 20.25958529338255
    B3: 13.907316351056284
    B4: 70.03141655348698
    B5: 34.66775258336134
    B6_VCID_2: 190.2679106547084
    B7: 13.95053603828997
    

发送以下问题的反馈:

此网页
Google Earth Engine API