1

I want to simply filter an Image Collection for a set of Spatial coordinates. However, the built-in Filterbounds function does not seem to work. I did try researching and the only answer I got to my question was that filterbounds does not work due to global coordinate system (Or I think this is what it means)

This is the code in which I was not able to make any further progress.

var roi = ee.Geometry.Polygon(
    [[[-107.416796875, 36.750944433035215],
      [-107.416796875, 34.53706063512119],
      [-102.934375, 34.53706063512119],
      [-102.934375, 36.750944433035215]]], null, false);


var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_NO2')
  .select('NO2_column_number_density')
  .filterDate('2019-06-01', '2019-06-06')
  .filterBounds(roi);
  


var band_viz = {
  min: 0,
  max: 0.0002,
  palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};

Map.addLayer(collection.mean(), band_viz, 'S5P N02');
Map.setCenter(65.27, 24.11, 4);

Can someone demonstrate how to filter spatially?

2 Answers 2

1

Jobbo90 is right, you could just do your mean first, then clip the image to your ROI.

However, if for some reason you are still interested in doing a "spatial filter" on the entire collection, use .map(function(image){return image.clip(roi)}) instead of filterBounds(). I've attached an improved version of your code below.

Note: your Map.setCenter() coordinates did not center on your roi, so I change that for you too.

var roi = ee.Geometry.Polygon(
    [[[-107.416796875, 36.750944433035215],
      [-107.416796875, 34.53706063512119],
      [-102.934375, 34.53706063512119],
      [-102.934375, 36.750944433035215]]], null, false);
    
Map.addLayer(roi)

Map.centerObject(roi,6)

var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_NO2')
  .select('NO2_column_number_density')
  .filterDate('2019-06-01', '2019-06-06')
  .map(function(image){return image.clip(roi)});

var band_viz = {
  min: 0,
  max: 0.0002,
  palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};

Map.addLayer(collection.mean(), band_viz, 'S5P N02');
0

The Sentinel 5 dataset seems to hold all observations from 1 orbit:

From the data description (link):

The OFFL assets contain data from a single orbit (which, due to half the earth being dark, contains data only for a single hemisphere).

So 'filtering' spatially as you call it doesn't make any sense. You could apply a clip if you just want the area you are interested in:

Map.addLayer(collection.mean().clip(roi), band_viz, 'S5P N02');

https://code.earthengine.google.com/0978414864437a84281bdfb1802cc3fd

Your Answer

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

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