Following the indication on Calculating number of pixels in polygon using Google Earthy Engine? I wrote this script:
var gfc =ee.Image('UMD/hansen/global_forest_change_2018_v1_6');
var lossyear = gfc.select(['lossyear']);
//For loop for each years
for (var py=0; py <19; py++){
var year = py+2000;
var y = py;
var table_comp = path for feature collection;
// current and next year
var lossYear= lossyear.eq(y);
var lossYear = lossyear.updateMask(lossYear);
var yp1 =ee.Number(y).add(1);
var lossYear_pl =lossyear.eq(yp1)
var lossYear_pl =lossyear.updateMask(lossYear_pl)
var gfc_count= lossYear.reduceRegions({
collection: table_comp,
reducer: ee.Reducer.count(),
scale: 30});
}
For each geometry of feature collection I would like to have the number of Hansen loss for the reference year and the next. I'm writing this script to ask information about function of reducer.count() function. I have noticed that the surface that I calculate starting from the pixels extracted from Hansen is often larger than the area of the polygons I previously calculated. Besides the inevitable mistake,I would ask major information about the function reduce.count().
In particular pixels that are on the border of the polygon how are they counted?