1

I want to clip this fire data so it only displays results in my shapefile titled 'tapajos'. How do I do this?

var dataset = ee.ImageCollection('FIRMS').filter(
    ee.Filter.date('2000-01-01', '2018-08-10'));
var fires = dataset.select('T21');
var firesVis = {
  min: 325.0,
  max: 400.0,
  palette: ['red', 'orange', 'yellow'],
};
Map.setCenter(-119.086, 47.295, 6);
Map.addLayer(fires, firesVis, 'Fires');

2 Answers 2

3

You can clip every image in the collection by using:

// This function clips images to the ROI feature collection
var clipToCol = function(image){
  return image.clip(tapajos);
};
var dataset = ee.ImageCollection('FIRMS').filter(
    ee.Filter.date('2000-01-01', '2018-08-10')).map(clipToCol);
var fires = dataset.select('T21');
var firesVis = {
  min: 325.0,
  max: 400.0,
  palette: ['red', 'orange', 'yellow'],
};
Map.setCenter(-119.086, 47.295, 6);
Map.addLayer(fires, firesVis, 'Fires');
2

When you say Map.addLayer(fires,...), you're implicitly calling mosaic() on that collection, which returns a single image. If that's how you're doing it, clipping a single image (a composite) to a FeatureCollection, then you should use image.clipToCollection(). If you need to clip every image in the collection first, then map a function over the ImageCollection in which you call clipToCollection().

2
  • How do image.clipToCollection() and image.clip() differ? Apr 15, 2019 at 18:29
  • 3
    If the geometries in the collection are complex and/or a lot of them, then clipToCollection is more efficient. Otherwise, the geometries will need to be extracted and merged into one giant geometry, which can be expensive. Apr 15, 2019 at 22:26

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.