2

I want to create a 10km buffer around mangrove patches from the mangrove forest raster. I've tried a number of approaches but can't get anything to work. I tried converting the raster to vector but at the resolution (30m) I need it is too big and the computation times out. I also tried to the focal.max tool but this seems to be dependent on the zoom level I'm using and therefore capture only certain patches

//import Mangroves of the World   
var MangroveImage = ee.ImageCollection('LANDSAT/MANGROVE_FORESTS') 

//select the image from the mangrove dataset 
var mangrove = ee.Image(MangroveImage.first());

//buffer around mangroves 
var mangrove_buffer = mangrove.focal_max({
radius: 10000,
kernelType: 'circle',
units:'meters',
iterations: 1
})
2

Unfortunately, the focal_max() and distance() methods are constrained to a kernel of 256 pixels, so you need to either increase the scale or decrease the buffer length. You can get an approximation using the cumulativeCost() (docs) method:

//import Mangroves of the World   
var MangroveImage = ee.ImageCollection('LANDSAT/MANGROVE_FORESTS');

//select the image from the mangrove dataset 
var mangrove = ee.Image(MangroveImage.first());
Map.addLayer(mangrove, {}, 'mangrove');

//buffer around mangroves 
var buffer = ee.Image(1)
    .cumulativeCost({
      source: mangrove, 
      maxDistance: 10000,
    }).lt(10000);

var params = {min: 0, max: 10000, palette: ['red']};
Map.addLayer(buffer.mask(buffer), params, 'mangrove_buffer');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.