Google Earth Engine – Filter DEM Image Collection for Elevation Band Value Greater Than 0 to Show Land Only

demelevationfiltergoogle-earth-enginevisualisation

I'm trying to display only the land areas of a DEM image collection, by filtering the image collection for values greater than 0. I am not sure how to write the arguments properly. There is only 1 band in my image collection, that is elevation, 'b1'.

var land = dtm.filter(ee.Filter.greaterThan('b1', 0));
Map.addLayer(land, {min: 0, max: 2400, palette: ['000FFF', '57874d', 'e2dba7', 'fcc573', 'b69c8d', 'ffffff']}, 'dtm');
 

Best Answer

Ok I have solved this! I defined a function to mask out the water, then mapped it over the image collection. This gives a pretty good representation of the land-sea boundary.

//////////////// DEFINE FUNCTION ////////////////
  // Function to mask out water
  var S2maskedWater = function(image) {
   var land = image.select(['b1']);
    return image.updateMask(land.gt(0)).rename('land');
  };

//////////////// APPLY FUNCTION TO THE IMAGE COLLECTION ////////////////
// Apply water masking functions to image collection
var dtm_land = dtm.map(S2maskedWater);
print(dtm_land)


//////////////// USER INTERFACE ////////////////
Map.addLayer(dtm_land, {min: 0.1, max: 1600, palette: ['57874d', 'e2dba7', 'fcc573', 'b69c8d', 'ffffff']}, 'dtm');

enter image description here

Related Question