Is there a way to fix the pixel resolution of a dataset in Earth Engine?
I am using the USGS Mangrove layer image collection, which I reduce using the max() function. This gives me an image of 1s over the global extent of mangroves. This image was made with Landsat so its native resolution is 30m.
However, when I try to get the area of each pixel, it varies with the level of zoom I am using. If I zoom out the pixel area increases and if I zoom in, the pixel area value decreases. At the equator, the value should be approximately 900 m2 and it should change with increases in latitude.
I need to get the size of each pixel as I need to multiply it by another dataset (Hansen Forest cover) in order to get the tree cover area per pixel.
A link to my code is here: https://code.earthengine.google.com/a01b4889289544bf5cd761105d9d8caa
And a code snippet is:
Map.setCenter(9.5, 0.2, 10)
var MaxMangrove = Mangroves.max()
print('Pixel Size = ', MaxMangrove.projection().nominalScale())
Map.addLayer(MaxMangrove, {min:0,max:1}, 'Max Mangrove Value')
// not sure if it wants res in m or degrees here
var MangroveProj = MaxMangrove.setDefaultProjection('EPSG:4326', null, 30)
var PixelArea = MangroveProj.multiply(ee.Image.pixelArea())
// This runs fine and displays the image I want - an image where the
// pixel value is the pixel area. This should change with latitude
// but it changes with zoom
Map.addLayer(PixelArea, {min:0,max:100}, 'Pixel Area')