TransWikia.com

Why does my Google Earth Engine code run on a polygon, but not an image if they are of the same area

Geographic Information Systems Asked by Shannon on January 13, 2021

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);

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP