ee.FeatureCollection.distance

יוצרת תמונת DOUBLE שבה כל פיקסל הוא המרחק במטרים ממרכז הפיקסל לנקודה, ל-LineString או לגבול מצולע הקרובים ביותר באוסף. הערה: המרחק נמדד גם בתוך פוליגונים. פיקסלים שלא נמצאים במרחק של searchRadius מטרים מצורה גיאומטרית יוסתרו.

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

שימושהחזרות
FeatureCollection.distance(searchRadius, maxError)תמונה
ארגומנטסוגפרטים
זה: featuresFeatureCollectionאוסף התכונות שממנו נלקחות התכונות שמשמשות לחישוב המרחקים בין הפיקסלים.
searchRadiusמספר ממשי (float), ברירת מחדל: 100,000המרחק המקסימלי במטרים מכל פיקסל שבו יתבצע חיפוש של קצוות. פיקסלים יוסתרו אלא אם יש קצוות במרחק הזה.
maxErrorמספר ממשי (float), ברירת מחדל: 100שגיאת ההיטל המקסימלית במטרים, לשימוש רק אם נדרש היטל מחדש של קווי הפוליגון של הקלט. אם מציינים '0', הפעולה תיכשל אם נדרשת הקרנה.

דוגמאות

עורך הקוד (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');

הגדרת Python

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

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