ee.FeatureCollection.distance

各ピクセルが、ピクセルの中央からコレクション内の最も近い Point、LineString、またはポリゴンの境界までの距離(メートル単位)である DOUBLE 画像を生成します。距離はポリゴンの内部でも測定されます。ジオメトリから「searchRadius」メートル以内のピクセルはマスクされます。

距離は球体上で計算されるため、各ピクセルと最も近いジオメトリの緯度の差に比例した小さな誤差が生じます。

用途戻り値
FeatureCollection.distance(searchRadius, maxError)画像
引数タイプ詳細
これ: featuresFeatureCollectionピクセル距離の計算に使用する特徴を取得する特徴コレクション。
searchRadius浮動小数点数、デフォルト: 100000各ピクセルからエッジを探す最大距離(メートル単位)。この距離内にエッジがない限り、ピクセルはマスクされます。
maxError浮動小数点数、デフォルト: 100再投影の最大誤差(メートル単位)。入力ポリラインの再投影が必要な場合にのみ使用されます。「0」が指定されている場合、射影が必要な場合、このオペレーションは失敗します。

コードエディタ(JavaScript)

// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
             .filter('country_lg == "Belgium"');

// Generate an image of distance to nearest power plant.
var distance = fc.distance({searchRadius: 50000, maxError: 50});

// Display the image and FeatureCollection on the map.
Map.setCenter(4.56, 50.78, 7);
Map.addLayer(distance, {max: 50000}, 'Distance to power plants');
Map.addLayer(fc, {color: 'red'}, 'Power plants');

Python の設定

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

import ee
import geemap.core as geemap

Colab(Python)

# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
    'country_lg == "Belgium"'
)

# Generate an image of distance to nearest power plant.
distance = fc.distance(searchRadius=50000, maxError=50)

# Display the image and FeatureCollection on the map.
m = geemap.Map()
m.set_center(4.56, 50.78, 7)
m.add_layer(distance, {'max': 50000}, 'Distance to power plants')
m.add_layer(fc, {'color': 'red'}, 'Power plants')
m