0

I have 0.02° tiles across some regions of interest in Africa. I am trying to find the percent of 300m ESA land cover pixels that are classified as cropland (classification 10-30) for each tile, as well as the total number of ESA non-NA pixels. I thought one way to do this would be to count the within-tile pixels classified as cropland and then count the total number of ESA pixels within each tile. I did this as follows:

//Select only the 2001 ESA image
var lulc_01 = lulcYrSub.select(["lc_2001"]);

//Reclassify the ESA image such that all pixels with classification 10-30 are 1s and the rest zeroes
var ag_2001 = lulc_01.gte(10).and(lulc_01.lte(30));

//Reclassify ESA image so that all non-NA pixels are 1's
var tot_2001 = lulc_01.gte(10).and(lulc_01.lte(220));

//Function adds up total number of cropland pixels within each tile
var nAg_2001 = tiles.map(function(feature) {
  return feature.set(ag_2001.reduceRegion({
    reducer: ee.Reducer.sum(),
    geometry: feature.geometry(),
    scale: 30
  }));
});

//Function adds up total number of pixels within each tile
var nPix_2001 = nAg_2001.map(function(feature) {
  return feature.set(tot_2001.reduceRegion({
    reducer: ee.Reducer.sum(),
    geometry: feature.geometry(),
    scale: 30
  }));
});

But the resulting pixel counts seem impossible given the tile size. My tiles are about 2.22 km by 2.22 km. There should be approximately 50-60 300-meter pixels within each tile. Yet one of my tiles allegedly has 1,900 pixels in it! What is going wrong? Can you recommend an alternative way to get the percent crop cover as well as the total number of pixels within each tile? Full code here.

2
  • Try setting the scale to 300. Also we can't access your code. Could you link to it using the Get Link button in the code editor? – JonasV Mar 22 at 10:58
  • I'm sorry the link wasn't working - I used "Get Link", so not sure what the problem was. Any way, suggestion worked perfectly. The counts are reasonable now. Thank you! – C. Ashley Mar 22 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.