0

I've been following this Earth Engine tutorial on calculating forest loss by country, and running that same code for multiple other countries. What I had matched the expected output that the tutorial references (ie. 348,036,295 square meters of forest lost in Congo in 2012).

https://developers.google.com/earth-engine/tutorial_forest_03

I was curious what tree cover lost each year was as a percentage of total land area in each country, but those results don't make any sense. For Congo, there are years when 20-50% of the total country area show forest loss. When I tried this with other countries, the results are worse--with forest loss sometimes over 100% of the country's land area.

I'm getting the country's land area from CIA World Factbook: https://www.cia.gov/library/publications/the-world-factbook/geos/cg.html

Obviously I'm overlooking something very basic?

My code:

var country = ee.FeatureCollection("USDOS/LSIB/2013")
        .filterMetadata('cc', 'equals', 'CF');

// Get the forest loss image.
var hansen = ee.Image('UMD/hansen/global_forest_change_2018_v1_6')

// separating out the bands
var treecover2000 = hansen.select('treecover2000');
var loss = clipped.select('loss');
var lossAreaImage = loss.multiply(ee.Image.pixelArea());

// PRINT YEARLY LOSS BY COUNTRY (SMALL)
var lossyear = hansen.select(['lossyear'])

var lossByYear = lossAreaImage.addBands(lossyear).reduceRegion({
  reducer: ee.Reducer.sum().group({
    groupField: 1
    }),
  geometry: country,
  scale: 30,
  maxPixels: 1e13
});
print(lossByYear);

var statsFormatted = ee.List(lossByYear.get('groups'))
  .map(function(el) {
    var d = ee.Dictionary(el);
    return [ee.Number(d.get('group')).format("20%02d"), d.get('sum')];
  });
var statsDictionary = ee.Dictionary(statsFormatted.flatten());

print(statsDictionary);
0

As suspected, I was just making a simple mistake in converting square km to square meters (multiplying by 1000 instead of 1,000,000) when calculating percents.

|improve this answer|||||
0

You can calculate the country area from the geometry itself, then use that to calculate share

Try this:

// Load country
var country = ee.FeatureCollection("USDOS/LSIB/2013")
    .filterMetadata('cc', 'equals', 'CD');


// Get the forest loss image.
var hansen = ee.Image('UMD/hansen/global_forest_change_2018_v1_6')

// separating out the bands
var treecover2000 = hansen.select('treecover2000');
var loss = hansen.select(['loss']);
var lossAreaImage = loss.multiply(ee.Image.pixelArea());

// PRINT YEARLY LOSS BY COUNTRY (SMALL)
var lossyear = hansen.select(['lossyear'])

var lossByYear = lossAreaImage.addBands(lossyear).reduceRegion({
  reducer: ee.Reducer.sum().group({
  groupField: 1
    }),
  geometry: country,
  scale: 30,
  maxPixels: 1e13
});

var statsFormatted = ee.List(lossByYear.get('groups'))
  .map(function(el) {
  var d = ee.Dictionary(el);
  return [ee.Number(d.get('group')).format("20%02d"), d.get('sum')];
});

var statsDictionary = ee.Dictionary(statsFormatted.flatten());

// Calculate are of country geometry
var area = country.geometry().area()

// Calculate forest loss share of total area
var lossShare = statsDictionary.map(function(k,el) {
  return ee.Number(el).divide(area).multiply(100)
})

print(lossShare)
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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