ee.Geometry.distance

2 つのジオメトリ間の最小距離を返します。

用途戻り値
Geometry.distance(right, maxError, proj, spherical)浮動小数点数
引数タイプ詳細
this: leftジオメトリオペレーションの左オペランドとして使用されるジオメトリ。
rightジオメトリ演算の右オペランドとして使用されるジオメトリ。
maxErrorErrorMargin、デフォルト: null必要な再投影を実行する際に許容される最大エラー量。
proj投影、デフォルト: nullオペレーションを実行する投影。指定しない場合、操作は球面座標系で実行され、直線距離は球面上のメートル単位になります。
sphericalブール値。デフォルト: falsetrue の場合、計算は単位球上で行われます。false の場合、地球の扁平率を考慮した楕円形の計算が行われます。proj が指定されている場合は無視されます。デフォルトは false です。

コードエディタ(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]]]
});

// Define other inputs.
var inputGeom = ee.Geometry.Point(-122.090, 37.423);

// Apply the distance method to the Geometry object.
var geometryDistance = geometry.distance({'right': inputGeom, 'maxError': 1});

// Print the result to the console.
print('geometry.distance(...) =', geometryDistance);

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

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],
    ]],
})

# Define other inputs.
input_geom = ee.Geometry.Point(-122.090, 37.423)

# Apply the distance method to the Geometry object.
geometry_distance = geometry.distance(right=input_geom, maxError=1)

# Print the result.
display('geometry.distance(...) =', geometry_distance)

# 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(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom')
m