ee.Geometry.Rectangle.distance

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

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

コードエディタ(JavaScript)

// Define a Rectangle object.
var rectangle = ee.Geometry.Rectangle(-122.09, 37.42, -122.08, 37.43);

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

// Apply the distance method to the Rectangle object.
var rectangleDistance = rectangle.distance({'right': inputGeom, 'maxError': 1});

// Print the result to the console.
print('rectangle.distance(...) =', rectangleDistance);

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

Python の設定

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

import ee
import geemap.core as geemap

Colab(Python)

# Define a Rectangle object.
rectangle = ee.Geometry.Rectangle(-122.09, 37.42, -122.08, 37.43)

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

# Apply the distance method to the Rectangle object.
rectangle_distance = rectangle.distance(right=input_geom, maxError=1)

# Print the result.
display('rectangle.distance(...) =', rectangle_distance)

# Display relevant geometries on the map.
m = geemap.Map()
m.set_center(-122.085, 37.422, 15)
m.add_layer(rectangle, {'color': 'black'}, 'Geometry [black]: rectangle')
m.add_layer(input_geom, {'color': 'blue'}, 'Parameter [blue]: input_geom')
m