ee.FeatureCollection.randomPoints

יצירת נקודות אקראיות באופן אחיד בגיאומטריה הנתונה. אם הגיאומטריה היא דו-מימדית (פוליגון או פוליגון מרוכב), הנקודות שמוחזרות מחולקות באופן אחיד באזור הנתון של הכדור. אם הגיאומטריה היא חד-מימדית (קווים), הנקודות שמוחזרות מותאמות באופן אחיד לאורך הקצוות של הגיאומטריה. אם לגיאומטריה יש מאפיין אפס (נקודות), הנקודות שמוחזרות נלקחות באופן אחיד מנקודות הקלט. אם נתונה גיאומטריה מרובה של מאפיין מעורב, הנקודות נלקחות מדגימה של גיאומטריות הרכיבים עם המאפיין הגבוה ביותר.

שימושהחזרות
ee.FeatureCollection.randomPoints(region, points, seed, maxError)FeatureCollection
ארגומנטסוגפרטים
regionגיאומטריההאזור שבו רוצים ליצור נקודות.
pointsמספר שלם, ברירת המחדל: 1000מספר הנקודות שייווצרו.
seedארוך, ברירת המחדל: 0ערך בסיס למחולל המספרים האקראיים.
maxErrorErrorMargin, אופציונלירמת השגיאה המקסימלית שאפשר לסבול במהלך הקרנה מחדש (reprojection) נדרשת.

דוגמאות

Code Editor‏ (JavaScript)

// An ee.Geometry to constrain the geographic bounds of random points.
var region = ee.Geometry.Rectangle(
    {coords: [-113.5, 40.0, -110.2, 41.9], geodesic: false});

// Generate 50 random points with the region.
var randomPoints = ee.FeatureCollection.randomPoints(
    {region: region, points: 50, seed: 0, maxError: 1});

print('Random points from within the defined region', randomPoints);
Map.setCenter(-111.802, 40.979, 7);
Map.addLayer(region, {color: 'yellow'}, 'Region');
Map.addLayer(randomPoints, {color: 'black'}, 'Random points');

הגדרת Python

בדף סביבת Python מפורט מידע על Python API ועל השימוש ב-geemap לפיתוח אינטראקטיבי.

import ee
import geemap.core as geemap

Colab (Python)

# An ee.Geometry to constrain the geographic bounds of random points.
region = ee.Geometry.Rectangle(
    coords=[-113.5, 40.0, -110.2, 41.9], proj='EPSG:4326', geodesic=False
)

# Generate 50 random points with the region.
random_points = ee.FeatureCollection.randomPoints(
    region=region, points=50, seed=0, maxError=1
)

display('Random points from within the defined region', random_points)
m = geemap.Map()
m.set_center(-111.802, 40.979, 7)
m.add_layer(region, {'color': 'yellow'}, 'Region')
m.add_layer(random_points, {'color': 'black'}, 'Random points')
m