ee.FeatureCollection.randomColumn
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
הוספת עמודה של מספרים פסאודו-אקראיים דטרמיניסטיים לאוסף. הפלט הוא מספרים של נקודה צפה (floating-point) ברמת דיוק כפולה. כשמשתמשים בהתפלגות 'uniform' (ברירת המחדל), הפלט נמצא בטווח [0, 1). כשמשתמשים בהתפלגות 'נורמלית', הערכים של הפלט הם μ=0, σ=1, אבל אין להם מגבלות מפורשות.
שימוש | החזרות |
---|
FeatureCollection.randomColumn(columnName, seed, distribution, rowKeys) | FeatureCollection |
ארגומנט | סוג | פרטים |
---|
זה: collection | FeatureCollection | אוסף הקלט שאליו רוצים להוסיף עמודה אקראית. |
columnName | מחרוזת, ברירת המחדל: 'random' | השם של העמודה שרוצים להוסיף. |
seed | ארוך, ברירת המחדל: 0 | זרע שמשמש ליצירת המספרים האקראיים. |
distribution | מחרוזת, ברירת המחדל: uniform | סוג ההתפלגות של המספרים האקראיים שייווצרו. אפשר לבחור באפשרויות 'עקבי' או 'נורמלי'. |
rowKeys | רשימה, אופציונלי | רשימה של מאפיינים שצריכים לזהות באופן ייחודי וחזרתי אלמנט בקולקציה, המשמשת ליצירת המספר האקראי. ברירת המחדל היא [system:index]. |
דוגמאות
Code Editor (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 מפורט מידע על Python API ועל השימוש ב-geemap
לפיתוח אינטראקטיבי.
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())
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-25 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-25 (שעון UTC)."],[],["This tool adds a column of pseudorandom numbers to a FeatureCollection. Users can specify the `columnName`, `seed`, and `distribution`. The default distribution, 'uniform', generates numbers between 0 and 1; 'normal' produces numbers with a mean of 0 and a standard deviation of 1. The `randomColumn` method returns the modified FeatureCollection. This is exemplified by creating random splits into subsets. The outputs are double-precision floating point numbers.\n"],null,[]]