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:


here is my code:

var image = l8.filterBounds(table)
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));


1 Answer 1


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.