ee.Geometry

ジオメトリを作成します。

用途戻り値
ee.Geometry(geoJson, proj, geodesic, evenOdd)ジオメトリ
引数タイプ詳細
geoJsonオブジェクトジオメトリを記述する GeoJSON オブジェクト、または Geometry として再解釈される ComputedObject。GeoJSON 仕様に準拠した CRS 仕様をサポートしますが、名前付き(「リンクされた」CRS ではなく)CRS のみ許可します。これに「geodesic」フィールドが含まれていて、opt_geodesic が指定されていない場合は、opt_geodesic として使用されます。
proj投影(省略可)オプションの投影仕様。CRS ID コードまたは WKT 文字列のいずれか。指定すると、geoJson パラメータで見つかった CRS がオーバーライドされます。指定されておらず、geoJson で CRS が宣言されていない場合、デフォルトは「EPSG:4326」(x=経度、y=緯度)になります。
geodesicブール値、省略可線分を球状測地線として解釈するかどうか。false の場合、線分は指定された CRS の平面線として解釈されることを示します。指定しない場合、CRS が地理座標系(デフォルトの EPSG:4326 を含む)の場合はデフォルトで true、CRS が投影座標系の場合はデフォルトで false になります。
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 環境のページをご覧ください。

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