ee.Geometry.convexHull

指定されたジオメトリの凸包を返します。単一のポイントの凸包はポイント自体であり、同一線上のポイントの凸包は線であり、それ以外のすべての凸包はポリゴンです。すべての頂点が同じ線上にある縮退ポリゴンは、線分になります。

用途戻り値
Geometry.convexHull(maxError, proj)ジオメトリ
引数タイプ詳細
これ: geometryジオメトリこのジオメトリの凸包を計算します。
maxErrorErrorMargin、デフォルト: null必要な再投影を行う際に許容される最大誤差。
projProjection、デフォルト: nullオペレーションを実行するプロジェクション。指定しない場合、演算は球面座標系で実行され、線形距離は球面のメートル単位になります。

コードエディタ(JavaScript)

// Define a Geometry object.
var geometry = ee.Geometry({
  'type': 'Polygon',
  'coordinates':
    [[[-122.081, 37.417],
      [-122.086, 37.421],
      [-122.084, 37.418],
      [-122.089, 37.416]]]
});

// Apply the convexHull method to the Geometry object.
var geometryConvexHull = geometry.convexHull({'maxError': 1});

// Print the result to the console.
print('geometry.convexHull(...) =', geometryConvexHull);

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

Python の設定

Python API とインタラクティブな開発での geemap の使用については、 Python 環境のページをご覧ください。

import ee
import geemap.core as geemap

Colab(Python)

# Define a Geometry object.
geometry = ee.Geometry({
    'type': 'Polygon',
    'coordinates': [[
        [-122.081, 37.417],
        [-122.086, 37.421],
        [-122.084, 37.418],
        [-122.089, 37.416],
    ]],
})

# Apply the convexHull method to the Geometry object.
geometry_convex_hull = geometry.convexHull(maxError=1)

# Print the result.
display('geometry.convexHull(...) =', geometry_convex_hull)

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