0

I am currently struggling to compute the forest area of some regions. I am an absolute beginner with Google Earth Engine. I tried it 2 different ways, mostly by copying and editing code I found.

  1. Count the number of pixels with a tree cover greater than 10% (using the Hansen data) I thought that, I then could simply multiply by the pixel size and get the area. However, I am not sure if I can do it like that. Nonetheless, here is my code:
    var gfc2017 = ee.Image('UMD/hansen/global_forest_change_2017_v1_5');
        var treeCover = gfc2017.select(['treecover2000']).unitScale(10, 100);

        Map.addLayer(
            treeCover,
           {palette: ['000000', '00FF00'] });

    // import the District layers as a fusion table
    var districts = ee.FeatureCollection('ft:13cHA4yautjvngKSaPywzP9Li9FVtlkJ7Dg64DQMG');
    //add districts to the map and center map
    Map.addLayer(districts);
    Map.centerObject(districts);    

    // Count the pixels with tree cover over 10 percent
    var stats = treeCover.reduceRegions({
    collection: districts,
     reducer: ee.Reducer.count(),
     scale: 30
    });
    //print('count of pixels representing forest in each circle:', stats)

    print('pixels representing forest: ', stats);

The numbers I am getting are however, way to high. Can anybody please help me?

  1. My second approach was to try using a map that has pixels of forest area, non forest area and water of the year 2010 (ID:JAXA/ALOS/PALSAR/YEARLY/FNF/2010)

I tried to sum the pixels, however, I am not able to just look at forest pixels. I guess it is pretty easy to do. But reading here and googling a lot has not helped yet.

My code (without the selection of only forest pixels):

 // Load the image from the archive
    var farea = ee.Image('JAXA/ALOS/PALSAR/YEARLY/FNF/2010')

    var treeCover = farea

    Map.addLayer(treeCover)

// import the District layers as a fusion table
var districts = ee.FeatureCollection('ft:13cHA4yautjvngKSaPywzP9Li9FVtlkJ7Dg64DQMG');
//add districts to the map and center map
Map.addLayer(districts);
Map.centerObject(districts);    

// Sum the values of forest pixels in districts.
var areaImage = farea.multiply(ee.Image.pixelArea());

// Count forest pixels in districts
var stats = areaImage.reduceRegions({
collection: districts,
 reducer: ee.Reducer.count(),
 scale: 30
});

Would be really great if someone could help me out.

0

So I managed to do it myself by reading more on here (someone had a comparable question about tree cover) and thinking :D For the Hansen data, this code worked for me:

//Select the area with tree cover greater than 10%
var treeCover = gfc2017.select(['treecover2000']);
var greater10 = treeCover.gte(10);
var treeCover_greater10 = treeCover.updateMask(greater10);

Apart from that it is crucial to count instead of sum as tree cover is given as a percentage. Hope this helps someone with the same question in the future.

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