I'm collecting Sentinel-5p tropospheric SO2 column data. I want to remove negative SO2 band values from my collection. How do I achieve this?

Here is my code:

// define a 'collection' of images
var collection = ee.ImageCollection('COPERNICUS/S5P/NRTI/L3_SO2')


.filterDate('2018-05-01', '2021-05-31')

.filterMetadata("SO2_column_number_density", 'less_than', 0);

// print(collection)
// var col=collection.values.filter(ee.Filter.notNull(['SO2_column_number_density']))


var no2Image = collection.mean(); // mean across each period
print('NO2 image', no2Image); // debug info in console
var band_viz = {
min: 0,
max: 0.0002,
opacity: 0.45,
palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
// The region of interest - a planar rectangle around London/S.England.
var rect = table

Map.setOptions('hybrid'); // set map to hybrid backdrop
Map.centerObject(rect, 7); // zoom in to the defined area
Map.addLayer(no2Image, band_viz, 'Sentinel 5P NRT N02 - Nov 2019');

// Create a task that you can launch from the Tasks tab.
// commented out here - but saves off geoTIFF files
image: no2Image.clip(rect),
description: 'SO2_red_sea_december',
folder: 'GEE',
fileNamePrefix: 'SO2_change',
region: rect,
fileFormat: 'GEOTIFF',
scale: 1000


1 Answer 1


SO2_column_number_density is a band and not an image property. Image properties are metadata related to the whole image (such as date of acquisition) and not pixel-specific. To remove pixels that have a negative SO2_column_number_density, you may mask them out using


The above line keeps those pixels in an image that are greater than or equal to zero.

Finally, to apply the above function to every image in an image collection, you can use the .map() function in earth engine:

.map(function(image){return image.updateMask(image.gte(0))})

Bringing it all together, here is the complete code.

And here is the result

enter image description here

  • Thanks a lot! It worked
    – Al-Iqram
    Mar 9, 2021 at 6:51

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.