I have an Image (TIFF) that I imported and would like to run this script over to calculate average NDVI over that region, but it does not work giving me an error message stating "ImageCollection (Error) Feature, argument 'geometry': Invalid type. Expected type: Geometry. Actual type: Image<[b1]>."

However, if I manually create a polygon geometry over the exact same region and have that as my input to filterbounds over it works perfectly.

Why does it accept the "geometry", but not the "image" if it is of the same region? In the example code below, I have the "image" as the filterbounds and it does not run as such. I realize in the error message that it says it is expecting a "geometry", but I don't know how to get it to expect an "image".

code example:

//This approach starts with a collection of L8 TOA images and filters them by cloud cover 

// --------------Set Location and Filter by Date and Cloud-------------------//
var MAX_LIST_SIZE = 100;

var L8_TOA = ee.ImageCollection("LANDSAT/LC08/C01/T1_RT_TOA")
    .filterDate('2013-12-25', '2016-12-25') //For whole collection, comment this out
    .filter(ee.Filter.eq('WRS_PATH', 41))
    .filter(ee.Filter.eq('WRS_ROW', 36)); //This eliminates multiple WRS results
var count = L8_TOA.size();
print('Collection size after date filtering, if that was set: ', count);

var boundary = ee.Geometry.Rectangle(-122.45, 37.74, -122.4, 37.8);    

        // **** This is not working correctly bc it only allows for "geometry"
var c = L8_TOA.filterBounds(image);          // Geometry, Image, or Boundary ***

var withCloudiness = c.map(function(image) {
  var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
  var cloudiness = cloud.reduceRegion({
    reducer: 'mean', 
    geometry: image,                         // Geometry, Image, or Boundary ***
    scale: 30,  });
  return image.set(cloudiness);});

// Here is where the computed cloud score threshold is set!
var filteredCollection = withCloudiness.filter(ee.Filter.lt('cloud', 5));
 print('L8 TOA Filtered Collection, by date and cloud',filteredCollection);

1 Answer 1


filterBounds() just doesn't accept an image.

ImageCollection.filterBounds(geometry) Collection
Argument Type Details
geometry ComputedObject|FeatureCollection|Geometry The geometry, feature or collection to intersect with.
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 12, 2021 at 8:36

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.