0

I am trying to calculate the NDVI using the Google Earth engine. my area of interest is not covered in one scene so I need to mosaic the required bands. but the mosaic function does not work when I define a specific date although it seems to work without a date.

here is a link to my code:

https://code.earthengine.google.com/a464f6f1f43748ee42721c2447141615

here is my code:

var image = l8.filterBounds(table)
           .filterMetadata('CLOUD_COVER','less_than',1)
           .filterDate('2023-05-1','2023-08-30');
var RED = image.select('B4');
var NIR = image.select('B5');
var mosaic_red = RED.mosaic();
var mosaic_nir = NIR.mosaic();

 var NDVI = mosaic_nir.subtract(mosaic_red).divide(mosaic_nir.add(mosaic_red));

Map.addLayer(NDVI);
Map.centerObject(table,8);

1 Answer 1

0

I cannot run your code since you didn't share your asset. You also didn't specify in what way this fails. I have to do some guesswork.

Perhaps you filtered down the collection so you didn't have any imagery left. At that point, when calling mosaic(), you get an image without bands, leading to NDVI without bands.

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.