0

Does anyone have an idea how I could aggregate my Image so that in the output the most frequent value is used, as shown on the picture?

image

this is the same question as aggregate raster using the most frequent value but using the earthengine API

Pierrick Rambaud
  • 2,788
  • 1
  • 14
  • 49

1 Answers1

0

You control how pixels are aggregated with the pyramidPolicy property in exports. In your case, you want to use mode.

var image = ee.Image('USGS/GFSAD1000_V1')
  .clip(geometry)

Export.image.toAsset({ image: image, pyramidingPolicy: {'.default': 'mode'}, scale: 100000 })

https://code.earthengine.google.com/cc36b36bc0d8374dcf3483c87252f0eb

Update

When exporting to drive, pyramidingPolicy cannot be specified. Something like this could work:

var scale = 10000
var image = ee.Image('USGS/GFSAD1000_V1')
  .clip(geometry)

var reprojected = image .reduceResolution({ reducer: ee.Reducer.mode(), maxPixels: 65536 // Max input pixels for each output pixel })

Export.image.toDrive({ image: reprojected, scale: scale })

https://code.earthengine.google.com/4058242ee0216ab76b9343a675066e7d

Daniel Wiell
  • 14,155
  • 2
  • 11
  • 29