ee.Geometry.MultiPoint.centroid

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

שימושהחזרות
MultiPoint.centroid(maxError, proj)גיאומטריה
ארגומנטסוגפרטים
זה: geometryגיאומטריההפונקציה מחשבת את מרכז הכובד של הצורה הגיאומטרית.
maxErrorErrorMargin, ברירת מחדל: nullהכמות המקסימלית של שגיאות שמותרות כשמבצעים הקרנה מחדש.
projתחזית, ברירת מחדל: nullאם מציינים הקרנה, התוצאה תהיה בהקרנה הזו. אחרת, הוא יהיה ב-EPSG:4326.

דוגמאות

עורך הקוד (JavaScript)

// Define a MultiPoint object.
var multiPoint = ee.Geometry.MultiPoint([[-122.082, 37.420], [-122.081, 37.426]]);

// Apply the centroid method to the MultiPoint object.
var multiPointCentroid = multiPoint.centroid({'maxError': 1});

// Print the result to the console.
print('multiPoint.centroid(...) =', multiPointCentroid);

// Display relevant geometries on the map.
Map.setCenter(-122.085, 37.422, 15);
Map.addLayer(multiPoint,
             {'color': 'black'},
             'Geometry [black]: multiPoint');
Map.addLayer(multiPointCentroid,
             {'color': 'red'},
             'Result [red]: multiPoint.centroid');

הגדרת Python

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

import ee
import geemap.core as geemap

Colab (Python)

# Define a MultiPoint object.
multipoint = ee.Geometry.MultiPoint([[-122.082, 37.420], [-122.081, 37.426]])

# Apply the centroid method to the MultiPoint object.
multipoint_centroid = multipoint.centroid(maxError=1)

# Print the result.
display('multipoint.centroid(...) =', multipoint_centroid)

# Display relevant geometries on the map.
m = geemap.Map()
m.set_center(-122.085, 37.422, 15)
m.add_layer(multipoint, {'color': 'black'}, 'Geometry [black]: multipoint')
m.add_layer(
    multipoint_centroid, {'color': 'red'}, 'Result [red]: multipoint.centroid'
)
m