0

I'm having an issue with what I hope is a rather simple task. I have a raster of worldwide extent and I simply want a list of the unique pixel values in a given band.

Example:

//load in fire data from the last two years as dummy data
var burn = ee.ImageCollection('ESA/CCI/FireCCI/5_1')
                  .filterDate('2018-11-06', '2020-11-06');

How do I grab a list of unique values from this?

My real dataset is pretty sparse on a worldwide level, so ~300m is where I'd like to set my scale.

Furthermore, can I use this list to filter out entries in a FeatureCollection that have the unique values I find?

I've tried a variety of methods and a number of S/O threads... so far either reduceRegions has produced a memory error, or a toDictionary/frequencyHistogram method has turned up with empty outputs.

1

As far as I can see, there are several problems with the way you've gone about this problem. First, frequencyHistogram works with Images, not ImageCollections, so you have to decide if you want to run it on each image one by one, or if you want to reduce your ImageCollection (with a max, min, mean, or median function for example). Second, you did not specify which band you want the unique values of, I can see there are four, you have to select one. Lastly, to my knowledge there is no way to do the operation you want at a worldwide extent, but you can try to select an area that is large and representative enough.

Below is a snippet of code that works (you just have to define a geometry named geometry):

var burn = ee.ImageCollection('ESA/CCI/FireCCI/5_1')
                  .filterDate('2018-11-06', '2020-11-06')
                  .select('BurnDate')
                  .median();
print(burn);

var freqHist = ee.Dictionary( // Calculate frequency histogram
      burn.reduceRegion(
        {reducer:ee.Reducer.frequencyHistogram(), geometry:geometry, scale:500, maxPixels:1e13})
        .get('BurnDate')
    );

print(freqHist);
1
  • Thanks for the answer here. I see the example dataset I had listed was a bad choice. On my actual data, I had accounted for each of the things you mentioned but came up short nonetheless. I now recognize there was just no way around the worldwide extent and fine resolution that I wanted. I'm accepting this answer for visibility and hopefully others can see it in case it's helpful to them. Thanks again! – eorland Nov 16 '20 at 15:07

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.