I am trying to calculate the tree cover in Maine (by county) using the reduceRegions() tool. I based my code on this thread. I am interested in areas in square km. The output of my code yields, though, areas of counties' tree cover that are larger than their areas (and/or the whole Maine itself!). The calculated tree cover in the 16 counties of Maine sums up to about 6.5 million sq. km. The area of Maine, instead, is of about 95 thousand sq. km.

I set the scale to 30 meters so to fit Hansen's data pixel resolution. Here is my code:

//Load and filter the Hansen data
var gfc2014 = ee.Image('UMD/hansen/global_forest_change_2017_v1_5')

// turn your scale into a var in case you want to change it
var scale = 30;

//load maine:
var maine = ee.FeatureCollection('ft:1S4EB6319wWW2sWQDPhDvmSBIVrD3iEmCLYB7nMM')
              .filter(ee.Filter.eq('StateName', 'Maine')).select(['CntyFips']);

//find the area of tree cover in sq km:
var treeCover = gfc2014.select(['treecover2000']);
var areaCover = treeCover.multiply(ee.Image.pixelArea())

// Sum tree cover area per feature (county):
var mainetree = areaCover.reduceRegions({
  collection: maine,
  reducer: ee.Reducer.sum(),
  scale: scale,

print(mainetree);    // just for visual inspection, the sum is done in the .csv

Map.addLayer(maine, {}, 'counties');    // visualise area of interest

// Export the FeatureCollection.
  collection: mainetree,
  description: 'maine',
  fileFormat: 'CSV'

You are multiplying the area of each pixel with the values of the pixels in the image called "treeCover". Those values range from 0 - 100, i.e. they are percentages. So you first have to divide that image by 100 to get the fraction of the area you want to sum with your reduceRegions.

  • That is sure the case. It solves my issue, thanks a lot! – Bruno Conte Leite Nov 16 '18 at 11:15

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.