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: