ee.Feature.buffer

แสดงผลอินพุตที่บัฟเฟอร์ตามระยะทางที่กำหนด หากระยะทางเป็นบวก ระบบจะขยายเรขาคณิต และหากระยะทางเป็นลบ ระบบจะย่อเรขาคณิต

การใช้งานการคืนสินค้า
Feature.buffer(distance, maxError, proj)ฟีเจอร์
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ featureองค์ประกอบฟีเจอร์ที่มีการบัฟเฟอร์เรขาคณิต
distanceทศนิยมระยะห่างของการบัฟเฟอร์ ซึ่งอาจเป็นค่าลบ หากไม่ได้ระบุการฉายภาพ หน่วยจะเป็นเมตร มิฉะนั้น หน่วยจะเป็นระบบพิกัดของการฉาย
maxErrorErrorMargin, ค่าเริ่มต้น: nullปริมาณข้อผิดพลาดสูงสุดที่ยอมรับได้เมื่อประมาณวงกลมการบัฟเฟอร์และทำการฉายซ้ำที่จำเป็น หากไม่ได้ระบุไว้ ระบบจะใช้ 1% ของระยะทางเป็นค่าเริ่มต้น
projการฉายภาพ ค่าเริ่มต้น: nullหากระบุ ระบบจะทำการบัฟเฟอร์ในการฉายภาพนี้ และจะตีความระยะทางเป็นหน่วยของระบบพิกัดของการฉายภาพนี้ มิฉะนั้น ระบบจะตีความระยะทางเป็นเมตรและทำการบัฟเฟอร์ในระบบพิกัดทรงกลม

ตัวอย่าง

โปรแกรมแก้ไขโค้ด (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);

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า สภาพแวดล้อม Python

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