I want to calculate the total yearly NO2 emission from the power plants by using Sentinel-5p NO2 data. First I defined my aoi and sum all 365 images into one image using ee.Reducer.sum(). After that reduceRegion (with sum reducer) to find the total yearly sum of no2 of my aoi. But this picks a lot of noise from other emission sources like transport.

For avoiding those, I have planned to use Weighted Reductions. I want to use weight in reduceRegion in a way where pixels away from power plants will receive less weight and higher weight to nearest pixels to power plants.

From the documentation, we can see how to calculate weights for clouds ( the more cloud, the less weight each pixel will get ). But how do I calculate weights in my case where each pixel will receive weights according to distances to nearest power plants.

1 Answer 1


ee.FeatureCollection.distance produces an image where pixel values represent the distance to the nearest point. You can convert this image into a linear weight from 0 to 1.

// Mock up a feature collection.
var fc = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([-120.831, 37.119])),
  ee.Feature(ee.Geometry.Point([-120.193, 37.029])),
  ee.Feature(ee.Geometry.Point([-121.119, 36.803])),
  ee.Feature(ee.Geometry.Point([-121.130, 36.539])),
  ee.Feature(ee.Geometry.Point([-119.872, 36.525])),
  ee.Feature(ee.Geometry.Point([-120.432, 36.807]))

// Set maximum distance to consider.
var maxDist = 1e5; // Meters

// Calculate pixel distance to nearest point.
var distance = fc.distance({searchRadius: maxDist, maxError: 10});

// Convert distance to linear weight between 0 and 1.
var weight = distance.subtract(maxDist).abs().divide(maxDist);

// Display the distance and weight images.
Map.centerObject(fc, 9);
Map.addLayer(distance, {min:0, max: maxDist}, 'Meters');
Map.addLayer(weight, {min:0, max: 1}, 'Weight');
Map.addLayer(fc, {color: 'red'}, 'Points');

Code Editor script

enter image description here

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.