הערה: המרחק נמדד גם בתוך פוליגונים. פיקסלים שלא נמצאים במרחק של searchRadius מטרים מצורה גיאומטרית יוסתרו.
המרחקים מחושבים על פני כדור, ולכן יש שגיאה קטנה שפרופורציונלית להפרש בקו הרוחב בין כל פיקסל לבין הצורה הגיאומטרית הקרובה ביותר.
| שימוש | החזרות |
|---|---|
FeatureCollection.distance(searchRadius, maxError) | תמונה |
| ארגומנט | סוג | פרטים |
|---|---|---|
זה: features | FeatureCollection | אוסף התכונות שממנו נלקחות התכונות שמשמשות לחישוב המרחקים בין הפיקסלים. |
searchRadius | מספר ממשי (float), ברירת מחדל: 100,000 | המרחק המקסימלי במטרים מכל פיקסל שבו יתבצע חיפוש של קצוות. פיקסלים יוסתרו אלא אם יש קצוות במרחק הזה. |
maxError | מספר צף, ברירת מחדל: 100 | שגיאת ההיטל המקסימלית במטרים, בשימוש רק אם נדרש ליצור היטל מחדש של קווי הפוליגון של הקלט. אם מציינים '0', הפעולה תיכשל אם נדרשת הקרנה. |
דוגמאות
Code Editor (JavaScript)
// FeatureCollection of power plants in Belgium. var fc = ee.FeatureCollection('WRI/GPPD/power_plants') .filter('country_lg == "Belgium"'); // Generate an image of distance to nearest power plant. var distance = fc.distance({searchRadius: 50000, maxError: 50}); // Display the image and FeatureCollection on the map. Map.setCenter(4.56, 50.78, 7); Map.addLayer(distance, {max: 50000}, 'Distance to power plants'); Map.addLayer(fc, {color: 'red'}, 'Power plants');
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"' ) # Generate an image of distance to nearest power plant. distance = fc.distance(searchRadius=50000, maxError=50) # Display the image and FeatureCollection on the map. m = geemap.Map() m.set_center(4.56, 50.78, 7) m.add_layer(distance, {'max': 50000}, 'Distance to power plants') m.add_layer(fc, {'color': 'red'}, 'Power plants') m