0

I have to filter dates for the working days of the month: "January 2020" and then I have to find the mean value of the working days.

 var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_NO2')
    .select('tropospheric_NO2_column_number_density')
    .filterDate('2020-01-01', '2020-01-03');

How can I make the code for this?

1
  • 1
    Welcome to GIS SE! We're a little different from other sites. We're a Q&A site, not a discussion forum. For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely. Please check out our short tour for more about how the site works. Thanks.
    – PolyGeo
    Feb 9, 2021 at 5:31

1 Answer 1

0

You can use ee.Filter.calendarRange(1, 5, 'day_of_week') to only include Monday to Friday. To calculate mean, you simply call mean() on the collection

https://code.earthengine.google.com/5bf9ec3c33a9fa557b7d5ba8dc0e74bf

var aoi = ee.Geometry.Point([0, 10]).buffer(1000)
var collection = ee.ImageCollection('COPERNICUS/S2')
  .filterBounds(aoi)
  .filterDate('2020-01-01', '2020-02-01') // Only January 2020
  .filter(ee.Filter.calendarRange(1, 5, 'day_of_week')) // Only workdays

var mean = collection
  .mean()
  .clip(aoi)
  
Map.addLayer(mean, {bands: 'B4,B3,B2', min: 500, max: 3000})
Map.centerObject(mean)

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.