ee.Feature.buffer

Menampilkan input yang di-buffer berdasarkan jarak tertentu. Jika jaraknya positif, geometri akan diperluas, dan jika jaraknya negatif, geometri akan dikontrak.

PenggunaanHasil
Feature.buffer(distance, maxError, proj)Fitur
ArgumenJenisDetail
this: featureElemenFitur yang geometrinya sedang di-buffer.
distanceFloatJarak buffering, yang mungkin negatif. Jika tidak ada proyeksi yang ditentukan, unitnya adalah meter. Jika tidak, unitnya berada dalam sistem koordinat proyeksi.
maxErrorErrorMargin, default: nullJumlah maksimum error yang ditoleransi saat memperkirakan lingkaran buffering dan melakukan proyeksi ulang yang diperlukan. Jika tidak ditentukan, defaultnya adalah 1% dari jarak.
projProjection, default: nullJika ditentukan, buffering akan dilakukan dalam proyeksi ini dan jarak akan ditafsirkan sebagai unit sistem koordinat proyeksi ini. Jika tidak, jarak akan ditafsirkan sebagai meter dan buffering dilakukan dalam sistem koordinat bola.

Contoh

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

Penyiapan Python

Baca halaman Lingkungan Python untuk mengetahui informasi tentang Python API dan penggunaan geemap untuk pengembangan interaktif.

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