ee.Geometry

יוצרת גיאומטריה.

שימושהחזרות
ee.Geometry(geoJson, proj, geodesic, evenOdd)גיאומטריה
ארגומנטסוגפרטים
geoJsonאובייקטאובייקט GeoJSON שמתאר את הגיאומטריה או אובייקט ComputedObject שצריך לפרש מחדש כאובייקט Geometry. תומך במפרטי CRS בהתאם למפרט GeoJSON, אבל מאפשר רק CRS עם שם (ולא CRS מקושר). אם השדה הזה כולל שדה geodesic, ולא מצוין opt_geodesic, המערכת תשתמש בו כ-opt_geodesic.
projתחזית, אופציונלימפרט הקרנה אופציונלי, כמזהה CRS או כמחרוזת WKT. אם מציינים ערך, הוא מחליף כל CRS שנמצא בפרמטר geoJson. אם לא מציינים את מערכת הייחוס הגיאוגרפי (CRS) בקובץ ה-GeoJSON, ברירת המחדל היא EPSG:4326 (x=קו אורך, y=קו רוחב).
geodesicבוליאני, אופציונליהארגומנט שקובע אם לפרש קטעי קו כגיאודזיות כדוריות. אם הערך הוא false, המשמעות היא שצריך לפרש את קטעי הקו כקווים מישוריים במערכת קואורדינטות שצוינה. אם המאפיין לא מצוין, ברירת המחדל היא true אם ה-CRS הוא גיאוגרפי (כולל ברירת המחדל EPSG:4326), או false אם ה-CRS הוא מוקרן.
evenOddבוליאני, אופציונליאם הערך הוא True, פנים הפוליגון ייקבע לפי כלל הזוגי/האי-זוגי, שבו נקודה נמצאת בפנים אם היא חוצה מספר אי-זוגי של קצוות כדי להגיע לנקודה באינסוף. אחרת, במצולעים נעשה שימוש בכלל 'הצד השמאלי', שבו החלק הפנימי נמצא בצד שמאל של קצוות המעטפת כשמסתכלים על הקודקודים בסדר הנתון. אם לא מציינים ערך, ברירת המחדל היא true.

דוגמאות

עורך הקוד (JavaScript)

// A GeoJSON object for a triangular polygon.
var geojsonObject = {
  "type": "Polygon",
  "coordinates": [
    [
      [
        -122.085,
        37.423
      ],
      [
        -122.092,
        37.424
      ],
      [
        -122.085,
        37.418
      ],
      [
        -122.085,
        37.423
      ]
    ]
  ]
};
print('ee.Geometry accepts a GeoJSON object', ee.Geometry(geojsonObject));

// GeoJSON strings need to be converted to an object.
var geojsonString = JSON.stringify(geojsonObject);
print('A GeoJSON string needs to be converted to an object',
      ee.Geometry(JSON.parse(geojsonString)));

// Use ee.Geometry to cast computed geometry objects into the ee.Geometry
// class to access their methods. In the following example an ee.Geometry
// object is stored as a ee.Feature property. When it is retrieved with the
// .get() function, a computed geometry object is returned. Cast the computed
// object as a ee.Geometry to get the geometry's bounds, for instance.
var feature = ee.Feature(null, {geom: ee.Geometry(geojsonObject)});
print('Cast computed geometry objects to ee.Geometry class',
      ee.Geometry(feature.get('geom')).bounds());

הגדרת Python

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

import ee
import geemap.core as geemap

Colab (Python)

import json

# A GeoJSON object for a triangular polygon.
geojson_object = {
    'type': 'Polygon',
    'coordinates': [
        [
            [
                -122.085,
                37.423
            ],
            [
                -122.092,
                37.424
            ],
            [
                -122.085,
                37.418
            ],
            [
                -122.085,
                37.423
                ]
            ]
        ]
}
print(
    'ee.Geometry accepts a GeoJSON object:',
    ee.Geometry(geojson_object).getInfo()
)

# GeoJSON strings need to be converted to an object.
geojson_string = json.dumps(geojson_object)
print('A GeoJSON string needs to be converted to an object:',
      ee.Geometry(json.loads(geojson_string)).getInfo())

# Use ee.Geometry to cast computed geometry objects into the ee.Geometry
# class to access their methods. In the following example an ee.Geometry
# object is stored as a ee.Feature property. When it is retrieved with the
# .get() function, a computed geometry object is returned. Cast the computed
# object as a ee.Geometry to get the geometry's bounds, for instance.
feature = ee.Feature(None, {'geom': ee.Geometry(geojson_object)})
print('Cast computed geometry objects to ee.Geometry class:',
      ee.Geometry(feature.get('geom')).bounds().getInfo())