3

Here is the thing: I want to count how many Landsat pixels 30x30m were included in a 500x500m MODIS pixel. It is basically a zonal statistics, and I use reduceResolution to compute. But the issue is: in theory, there should be 500x500/30x30 = 278 landsat pixels in a MODIS pixel. But when I compute use count reducer in GEE, the number is 403 ~ 424, larger than the theoretical value. When implemented in arcgis, the sum zonal statistics returns 272 ~ 289, which makes more sense considering the actual MODIS pixel size is < 500 and Landsat pixel size is < 30 as well. So my question is how GEE handle the pixel resolution and alignment when implementing zonal statistics? Also, how can I get the value close to the theoretical 278? Is there a projection problem hidden in this issue? As GEE projection tutorial stated we should rarely concerned about projection when computing. I also tried reproject all layers to the same coordinates, but zonal statistics results are around 415. here is my snippet using GEE example.

// Load a MODIS EVI image.
var modis = ee.Image(ee.ImageCollection('MODIS/006/MOD13A1').first())
    .select('EVI');

// Display the EVI image near La Honda, California.
Map.setCenter(-122.3616, 37.5331, 12);
Map.addLayer(modis, {min: 2000, max: 5000}, 'MODIS EVI');

// Get information about the MODIS projection.
var modisProjection = modis.projection(); // what's the difference betwen .projection() and crs()
print('MODIS projection:', modisProjection);

//var modisCrs = modis.crs(); // modis.crs is not a function
//print('MODIS crs', modisCrs);

// Load and display forest cover data at 30 meters resolution.
var forest = ee.Image('UMD/hansen/global_forest_change_2015')
    .select('treecover2000');

var forestCount = forest
    // Force the next reprojection to aggregate instead of resampling.
    .reduceResolution({
      reducer: ee.Reducer.count(), // count gives value 403~424
      maxPixels: 1024
    })
    // Request the data at the scale and projection of the MODIS image.
    .reproject({
      crs: modisProjection
    });

// Display the aggregated, reprojected forest cover data.
Map.addLayer(forestCount, {max :80}, 'forest cover count at MODIS scale');

Here is screen shot of images when use ee.Reducer.count(). the black pixel value is around 403, and the white pixel value is around 424. Way large than the theoretical 278.

screen shot of images when use ee.Reducer.count()

ee.Reducer.count() results

1 Answer 1

0

I found the resolution myself. Here I shared and with some unresolved questions in my mind. The solution is you have to reproject the forest cover and after later, after reduceResolution, you need to reproject again. Here is the snippet.

var forestCount = forest.reproject({crs:'SR-ORG:6974', scale: 30})
      // Force the next reprojection to aggregate instead of resampling.
      .reduceResolution({
        reducer: ee.Reducer.count(), // 
        maxPixels: 1024
      })
      // Request the data at the scale and projection of the MODIS image.
      .reproject({
       crs: 'SR-ORG:6974', // MODIS projection
      });
  };

This works with reasonable outputs. But reproject is not recommended in GEE. particularly reproject twice. So my question for the GEE expert is, do you have better solutions or explanations?

Your Answer

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

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