Geographic Information Systems Asked by Anni on June 14, 2021
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.
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?
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.
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.
Answered by Anni on June 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP