ee.Feature.buffer

Restituisce l'input memorizzato nel buffer in base a una distanza specificata. Se la distanza è positiva, la geometria viene espansa, mentre se è negativa, viene contratta.

UtilizzoResi
Feature.buffer(distance, maxError, proj)Funzionalità
ArgomentoTipoDettagli
questo: featureElementoLa funzionalità di cui viene eseguito il buffering della geometria.
distanceFloatLa distanza del buffering, che può essere negativa. Se non viene specificata alcuna proiezione, l'unità è metri. In caso contrario, l'unità si trova nel sistema di coordinate della proiezione.
maxErrorErrorMargin, valore predefinito: nullLa quantità massima di errore tollerata durante l'approssimazione del cerchio di buffering e l'esecuzione di qualsiasi riproiezione necessaria. Se non specificato, il valore predefinito è l'1% della distanza.
projProiezione, valore predefinito: nullSe specificato, il buffering verrà eseguito in questa proiezione e la distanza verrà interpretata come unità del sistema di coordinate di questa proiezione. In caso contrario, la distanza viene interpretata come metri e il buffering viene eseguito in un sistema di coordinate sferiche.

Esempi

Editor di codice (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);

Configurazione di Python

Consulta la pagina Ambiente Python per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo.

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