ee.Feature.buffer

Devuelve la entrada almacenada en búfer según una distancia determinada. Si la distancia es positiva, la geometría se expande, y si es negativa, se contrae.

UsoMuestra
Feature.buffer(distance, maxError, proj)Función
ArgumentoTipoDetalles
esta: featureElementoEs el atributo cuya geometría se está almacenando en búfer.
distanceNúmero de punto flotanteEs la distancia del búfer, que puede ser negativa. Si no se especifica ninguna proyección, la unidad es metros. De lo contrario, la unidad se encuentra en el sistema de coordenadas de la proyección.
maxErrorErrorMargin, valor predeterminado: nullEs la cantidad máxima de error que se tolera al aproximar el círculo de almacenamiento en búfer y realizar cualquier reproyección necesaria. Si no se especifica, el valor predeterminado es el 1% de la distancia.
projProyección, valor predeterminado: nuloSi se especifica, el almacenamiento en búfer se realizará en esta proyección, y la distancia se interpretará como unidades del sistema de coordenadas de esta proyección. De lo contrario, la distancia se interpreta como metros y el almacenamiento en búfer se realiza en un sistema de coordenadas esféricas.

Ejemplos

Editor de código (JavaScript)

// Polygon feature of Serengeti National Park.
var feature = ee.FeatureCollection('WCMC/WDPA/202307/polygons')
                  .filter('ORIG_NAME == "Serengeti National Park"')
                  .first();

// Cast the resulting object as an ee.Feature so that the call to the buffer
// method is unambiguous (first() and buffer() are shared by multiple classes).
feature = ee.Feature(feature);

// Generate buffered features out and in from the original boundary.
var bufferOut = feature.buffer(10000);  // 10 km out
var bufferIn = feature.buffer(-10000);  // 10 km in

// Display the features on the map.
Map.addLayer(bufferOut, {color: 'red'}, 'Buffer out');
Map.addLayer(feature, {color: 'blue'}, 'No buffer');
Map.addLayer(bufferIn, {color: 'yellow'}, 'Buffer in');
Map.setCenter(34.8407, -2.398, 8);

Configuración de Python

Consulta la página Entorno de Python para obtener información sobre la API de Python y el uso de geemap para el desarrollo interactivo.

import ee
import geemap.core as geemap

Colab (Python)

# Polygon feature of Serengeti National Park.
feature = (
    ee.FeatureCollection('WCMC/WDPA/202307/polygons')
    .filter('ORIG_NAME == "Serengeti National Park"')
    .first()
)

# Cast the resulting object as an ee.Feature so that the call to the buffer
# method is unambiguous (first() and buffer() are shared by multiple classes).
feature = ee.Feature(feature)

# Generate buffered features out and in from the original boundary.
buffer_out = feature.buffer(10000)  # 10 km out
buffer_in = feature.buffer(-10000)  # 10 km in

# Display the features on the map.
m = geemap.Map()
m.add_layer(buffer_out, {'color': 'red'}, 'Buffer out')
m.add_layer(feature, {'color': 'blue'}, 'No buffer')
m.add_layer(buffer_in, {'color': 'yellow'}, 'Buffer in')
m.set_center(34.8407, -2.398, 8)
m