Just getting started with GEE and trying to achieve something fairly simple using the Hansen et al. dataset.

Basically, I have a series of GPS points, and I want to count the amount (pref %) forest cover remaining around each point - at different distances (e.g., 500m, 1km, 3km).

If I understand this correctly, there are several critical steps:

  1. Masking out the loss pixels, to create an updated forest cover layer;
  2. Count and convert the number of pixels in my buffer around each gps.

I have done this crudely using the following script, however, the values I am getting out look rather odd. I am wondering how much of this is just due to the raster/datalayer, or simply due to some obvious errors in my script.

// Import Global Forest Change dataset.
var hansen_2020 = ee.Image("UMD/hansen/global_forest_change_2020_v1_8");

// Subset Global Forest Change the dataset.
var treeLoss = hansen_2020.select('loss');
var treeGain = hansen_2020.select('gain');
var treeCover = hansen_2020.select('treecover2000');
var treeCoverUpdated = treeCover.mask(treeLoss);
var greater10 = treeCoverUpdated.gte(10);
var treeCover_greater10 = treeCover.updateMask(greater10);

// Load GPS coordinates
var GPS = ee.FeatureCollection('users/MSc_project/GPSCords_allv2');

// Set 500m, 1km and 3km buffers
var GPS_500m = GPS.map(function (feature) {
  return feature.buffer(500, 1)

var GPS_1000m = GPS.map(function (feature) {
  return feature.buffer(1000, 1)

var GPS_3000m = GPS.map(function (feature) {
  return feature.buffer(3000, 1)

// Calculate forest cover
var forestImage = treeCover_greater10.multiply(ee.Image.pixelArea());

// Count the forest cover pixels in 500m.
var forest = forestImage.reduceRegions({
  collection: GPS_500m,
  reducer: ee.Reducer.count(),
  scale: 1

  collection: forest,
  description: '500m_forest_cover'});

Any tips?

1 Answer 1


Probably you are getting odd values because you are multiplying the tree cover values (treeCover_greater10, values between 10 and 100) by the pixel area (ee.Image.pixelArea()). You might want to multiply greater10 (values of 0 and 1) by ee.Image.pixelArea() in order to obtain the area of pixels with more than 10 % of tree cover. Try defining forestImage like this:

var forestImage = greater10.multiply(ee.Image.pixelArea());
  • Thanks that helped a lot.
    – Makopet
    Jun 18, 2021 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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