0

I took two datasets - WorldCover 2020 for builtup (100m), and MODIS for LST (1km), and clipped them to a predefined geometry.

I then aggregated the builtup data to 1km resolution as given here.

Then I defined a threshold of 100,000 for the builtup and masked out the corresponding values for the LST image.


The problem is that after performing reduceRegion operation on this masked LST image, using a combined reducer, the values are shown as NULL.

What could I be doing wrong?


Following is the code:

var buffer = 
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[77.3771407683881, 13.160658695038297],
          [77.3771407683881, 12.795327445635392],
          [77.78500820002873, 12.795327445635392],
          [77.78500820002873, 13.160658695038297]]], null, false);



/* ----  Builtup image (WorldCover 2020) ---- */

var builtup = ee.ImageCollection('ESA/WorldCover/v100')
              .first()
              .clip(buffer);

// Show only the builtup class
var mask = builtup.eq(50)

builtup = builtup.updateMask(mask)


var projection = ee.Image(builtup).projection()

print(projection.nominalScale())

// Get the projection at required scale
var projectionAt100m = projection.atScale(100)
var projectionAt1k = projection.atScale(1000)
 
// Step1: 10m to 100m
var builtupAt100m = builtup
  .reduceResolution({
    reducer: ee.Reducer.sum().unweighted(),
    maxPixels: 1024
  })
  // Request the data at the scale and projection
  // of reduced resolution
  .reproject({
    crs: projectionAt100m
  });
  
// Step2: 100m to 1000m
var builtupAt1k = builtupAt100m
  .reduceResolution({
    reducer: ee.Reducer.sum().unweighted(),
    maxPixels: 1024
  })
  // Request the data at the scale and projection
  // of reduced resolution
  .reproject({
    crs: projectionAt1k
  });




/* ----  Land surface Temperature image (MODIS) ---- */


function applyScaleFactors(img){
    
    img = img.multiply(0.02).subtract(273.15)
          .copyProperties(img, ['system:time_start','system:time_end','system:index'])
  
    return img

}

var lst = ee.ImageCollection('MODIS/061/MOD11A1')
          .select('LST_Day_1km')
          .filter(ee.Filter.date('2020-03-01', '2020-05-31'))
          .map(applyScaleFactors)
          .mean()
          .clip(buffer);
          
var mask_gte = builtupAt1k.gte(100000)
var mask_lt = builtupAt1k.lt(100000)

var masked_lst_gte = lst.updateMask(mask_gte)
var masked_lst_lt = lst.updateMask(mask_lt)


var reducers = ee.Reducer.mean().combine({
  reducer2: ee.Reducer.max(),
  sharedInputs: true
}).combine({
  reducer2: ee.Reducer.percentile([95]),
  sharedInputs: true
});


var reduced_lst_gte = masked_lst_gte.reduceRegion({
                        reducer: reducers
                      })

var reduced_lst_lt = masked_lst_lt.reduceRegion({
                        reducer: reducers
                     })
                
print('reducer for >= threshold', reduced_lst_gte)
print('reducer for < threshold', reduced_lst_lt)

The outputs for the last two print functions are as shown below:

enter image description here

1 Answer 1

0

Specifying geometry, scale and crs in the reduceRegion function as parameters seems to work

https://code.earthengine.google.com/86abce24e3b171bfb9e5fa22e6f4d06b

3
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jun 13 at 20:23
  • These extra parameters totally skipped my mind. Thanks a lot!
    – Anjishnu
    Commented Jun 14 at 9:48
  • @Anjishnu happy to help!
    – aeaturu
    Commented Jun 18 at 17:04

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.