Google Earth Engine – Why Data Appears for Entire World Despite Geometry Filter

google-earth-enginemodis

Ultimately, I'm trying to return a MOD11A1 TIFF file for a bounded geometry, but I'm seeing what I consider to be strange behavior when visualizing an Image from an ImageCollection.

The following JavaScript code is meant to return MODIS data – and display the data on the map – for a Geometry Polygon defined as:

enter image description here

// this block of code results in an ImageCollection of 2 Images
var startDate = ee.Date.fromYMD(2010,1,5);
var endDate = ee.Date.fromYMD(2010,1,7);
var dataset1 = ee.ImageCollection('MODIS/061/MOD11A1')
                  .filterDate(startDate, endDate)
                  .select('LST_Day_1km')
                  .filterBounds(geometry);
                  
var ds1_final = dataset1.map(function(img) {
  return img.select('LST_Day_1km').multiply(0.02).subtract(273.15)
})

// this block of code is pulled directly from the example on the MOD11A1 data catalog page
var landSurfaceTemperatureVis = {
  min: 13000.0,
  max: 16500.0,
  palette: [
    '040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
    '0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
    '3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
    'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
    'ff0000', 'de0101', 'c21301', 'a71001', '911003'
  ],
};
Map.setCenter(6.746, 46.529, 2);
Map.addLayer(
    ds1_final.first(), landSurfaceTemperatureVis,
    'Land Surface Temperature');

Because I'm passing the geometry variable to the filterBounds() function, I would expect that the resulting Image/ImageCollection would be specific to that geometry. Yet when the first image is added to the map I see data for the entire Globe (I've circled my geometry polygon in red):
enter image description here

Why would all of this data be shown if I'm using the filterBounds() function with a small polygon when pulling the Image/ImageCollection? Assuming I'm not doing anything wrong with the code above, is there a straightforward way to pull an Image/ImageCollection that only contains pixels that overlap with the given polygon/geometry? Ultimately I want to download/extract x number of days worth of TIFFs for a given polygon, and I'd like to be able to properly visualize in the map to ensure that the TIFFs I'm downloading look correct (i.e. compare a downloaded TIFF in QGIS to the Image as it's shown directly in the GEE console/map).

Best Answer

ImageCollections are basically tables, with 1 row per image and a column per metadata property. Filter functions only remove rows from that table, they don't alter the contents. In this case, your images are global, so even if the filter only returns 1 image, it's still going to be global.

If you want to limit data to just a region, you use clip on the individual images (via a mapped function) after you've filtered them.

Related Question