ee.FeatureCollection.randomColumn

किसी कलेक्शन में, डेटरमिनिस्टिक स्यूडोरैंडम नंबर का कॉलम जोड़ता है. आउटपुट, डबल-प्रिसिशन फ़्लोटिंग पॉइंट नंबर होते हैं. 'यूनिफ़ॉर्म' डिस्ट्रिब्यूशन (डिफ़ॉल्ट) का इस्तेमाल करने पर, आउटपुट [0, 1] की रेंज में होते हैं. 'सामान्य' डिस्ट्रिब्यूशन का इस्तेमाल करने पर, आउटपुट में μ=0, σ=1 होता है. हालांकि, इनकी कोई तय सीमा नहीं होती.

इस्तेमालरिटर्न
FeatureCollection.randomColumn(columnName, seed, distribution, rowKeys)FeatureCollection
आर्ग्यूमेंटटाइपविवरण
यह: collectionFeatureCollectionवह इनपुट कलेक्शन जिसमें कोई रैंडम कॉलम जोड़ना है.
columnNameस्ट्रिंग, डिफ़ॉल्ट: "random"जोड़ने के लिए कॉलम का नाम.
seedलंबी, डिफ़ॉल्ट: 0रैंडम नंबर जनरेट करते समय इस्तेमाल किया जाने वाला सीड.
distributionस्ट्रिंग, डिफ़ॉल्ट: "uniform"रैंडम नंबर जनरेट करने के लिए, डिस्ट्रिब्यूशन का टाइप; 'यूनिफ़ॉर्म' या 'नॉर्मल' में से कोई एक.
rowKeysसूची, ज़रूरी नहींऐसी प्रॉपर्टी की सूची जो कलेक्शन के किसी एलिमेंट की पहचान, यूनीक और बार-बार करने में सक्षम होनी चाहिए. इसका इस्तेमाल, रैंडम नंबर जनरेट करने के लिए किया जाता है. डिफ़ॉल्ट रूप से, [system:index] पर सेट होता है.

उदाहरण

कोड एडिटर (JavaScript)

// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
            .filter('country_lg == "Belgium"');
print('N features in collection', fc.size());

// Add a uniform distribution random value column to the FeatureCollection.
fc = fc.randomColumn();

// Randomly split the collection into two sets, 30% and 70% of the total.
var randomSample30 = fc.filter('random < 0.3');
print('N features in 30% sample', randomSample30.size());

var randomSample70 = fc.filter('random >= 0.3');
print('N features in 70% sample', randomSample70.size());

Python सेटअप

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

import ee
import geemap.core as geemap

Colab (Python)

# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
    'country_lg == "Belgium"')
print('N features in collection:', fc.size().getInfo())

# Add a uniform distribution random value column to the FeatureCollection.
fc = fc.randomColumn()

# Randomly split the collection into two sets, 30% and 70% of the total.
random_sample_30 = fc.filter('random < 0.3')
print('N features in 30% sample:', random_sample_30.size().getInfo())

random_sample_70 = fc.filter('random >= 0.3')
print('N features in 70% sample:', random_sample_70.size().getInfo())