ee.Geometry.LineString.distance

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

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

コードエディタ(JavaScript)

// Define a LineString object.
var lineString = ee.Geometry.LineString([[-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 LineString object.
var lineStringDistance = lineString.distance({'right': inputGeom, 'maxError': 1});

// Print the result to the console.
print('lineString.distance(...) =', lineStringDistance);

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

Python の設定

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

import ee
import geemap.core as geemap

Colab(Python)

# Define a LineString object.
linestring = ee.Geometry.LineString([[-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 LineString object.
linestring_distance = linestring.distance(right=input_geom, maxError=1)

# Print the result.
display('linestring.distance(...) =', linestring_distance)

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