सुविधा के बारे में खास जानकारी

Earth Engine में Feature को 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'});

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

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');

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

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);

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

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);

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

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() मौजूदा प्रॉपर्टी को बदल देता है.