1

What is the best practice for the scale parameters in google earth engine?

Similar concerns had been also discussed in some of the previous threads, however, none of the solutions discussed regarding the do & don't for the scale parameter.

  1. Understanding Scale in Earth Engine
  2. What does it mean by scale in reduceRegion function in Google Earth Engine
  3. Google EarthEngine scale definition and export

For example, I am playing around with FIRMS hotspot dataset (1km spatial resolution).

Using the scale=1000, the number of count is equal to 3498.

var firms_toBands = dataset.toBands()
var firms_count = firms_toBands.reduceRegion(
        ee.Reducer.count(),
        AUS,
        1000
)
print(firms_count)

Default scale, number of counts = 4583

var firms_count = firms_toBands.reduceRegion(
        ee.Reducer.count(),
        AUS
)
print(firms_count)

In this scenario, which is more preferable, the default scale or the scale=1000?

A sample of the code: https://code.earthengine.google.com/32832056c76ae6109fac14a4caa2f67a

Note: The same applies to ui.chart.image.doySeriesbyYear

1 Answer 1

1

If the goal is to match the intended computation scale and the native pixel resolution as implied in the Earth Engine scale documentation, one can determine the scale from the input image by checking its native pixel resolution using .projection().nominalScale()

In the case of your example, the native resolution is ~926.6 Not 1000, and this is probably the reason behind the different outcomes

Taking a simplified version of your example, one can see how determining the scale as 1000 instead of the native resolution could go wrong for counting four pixels

As an attempt to examine one possible way of how the counting went wrong (I stand to be corrected if the computation behave in the same way), one can create two grids by setting the scale; once to be determined by the image projection by default, and then to be forced as 1000. In the case of 1000, the grid alignment seems to be centered leaving pixel fractions all around the covered pixel!

enter image description here

   // testing polygon
var AUS = ee.Geometry.Polygon([[[143.46647287429622,-19.542272752714126]
,[143.49968935073665,-19.542272752714126]
,[143.49968935073665,-19.524557657732945]
,[143.46647287429622,-19.524557657732945]
,[143.46647287429622,-19.542272752714126]]]);

Map.addLayer(AUS,{},'testing polygon', 0)
Map.centerObject(AUS);

// Adding data
var dataset = ee.ImageCollection('FIRMS').select('T21').filterDate('2019-01-01', '2019-01-02');
var firms_toBands = dataset.toBands()

var Vis = {min: 50,max: 200,palette: ['b27b18', 'red']};
Map.addLayer(firms_toBands,Vis,'firms_toBands')


// Get projection and actual scale
print('crs', firms_toBands.projection());
print('Image Scale', firms_toBands.projection().nominalScale());

// pixel count for 1000, defaut and actual scale
var CountPx = function(scale){
              var count = firms_toBands.reduceRegion({
               geometry: AUS,
               reducer: ee.Reducer.count(),
               scale: scale});
  return count.get((firms_toBands.bandNames()).get(0))};

print('defined scale = 1000', CountPx(1000))
print('default scale', CountPx())
print('actual band scale = ~926.6', CountPx(firms_toBands.projection().nominalScale()))


// using the image projection to make  grids:
// 1. defined scale 1000 
var Definedgrid = (ee.Feature(AUS)).geometry().coveringGrid(firms_toBands.projection(),1000);
Map.addLayer(Definedgrid,{},'Definedgrid 1000m',0)
// 2. default (scale determined from projection)
var Defaultgrid = (ee.Feature(AUS)).geometry().coveringGrid(firms_toBands.projection());
Map.addLayer(Defaultgrid,{},'Defaultgrid')

Link for the code

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.