I have a code that creates image collection and then calculate what is the biggest number of pixels in image (e.g the image with maximum spatial data). I managed to calculte this number and to use it to create new image collection with relevant images. I want to create range of numebr of pixels that are needed in an image in order to join this image collection. I decided that I can "accept" images that are at least 75% size of the biggest image. I have a code for that, but whenever I try to compute max_number.multiply(0.75) I get error:

max_number.multiply is not a function

Those are therelevant parts from my code:

var dataset = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
                  .filterDate('2013-01-01', '2019-12-02')
                  .select('B4', 'B5','pixel_qa')

//clip the dataset according to the geometry
var clippedCol=dataset.map(function(im){ 
  return im.clip(geometry);

// Get the number of images.
var count = clippedCol.size();
print('Count: ',count);

//here I do calculations -clip image collection, add NDVI so my new
//my new dataset called now "withNDVI"

//Filter according to number of pixels

var ndviWithCount = withNDVI.map(function(image){
  var countpixels = ee.Number(image.reduceRegion({
  reducer: ee.Reducer.count(),
  geometry: geometry,
  crs: 'EPSG:4326',
  scale: 30,

  return image.set('count', countpixels);


var max = ndviWithCount.reduceColumns(ee.Reducer.max(),  ["count"]);
var max_number=(max.get('max'));
var almost_max=max_number.multiply(0.75);

My end goal is to be able to compute numbers with my var max_number so in the end my script knows automatically for every polygon to choose only the correct images


Please, boil down your script as much as possible and always include a link to a working script when posting a question. Your changes of getting an answer will increase dramatically!

ee.ImageCollection.reduceColumns() returns an ee.Dictionary. Calling ee.Dictionary.get() returns an ee.Element. You will need to cast that element to whatever type it actually is, or use one of the convenience getters which does the casting for you - getArray(), getGeometry(), getNumber(), getString().

var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
  .filterDate('2013-01-01', '2019-12-02')

var max = collection.reduceColumns(ee.Reducer.max(), ['system:time_start'])
var max_number=max.getNumber('max')
var almost_max=max_number.multiply(0.75)


| improve this answer | |

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.