Google Earth Engine – Getting Accurate Pixel Area Measurements

google-earth-engine

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')

Best Answer

what you want is to force the projection of pixel area raster.

So, If you do this and use it to calculate stuff

var pa = ee.Image.pixelArea().reproject({crs:'EPSG:4326',scale:30})

or simply add the layer to map and check, the values do not change based on zoom level. It does take a while though. If you want to confirm it quickly, you can use the inspector tab/tool to check for values.

Related Question