# Forest change tutorial results don't make sense compared to area of the country

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).

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")

// 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);
``````

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.

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")

// 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)
``````