يتم تعريف Feature
في Earth Engine على أنّه عنصر GeoJSON. على وجه التحديد،
يكون Feature
عنصرًا يتضمّن سمة geometry
تخزِّن Geometry
(أو قيمة فارغة) وسمة properties
تخزِّن قاموسًا لسمات أخرى.
إنشاء عناصر "العناصر الرئيسية"
لإنشاء Feature
، قدِّم لطريقة وضع التصميم Geometry
وقاموسًا (اختياريًا) للخصائص الأخرى. على سبيل المثال:
محرِّر الرموز البرمجية (JavaScript)
// Create an ee.Geometry. var polygon = ee.Geometry.Polygon([ [[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]] ]); // Create a Feature from the Geometry. var polyFeature = ee.Feature(polygon, {foo: 42, bar: 'tart'});
import ee import geemap.core as geemap
Colab (Python)
# Create an ee.Geometry. polygon = ee.Geometry.Polygon( [[[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]]] ) # Create a Feature from the Geometry. poly_feature = ee.Feature(polygon, {'foo': 42, 'bar': 'tart'})
كما هو الحال مع Geometry
، يمكن طباعة Feature
أو إضافته إلى
الخريطة للفحص والعرض:
محرِّر الرموز البرمجية (JavaScript)
print(polyFeature); Map.addLayer(polyFeature, {}, 'feature');
import ee import geemap.core as geemap
Colab (Python)
display(poly_feature) m = geemap.Map() m.add_layer(poly_feature, {}, 'feature') display(m)
لا يجب أن يتضمّن Feature
Geometry
، ويمكن أن يلفّ ببساطة
قائمة بخصائص. على سبيل المثال:
محرِّر الرموز البرمجية (JavaScript)
// Create a dictionary of properties, some of which may be computed values. var dict = {foo: ee.Number(8).add(88), bar: 'nihao'}; // Create a null geometry feature with the dictionary of properties. var nowhereFeature = ee.Feature(null, dict);
import ee import geemap.core as geemap
Colab (Python)
# Create a dictionary of properties, some of which may be computed values. dic = {'foo': ee.Number(8).add(88), 'bar': 'nihao'} # Create a null geometry feature with the dictionary of properties. nowhere_feature = ee.Feature(None, dic)
في هذا المثال، يُرجى العِلم أنّ القاموس الذي تم تقديمه إلى Feature
يحتوي على قيمة يتم احتسابها. إنّ إنشاء العناصر بهذه الطريقة مفيد لتصدير العمليات الحسابية التي تستغرق وقتًا طويلاً والتي تؤدي إلى نتيجة Dictionary
(مثل image.reduceRegion()
).
يمكنك الاطّلاع على FeatureCollections واستيراد بيانات الجدول أو التصدير للحصول على تفاصيل.
تحتوي كل سمة Feature
على سمة Geometry
أساسية واحدة يتم تخزينها في
geometry
. قد يتم تخزين أشكال هندسية إضافية في سمات أخرى.
تتوفّر أيضًا طرق Geometry
، مثل التداخل والمساحة المخفّضة، في
Feature
لتسهيل الحصول على Geometry
الأساسي،
وتطبيق العملية، وضبط النتيجة على أنّها Geometry
الأساسي الجديد.
ستحتفظ النتيجة بجميع السمات الأخرى لعنصر Feature
الذي يتم
استدعاء الطريقة عليه. هناك أيضًا طرق للحصول على سمات Feature
غير الهندسية وضبطها. على سبيل المثال:
محرِّر الرموز البرمجية (JavaScript)
// Make a feature and set some properties. var feature = ee.Feature(ee.Geometry.Point([-122.22599, 37.17605])) .set('genus', 'Sequoia').set('species', 'sempervirens'); // Get a property from the feature. var species = feature.get('species'); print(species); // Set a new property. feature = feature.set('presence', 1); // Overwrite the old properties with a new dictionary. var newDict = {genus: 'Brachyramphus', species: 'marmoratus'}; var feature = feature.set(newDict); // Check the result. print(feature);
import ee import geemap.core as geemap
Colab (Python)
# Make a feature and set some properties. feature = ( ee.Feature(ee.Geometry.Point([-122.22599, 37.17605])) .set('genus', 'Sequoia') .set('species', 'sempervirens') ) # Get a property from the feature. species = feature.get('species') display(species) # Set a new property. feature = feature.set('presence', 1) # Overwrite the old properties with a new dictionary. new_dic = {'genus': 'Brachyramphus', 'species': 'marmoratus'} feature = feature.set(new_dic) # Check the result. display(feature)
في المثال السابق، يُرجى العِلم أنّه يمكن ضبط السمات باستخدام زوج مفتاح/قيمة،
أو باستخدام قاموس. يُرجى العلم أيضًا أنّ السمة feature.set()
تلغي السمات الحالية.