0

I have a MODIS image that I'd like to resample to 12km resolution. For each 12km pixel, I'd like two pieces of information: (1) the mean of the MODIS pixels within the 12km pixel and (2) the standard deviation of the MODIS pixels within the 12km pixel.

Consider the following example:

var imageCollection = ee.ImageCollection("UMT/NTSG/v2/MODIS/NPP");    
var data = imageCollection.first().select("annualNPP")
    
var data_mean =data .reproject({ crs: 'EPSG:4326', scale: 12000})
                                        .reduceResolution({
                                          reducer: ee.Reducer.mean(), 
                                          maxPixels: 65535  }).rename("mean")

var data_stdev =data .reproject({ crs: 'EPSG:4326', scale: 12000})
                                        .reduceResolution({
                                          reducer: ee.Reducer.stdDev(), 
                                          maxPixels: 65535  }).rename("stdev")
Map.addLayer(data_mean,{},"mean")
Map.addLayer(data_stdev,{},"stdev")

This gives me an image with the mean of the MODIS pixels within the 12km pixel but the standard deviation at each 12km pixel is zero.

I thought maybe the standard deviation was small, so I tried multiplying the data_stdev image by 1,000, but that did not solve the problem.

Perhaps there is another way to approach this?

1 Answer 1

1

The reproject goes after the reduceResolution.

1
  • That did it. Thanks Noel.
    – webbe
    Oct 17, 2021 at 14:26

Your Answer

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

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