I have uploaded several benthic habitat raster datasets into my Assets folder in Google Earth Engine to share in an app. The values are 1-13 and represent different habitat classes:

 1 'Reef Crest' (FF0000)
 2 'Reef Fore' (FFBEBE)
 3 'Reef Back' (FFD37F)
 4 'Coral/Algae' (FFAA00),
 5 'Spur and Groove' (FF73DF)
 6 'Hardbottom Sparse Algae' (ABCD66)
 7 'Hardbottom Dense Algae' (66CDAB)
 8 'Muddy Bottom' (A87000)
 9 'Dredged' (D7C29E)
 10 'Sand' (FFFFBE)
 11 'Boulders and Rocks' (AFF2FF)
 12 'Seagrass Sparse' (38A800)
 13 'Seagrass Dense' (267300)

When I symbolize the layer, it's averaging pixels in the symbology when zoomed out. For example, pixels between Sand and Seagrass Sparse are appearing as 'boulders and rocks'.

var palette_bh = ['FF0000','FFBEBE','FFD37F','FFAA00','FF73DF','ABCD66','66CDAB','A87000','D7C29E','FFFFBE','AFF2FF','38A800','267300'];
var bhVis = benhab.visualize({bands: 'b1', min: 1, max: 13, palette: palette_bh});

I've also generated pie charts showing the amount of habitat class per country, and this error is also impacting those calculations.

Is there a way to symbolize this differently to eliminate this problem?

1 Answer 1


As you zoom out or zoom in, what gets displayed (on the map and your pie chart) is controlled by the Google Earth Engine's pyramiding policy. So, for example, if you uploaded your rasters with default options (pyramiding policy = "mean"), then as you zoom out, the pixels represented at the lower resolution are constructed using the "mean" of the native-resolution pixels it overlaps. To fix this, you have 2 options:

  1. Option 1 [Preferred]- Reupload the raster data with pyramiding policy = "mode" enter image description here
  2. Option 2- Force Earth Engine to display the "mode" of pixels and use the "mode" to compute the pie chart. This can be done by passing the ee.Reducer.mode() reducer to the reduceResolution function. A working example is given here. Note that this should be used with caution since it is very computationally intensive for large areas. For large areas, option 1 should be used since it takes advantage of the fact the Earth Engine caches the uploaded raster at different resolutions and chooses the most ideal one depending on zoom level automatically.

Your Answer

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

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