1

I'd like to use the hansen forest cover dataset and the Resolve ecoregions database to sum forest areas across biomes. The Resolve dataset has many polygons, but the "BIOME_NAME" column is repeated across many of them, such that there are only 13 biomes across the globe. I would like to sum the forest area in each biome.

I'm sure there's some way to do this with reduceRegions, but I'm not sure how to confine the analysis across biomes, and not for each and every polygon. At present, the code below results in an error when calculating the final dictionary.

https://code.earthengine.google.com/2a60e1ddacbafdcb70b1bffb59811812

var gfc2018 = ee.Image("UMD/hansen/global_forest_change_2018_v1_6"),
resolve = ee.FeatureCollection("RESOLVE/ECOREGIONS/2017");

var fc2000_pct = gfc2018.select(0).divide(100)

// Get scale (in meters) information from band 0.
var b0scale = gfc2018.select(0).projection().nominalScale();
print('Band 0 scale: ', b0scale); // ee.Number

var forest_area_per_pixel = fc2000_pct.multiply(b0scale)

// now to aggregate by biome...
var forest_area_per_biome = forest_area_per_pixel.reduceRegion({
  reducer: ee.Reducer.sum(),
  geometry: resolve.geometry(),
  scale: b0scale,
  maxPixels: 1e9
});

print(forest_area_per_biome);
1
  • What is the error?
    – PolyGeo
    Commented Dec 12, 2019 at 19:27

1 Answer 1

1

This seems like a pretty big processing job, and I'm not sure it's possible to run it directly in the developer console. You probably need an export. Below is my take on it. I never waited for the export to finish, so I don't guarantee that it actually will. I'm sure there are cleverer and more efficient ways to do this too. But at least you've have a starting point with this.

var fc2000_pct = gfc2018.select(0).divide(100)

// Get scale (in meters) information from band 0.
var b0scale = gfc2018.select(0).projection().nominalScale();
print('Band 0 scale: ', b0scale); // ee.Number

var forest_area_per_pixel = fc2000_pct.multiply(b0scale)

var areas = resolve
  // .limit(5) // When developing, it's convenient to speed things up by limiting the amount of data to work with
  .map(function (feature) {
    var area = forest_area_per_pixel.reduceRegion({
      reducer: ee.Reducer.sum(),
      geometry: feature.geometry(),
      scale: b0scale,
      maxPixels: 1e12 // Some of the areas are large and have more pixels than 1e9
    }).getNumber('treecover2000')
    return ee.Feature(feature.geometry(), {AREA: area, BIOME: feature.get('BIOME_NAME')})
  }) // Results in a FeatureCollection with AREA and BIOME, one feature for each feature in resolve

var biomeAreas = ee.FeatureCollection(ee.List(areas.distinct('BIOME').aggregate_array('BIOME'))
  .map(function (biome) {
    return ee.Feature(ee.Geometry.Point([0, 0]), {BIOME: biome})
  })) // A FeatureCollection with only distinct BIOME
  .map(function (feature) {
    var biome = feature.getString('BIOME')
    var area = areas.filterMetadata('BIOME', 'equals', ee.String(biome)).aggregate_sum('AREA')
    return ee.Feature(feature.geometry(), {BIOME: biome, AREA: area})
  }) // A FeatureCollection with one feature per BIOME with the aggregated AREA

// print(biomeAreas) // Print the result will cause you to run out of memory
Export.table.toAsset(biomeAreas, 'test_biome_areas') // An export give you a lot more memory to play with

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.