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

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

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().

  • How do image.clipToCollection() and image.clip() differ? – JepsonNomad Apr 15 at 18:29
  • 1
    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. – Nicholas Clinton Apr 15 at 22:26

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.