Getting statistical Sentinel-5P data

Hello, I am trying to obtain average CO (Carbon Monoxide) air pollution at a specified place using sentinelhub-py module. I have the following evalscript:

//VERSION=3

function setup() {
  return {
    input: [{
      bands: ['CO', 'dataMask']
    }],
    output: [
      {
        id: 'output_co',
        bands: 1
      },
      {
        id: 'dataMask',
        bands: 1
      }
    ]
  };
}

function evaluatePixel(sample) {
  return {
      output_co: [sample.CO],
      dataMask: [sample.dataMask]
  }
}

It works, but it returns the exact same data for every location I specify as bbox.
Is my evalscript incorrect?

Hi @fordon.grzegorz ,

Could you please provide the request body which returns the exact same data for different locations? Thank you.

Hi @chung.horng,

Thanks for your reply. The code I am using is:

def get_air_pollution_data(self, coordinates, time_from, time_to):
    aggregation = SentinelHubStatistical.aggregation(
        evalscript=EVALSCRIPT,
        time_interval=(time_from, time_to),
        aggregation_interval='P1D',
        size=(631, 1047)
    )

    input_data=[SentinelHubStatistical.input_data(DataCollection.SENTINEL5P, 
    maxcc=0.8)]

    bbox = BBox(coordinates, CRS.POP_WEB)
    request = SentinelHubStatistical(
    aggregation=aggregation,
    input_data=input_data,
    bbox=bbox,
    config=self._config
    )

    return request.get_data()

Hi @fordon.grzegorz ,

It might be the CRS issue. I noticed that your coordinates were in WGS84, but you specified POP_WEB in your BBox class.

Hi @chung.horng ,

Thanks for the advice. However, I am working with coordinates coming from Google Maps (Geocoding API overview  |  Google for Developers). So, I guess I am supposed to use POP_WEB for this. Am I wrong?

Hi @fordon.grzegorz ,

It was not about the Geocoding API, but the request you sent to the Statistical API. The coordinates used in the BBox class was defined in (latitude, longitude), which was not aligned to POP_WEB.

In short, when you define a bounding box using BBox like BBox(coordinates, CRS.POP_WEB), the coordinates should be in the crs defined later as CRS.POP_WEB. In this case, either you use (longitude, latitude) with CRS.WGS84 or coordinates defined in Popular Web Mercator with CRS.POP_WEB.

Thanks for your clarification @chung.horng . So, if I want to get the statistics for Los Angeles which has a bounding box (according to Google maps):

    latitude_min: 33.703652
    longitude_min: -118.668176
    latitude_max: 34.337306
    longitude_max: -118.155289

The correct way to implement a BBox would be:

    bbox = BBox((-118.668176, 33.703652, -118.155289, 34.337306), CRS.WGS84)

Am I correct?

Hi @fordon.grzegorz ,

Yes, correct.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.