1

I want to make a Landsat image collection that is totally cloud free over a SET of polygons. I have about 300 polygons (all within a single Landsat tile). I found this question, which is doing exactly what I want over a single polygon, but I can't figure out how to get it to work over a set of polygons (which are loaded as a feature class).

Here is what I tried to do to modify the solution from the question posted above, where imgcollection is my Landsat TOA Image Collection and fc is my feature class of polygons. I was trying to use map and clip together to select all the polygons in the feature class for each image (based on the answers in this related question).

  var combine = imgcollection.map(function(imgcollection) { return 
    imgcollection.clip(fc); });

After this line, I tried to continue with the solution from the first question, but it doesn't work. The error I get is as follows, which confuses me. I'm trying to use the variable "combine" as the geometry - am I misunderstanding this and actually using something else?

  ImageCollection (Error)
  Image.reduceRegion, argument 'geometry': Invalid type. Expected: 
  Geometry. Actual: ImageCollection.

EDIT: full code

  var fc = ee.FeatureCollection('ft:omit');

  var imgcollection = ee.ImageCollection("LANDSAT/LC08/C01/T1_RT_TOA");

  var combine = imgcollection.map(function(img) { return img.clip(fc); });

  var withCloudiness = combine.map(function(image) {
    var cloud =       ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
    var cloudiness = cloud.reduceRegion({
      reducer: 'mean', 
      geometry: combine, 
      scale: 30,
    });
    return image.set(cloudiness);
  });

  var filteredCollection = withCloudiness.filter(ee.Filter.lt('cloud', 10));
  print(filteredCollection);
2
  • you should show the whole script, or at least share a link to it. The error doesn't seem to be related to the code you showed, which has an error too. Argument of a mapping function over ImageCollection must be an Image. Should be: var combine = imgcollection.map(function(img) { return img.clip(fc); }); Apr 15, 2018 at 2:50
  • Thanks, you're right, I fixed that but the error is still there. I posted the full code above.
    – user118738
    Apr 15, 2018 at 19:38

1 Answer 1

1

The error is quite clear. Parameter geometry of function reduceRegion must be a Geometry. In the documentation says:

geometry (Geometry, default: null): The region over which to reduce data. Defaults to the footprint of the image's first band.

So, if you want to reduce over fc:

var fc = ee.FeatureCollection('ft:omit');

  var imgcollection = ee.ImageCollection("LANDSAT/LC08/C01/T1_RT_TOA");

  var combine = imgcollection.map(function(img) { return img.clip(fc); });

  var withCloudiness = combine.map(function(image) {
    var cloud =       ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
    var cloudiness = cloud.reduceRegion({
      reducer: 'mean', 
      geometry: fc.geometry(), 
      scale: 30,
      maxPixels: 1e13,
    });
    return image.set(cloudiness);
  });

  var filteredCollection = withCloudiness.filter(ee.Filter.lt('cloud', 10));
  print(filteredCollection);
3
  • That makes a lot of sense, thanks so much! The only issue I am running into now is that I get a time out error when I ask it to print. In reading the developers documentation, I know that 'export to drive' is a way to get around this. But, I only know of an option to export one image, not a collection. Do you know if there's a way to get around this?
    – user118738
    Apr 16, 2018 at 1:26
  • Thank you! I realized I was trying to download the entire set of landsat images - when I was running it over the entire image collection, the computation timed out still. I selected the dates and path/row I needed to narrow it down and it ran perfectly.
    – user118738
    Apr 16, 2018 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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