04 April 2025 0 8K Report

I want to compute MNDWI, Water ratio index (WRI), NDBI (normalized difference built up index), Modified bare soil index (MBI), Bare soil index (BSI) from Sentinel-2 images in GEE. Before, computing those indices, I want to resample the 20m to 10m. So, can you recommend which algorithm is better for image resampling?

Can you give some correction my code?

Here is the sample code that I used to resample 20m to 10m in GEE.

// Image resampling (20 m to 10 m)

var ImageBands10m = ['B2', 'B3', 'B4','B8'];// 10 m bands

var ImageBands20m = ['B5', 'B6', 'B7', 'B8A', 'B11', 'B12'];// // 20 m bands

var bands = ImageBands10m.concat(ImageBands20m); // Combine for final selection

// Function to resample and reproject 20m bands to 10m

var SentResaTo10m = function(sent2CloudMasked) {

var bands20m = sent2CloudMasked.select(ImageBands20m)

.resample('bilinear')

.reproject({

crs: sent2CloudMasked.select('B2').projection().crs(), // Use consistent band projection

scale: 10

});

var bands10m = sent2CloudMasked.select(ImageBands10m);

return bands10m.addBands(bands20m).copyProperties(sent2CloudMasked, sent2CloudMasked.propertyNames());

};

// Apply the resampling function to each image in the collection

var Sent_2Resampled = sent2CloudMasked

.map(SentResaTo10m); // Apply resampling

// Computing the image composite based on the median

var CompositeImage = Sent_2Resampled.median().select(bands).clip(AOI);

//visualizating true and fale color composite of the image

var visParamsTrue= {bands:['B4','B3','B2'], min:0, max:3000, gama:1.1};

var fals= {bands:['B8','B4','B3'], min:0, max:3000, gama:1.1};

Map.centerObject(AOI, 8);

//Map.addLayer(CompositeImage,visParamsTrue,"sentinel2 2025T");

Map.addLayer(CompositeImage,fals,"sentinel2 2025F");

print(CompositeImage.bandNames());

More Abel Balew's questions See All
Similar questions and discussions