1

I am working on a simple script to get mean value from a ImageCollection(). To do this I am using ImageCollection.reduce(ee.Reducer.mean()).

My problem is that the Image returned is coming with a different nominalScale().

I already looked at the documentation but couldn't figure out why this results. As you can see on ee.ImageCollection.reducer() there is no parameter specifying the scale; nor on ee.Reducer.mean().

What am I doing wrong? Again, I am basically trying to do do something like this. Actually this tutorial shows an image which made me believe I wouldn't have changes on pixel resolution...

My code:

var WorldClim = ee.ImageCollection("WORLDCLIM/V1/MONTHLY");
print("WorldClim original", WorldClim.first().projection().nominalScale());
var WorldClim = WorldClim.select("prec");
print("Apenas prec:", WorldClim.first().projection().nominalScale());
var MeanPrec = WorldClim.reduce(ee.Reducer.mean());
print("Após reduce(ee.Reducer.mean())", MeanPrec.projection().nominalScale());

https://code.earthengine.google.com/3e3bff9030fd9ff70b052b2beb4daced

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
  • Welcome to Stack Overflow! Please always include the relevant portion of the code you are asking about in the question itself, not just a link. I've edited this question for you. – Kevin Reid Jun 30 '19 at 22:40

1 Answers1

0

That is most likely due to the image pyramiding of image. Since the mean image is a temporary object only in memory buffer, it should not have a base nominal scale and since the tiles are computed based on whatever zoom level your map is currently at. However, there is a way you can fix this if you specifically want to work with the resolution of the source image. You basically have to reproject the image to the same one the original has. One way to do this would be to change the line where you compute mean to

var MeanPrec = WorldClim.reduce(ee.Reducer.mean()).reproject({
  crs:WorldClim.first().projection(),
  scale:WorldClim.first().projection().nominalScale()
});
Nishanta Khanal
  • 316
  • 2
  • 4