ee.Geometry.LineString.centroid

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

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

דוגמאות

עורך הקוד (JavaScript)

// Define a LineString object.
var lineString = ee.Geometry.LineString([[-122.09, 37.42], [-122.08, 37.43]]);

// Apply the centroid method to the LineString object.
var lineStringCentroid = lineString.centroid({'maxError': 1});

// Print the result to the console.
print('lineString.centroid(...) =', lineStringCentroid);

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

הגדרת Python

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

import ee
import geemap.core as geemap

Colab (Python)

# Define a LineString object.
linestring = ee.Geometry.LineString([[-122.09, 37.42], [-122.08, 37.43]])

# Apply the centroid method to the LineString object.
linestring_centroid = linestring.centroid(maxError=1)

# Print the result.
display('linestring.centroid(...) =', linestring_centroid)

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