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 للحصول على معلومات حول واجهة برمجة التطبيقات Python واستخدام geemap للتطوير التفاعلي.

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