ee.Geometry

Crea una geometria.

UtilizzoResi
ee.Geometry(geoJson, proj, geodesic, evenOdd)Geometria
ArgomentoTipoDettagli
geoJsonOggettoL'oggetto GeoJSON che descrive la geometria o un ComputedObject da reinterpretare come geometria. Supporta le specifiche CRS in base alla specifica GeoJSON, ma consente solo CRS denominati (anziché CRS "collegati"). Se include un campo "geodetico" e opt_geodesic non è specificato, verrà utilizzato come opt_geodesic.
projProiezione, facoltativaUna specifica di proiezione facoltativa, come codice ID CRS o come stringa WKT. Se specificato, esegue l'override di qualsiasi CRS trovato nel parametro geoJson. Se non specificato e il file GeoJSON non dichiara un CRS, il valore predefinito è "EPSG:4326" (x=longitudine, y=latitudine).
geodesicBooleano, facoltativoIndica se i segmenti di linea devono essere interpretati come geodetiche sferiche. Se è false, indica che i segmenti di linea devono essere interpretati come linee planari nel sistema di riferimento specificato. Se assente, il valore predefinito è true se il CRS è geografico (incluso EPSG:4326 predefinito) o false se il CRS è proiettato.
evenOddBooleano, facoltativoSe true, gli interni del poligono saranno determinati dalla regola pari/dispari, in base alla quale un punto si trova all'interno se attraversa un numero dispari di bordi per raggiungere un punto all'infinito. In caso contrario, i poligoni utilizzano la regola sinistra-interna, in cui gli interni si trovano sul lato sinistro dei bordi della shell quando si percorrono i vertici nell'ordine specificato. Se non specificato, il valore predefinito è true.

Esempi

Editor di codice (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());

Configurazione di Python

Consulta la pagina Ambiente Python per informazioni sull'API Python e sull'utilizzo di geemap per lo sviluppo interattivo.

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