1

I'm using the below code to create NO2(Sentinel-5p) time series charts for my region of interest by mean reduction. However, upon charting, I get an error message

Error generating chart: No features contain non-null values of "system:time_start"

Please, somebody advise me how to fix this error?

Here is my code:

    var geometry = 
        /* color: #d63000 */
        /* displayProperties: [
          {
            "type": "rectangle"
          }
        ] */
        ee.Geometry.Polygon(
            [[[112.19326448481443, 37.22101939910812],
              [112.19326448481443, 36.467942373936516],
              [113.19250536005858, 36.467942373936516],
              [113.19250536005858, 37.22101939910812]]], null, false),
    
    
    // Create a FeatureCollection from the list and print it.
    var geometry = ee.FeatureCollection(geometry);
    print(geometry);
    Map.centerObject(geometry);
    Map.addLayer(geometry);
    
//Importing image and geometry:
    var collection = ee.ImageCollection('COPERNICUS/S5P/NRTI/L3_NO2')
      .select('NO2_column_number_density')
      .filterDate('2019-01-01', '2019-01-28')
      .filterBounds(geometry);
    
    // calculation mol/m^2 to ton/m^2.  
    var mol_to_ton = collection.map(function (image) {
      return image.multiply(0.000046);
    });
    
    
    //Visualization parameters
    var band_viz = {
      min: 0,
      max: 0.00000002,
      palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
    };
    
    
    Map.addLayer(mol_to_ton.mean(), band_viz, 'S5P N02_ton');
    
    // Create and print the chart.
    print(ui.Chart.image.series(mol_to_ton.mean(), geometry, ee.Reducer.mean(), 1113, 'system:time_start'));

1 Answer 1

1

There are 2 things:

  1. ui.Chart.image.series takes an ImageCollection as first argument (https://developers.google.com/earth-engine/apidocs/ui-chart-image-series) and you are passing an image (mol_to_ton.mean())
  2. When you perform a mathematical operation over an Image it "looses" its properties, so you have to add them again.

I will write here the relevant changes, and will paste a link to the complete working code.

// calculation mol/m^2 to ton/m^2.  
var mol_to_ton = collection.map(function (image) {
  return image.multiply(0.000046).set('system:time_start', image.date().millis());
});

and

print(ui.Chart.image.series(mol_to_ton, geometry, ee.Reducer.mean(), 1113, 'system:time_start'));

https://code.earthengine.google.com/034d11cb81b3d46d81f2466188ac528e

1
  • Thank you for help
    – Zara
    Jan 25, 2021 at 19:51

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.