1

I am trying to count the number of pixels in my large AOI (roughly the size of the state of Iowa) for a Landsat derived image. To get a rough pixel count, I could divide the area of my ROI by 900 (30x30m scale) but I prefer GEE's ee.Reducer.count(), which include partial pixels in the ROI if the pixel's centroid is there.

Printing the pixel count to the console returns Dictionary (Error) Computation timed out.

var pixel_count = ndvi_mosaic.reduceRegion({
  reducer: 'count',
  geometry: aoi,
  scale: 30,
  maxPixels: 1e20,
});
print(pixel_count)

Exporting pixel_count to a CSV also gives an error Error: User memory limit exceeded.

Export.table.toDrive({
  collection: ee.FeatureCollection([
    ee.Feature(null, pixel_count)
  ]),
  description: 'pixel_count',
  fileFormat: 'CSV'
});

I've also tried setting tileScale up to 16 and bestEffort: true, with no luck. Any suggestions that don't involve having to reduce the size of my image?

1
  • 2
    The way I see it is you need to either reduce the size of your study area or increase the scale, otherwise it'll just take up too much memory and output an error every time.
    – Madeleine
    Dec 15 '20 at 16:35
0

I made a mistake -- the image I was using the reducer on had 27 bands, and GEE was calculating a pixel count for each band (even though they should be the same). Just made sure the image I was reducing was only 1 layer (or you could just specify the band on the multi-band image).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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