ee.Geometry

Erstellt eine Geometrie.

NutzungAusgabe
ee.Geometry(geoJson, proj, geodesic, evenOdd)Geometrie
ArgumentTypDetails
geoJsonObjektDas GeoJSON-Objekt, das die Geometrie beschreibt, oder ein ComputedObject, das als Geometrie neu interpretiert werden soll. Unterstützt CRS-Spezifikationen gemäß der GeoJSON-Spezifikation, lässt aber nur benannte (und nicht „verknüpfte“) CRSs zu. Wenn dies ein Feld vom Typ „geodesic“ enthält und „opt_geodesic“ nicht angegeben ist, wird es als „opt_geodesic“ verwendet.
projProjektion (optional)Eine optionale Projektionsspezifikation, entweder als CRS-ID-Code oder als WKT-String. Falls angegeben, wird jedes CRS überschrieben, das im geoJson-Parameter gefunden wird. Wenn nicht angegeben und im GeoJSON kein CRS deklariert ist, wird standardmäßig „EPSG:4326“ verwendet (x=Längengrad, y=Breitengrad).
geodesicBoolesch, optionalGibt an, ob Liniensegmente als sphärische Geodäten interpretiert werden sollen. Wenn „false“, werden Liniensegmente als planare Linien im angegebenen CRS interpretiert. Wenn nicht vorhanden, wird standardmäßig „true“ verwendet, wenn das CRS geografisch ist (einschließlich des Standard-EPSG:4326), oder „false“, wenn das CRS projiziert ist.
evenOddBoolesch, optionalWenn „true“, wird das Innere von Polygonen nach der Even-Odd-Regel bestimmt. Ein Punkt liegt innerhalb, wenn er eine ungerade Anzahl von Kanten überquert, um einen Punkt im Unendlichen zu erreichen. Andernfalls wird für Polygone die Left-Inside-Regel verwendet, bei der sich das Innere auf der linken Seite der Kanten der Hülle befindet, wenn die Eckpunkte in der angegebenen Reihenfolge durchlaufen werden. Wenn nicht angegeben, lautet die Standardeinstellung „true“.

Beispiele

Code-Editor (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 einrichten

Informationen zur Python API und zur Verwendung von geemap für die interaktive Entwicklung finden Sie auf der Seite Python-Umgebung.

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())