FeatureCollection Information and Metadata

Methods for getting information from image collections are directly applicable to feature collections. (See the ImageCollection Information and Metadata section for details). You can use the aggregation shortcuts to count the number of features or summarize an attribute:

// Load watersheds from a data table.
var sheds = ee.FeatureCollection('USGS/WBD/2017/HUC06')
  // Filter to the continental US.
  .filterBounds(ee.Geometry.Rectangle(-127.18, 19.39, -62.75, 51.29))
  // Convert 'areasqkm' property from string to number.
  .map(function(feature){
    var num = ee.Number.parse(feature.get('areasqkm'));
    return feature.set('areasqkm', num);
  });

// Display the table and print its first element.
Map.addLayer(sheds, {}, 'watersheds');
print('First watershed', sheds.first());

// Print the number of watersheds.
print('Count:', sheds.size());

// Print stats for an area property.
print('Area stats:', sheds.aggregate_stats('areasqkm'));
    

For more general purpose FeatureCollection aggregation tools, see the Reducing a FeatureCollection page.

Palautteen aihe:

Tämä sivu
Google Earth Engine API