I am trying to generate multiple buffers around a layer that represents cities (FeatureCollection). Use the following code to create the buffers: // Function to create buffers of different sizes in Google Earth Engine . The problem is that this code generates polygons that include the inside area. I need to generate buffers on the outside, like doughnuts or perimeter rings.
I tried to use .difference to remove the original polygons from the buffers but I get the error "....difference is not a function"
Can anyone help me?
var geometry =
/* color: #d63000 */
/* displayProperties: [
{
"type": "rectangle"
},
{
"type": "rectangle"
},
{
"type": "rectangle"
}
] */
ee.FeatureCollection(
[ee.Feature(
ee.Geometry.Polygon(
[[[-92.93044076036253, 43.38666530027385],
[-92.93044076036253, 43.371630789523294],
[-92.90812478135862, 43.371630789523294],
[-92.90812478135862, 43.38666530027385]]], null, false),
{
"system:index": "0"
}),
ee.Feature(
ee.Geometry.Polygon(
[[[-93.016614771593, 43.389328699363205],
[-93.016614771593, 43.36986507859759],
[-92.99155221055784, 43.36986507859759],
[-92.99155221055784, 43.389328699363205]]], null, false),
{
"system:index": "1"
}),
ee.Feature(
ee.Geometry.Polygon(
[[[-93.09137330125608, 43.39935439198635],
[-93.09137330125608, 43.38213974024519],
[-93.06734070848265, 43.38213974024519],
[-93.06734070848265, 43.39935439198635]]], null, false),
{
"system:index": "2"
})]);
var RingBuffer = function (Poligono, DistBuff) {
var BufferFeature = function(f) {
f = ee.Feature(f);
var buffer_size = f.get('buffer_size');
return f.buffer(buffer_size);
};
var BufferFeaturesByDistance = function (fc, buffer_size) {
var SetBufferSize = function(f) {
return f.set({'buffer_size': buffer_size});
};
return (Poligono).map(SetBufferSize).map(BufferFeature);
};
var Buffer = BufferFeaturesByDistance(Poligono, DistBuff)
return (Buffer).difference(Poligono)
};
var Buff1 = RingBuffer (geometry, 2000);
Map.addLayer(Buff1);
.difference()
and it didn't work?difference
should work for this purpose, and showing your code will let us figure out how to fix it for you.