Overlapping Area Calculation with Statistical API and Data Fusion

Hello everyone,

I was wondering if it is possible to retrieve the intersecting/overlapping area between Sentinel-5p CO data and a shared byoc layer using data fusion from the statistical API request?

My goal is to calculate the area of a shared byoc population density layer that is affected by CO emissions in the chosen AOI.

Maybe you are aware of a similar use case or example that can help me?

This is the evalscript for the byoc layer where I already filtered out areas that are not populated:

//VERSION=3
function setup() {
  return {
    input: [{
      bands: ["BUILT", "dataMask"], // this sets which bands to use
    }],
    output: [
      { id:"default", bands: 1, sampleType: "FLOAT32" },
      { id: "dataMask", bands: 1 }
    ]
  };
}
 


function evaluatePixel(sample) {
    let pixelMask = 1
    
    if (sample.BUILT == 0){
        pixelMask = 0
    }
  return {
    default: [sample.BUILT],
    dataMask: [sample.dataMask * pixelMask]
  };
}

Hi @s6lestur ,

According to your description, I guess you’re trying obtain the statistics of S5P CO data where pixels are identified as built areas in your BYOC layer. This can be done by setting the dataMask properly. Please have a look at this example which shows a request of statistics of NDVI using Sentinel-2 L2A as the source of NDVI and Sentinel-1 GRD VV channel as the mask of water bodies.

In your case, the Evalscript would be something like below:

function setup() {
  return {
    input: [{
        datasource: "population",
        bands: ["BUILT", "dataMask"]
      }, {
        datasource: "s5p",
        bands: ["CO", "dataMask"]
      }
    ],
    output: [
      {
        id: "co", bands: 1
      },
      {
        id: "dataMask", bands: 1
      }
    ]
  }
}

function evaluatePixel(sample) {
  const population = sample.population[0];
  const s5p = sample.s5p[0];
  let pixelMask = 1;
  if (population.BUILT === 0) {
    pixelMask = 0;
  }
  return {
    co: [s5p.CO],
    dataMask: [population.dataMask * s5p.dataMask * pixelMask]
  }
}

Hi @chung.horng,

Thank very much for your quick response! Now the statistical request works fine.
However, I am encountering issues with the time range of my layer:
The population layer has only one time stamp (2020-01-01) which represents the population density for the whole year. But my goal is to calculate statistics for a later time period during the year and right now I can only see statistics for this exact day. Therefore, I wanted to ask if it is possible to change the time dimension of the byoc population layer in any way? Or if you may have another idea to work around this problem?

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