I am trying to create a function in Google Earth Engine which would iterate through an ImageCollection consisting of DEMs and return a message saying when a big elevation difference occurs. I believe I am not far from the answer, but I can't manage to make it work.
To what I understand, when you subtract one image from another it does so on pixel-by-pixel basis and returns an image. If you want elevation changes at a specific point, a geometic point can be defined. But what if you want the elevation difference to be calculated on the whole DEM and if at any location a big elevation change occurs, the function detects it? Do you need to explicitly define the region of interests, even though the DEMs themselves act as roi?
Script:
function anomaly(image) {
// Converting the ImageCollection ''newdems'' to list
var Imagelist = newdems.toList(newdems.size());
// Defining the previous image
var previous = ee.Image(Imagelist.get(-1));
// Equation to calculate the elevation difference
var difference = image.subtract(previous);
// Conditional statement to return the name of the image after which the big elevation change occurs
return ee.Algorithms.If(difference.gt(150),print('Anomaly occurs after: ', previous),ee.Image(0));
};
newdems
image collection and the region of interest geometry rather than just the function.