הודעה: כל הפרויקטים הלא מסחריים שנרשמו לשימוש ב-Earth Engine לפני
15 באפריל 2025 חייבים
לאמת את הזכאות לשימוש לא מסחרי כדי לשמור על הגישה. אם לא תאמתו את החשבון עד 26 בספטמבר 2025, יכול להיות שהגישה שלכם תושעה.
ee.FeatureCollection.randomPoints
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
יצירת נקודות אקראיות באופן אחיד בגיאומטריה הנתונה. אם הגיאומטריה היא דו-מימדית (פוליגון או פוליגון מרוכב), הנקודות שמוחזרות מחולקות באופן אחיד באזור הנתון של הכדור. אם הגיאומטריה היא חד-מימדית (קווים), הנקודות שמוחזרות מותאמות באופן אחיד לאורך הקצוות של הגיאומטריה. אם לגיאומטריה יש מאפיין אפס (נקודות), הנקודות שמוחזרות נלקחות באופן אחיד מנקודות הקלט. אם נתונה גיאומטריה מרובה של מאפיין מעורב, הנקודות נלקחות מדגימה של גיאומטריות הרכיבים עם המאפיין הגבוה ביותר.
| שימוש | החזרות |
|---|
ee.FeatureCollection.randomPoints(region, points, seed, maxError) | FeatureCollection |
| ארגומנט | סוג | פרטים |
|---|
region | גיאומטריה | האזור שבו רוצים ליצור נקודות. |
points | מספר שלם, ברירת המחדל: 1000 | מספר הנקודות שייווצרו. |
seed | ארוך, ברירת המחדל: 0 | ערך בסיס למחולל המספרים האקראיים. |
maxError | ErrorMargin, אופציונלי | רמת השגיאה המקסימלית שאפשר לסבול במהלך הקרנה מחדש (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
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-25 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-25 (שעון UTC)."],[],["The `ee.FeatureCollection.randomPoints` function generates a specified number of random points within a given geometry. The points are uniformly distributed within the geometry's area if it's two-dimensional, along its edges if one-dimensional, or sampled from the input points if zero-dimensional. For mixed-dimension multi-geometries, points are drawn from the highest-dimension components. The user defines the `region`, the number of `points`, a random `seed`, and an optional `maxError`.\n"]]