ee.FeatureCollection.randomPoints

指定されたジオメトリ内で均一にランダムな点を生成します。ジオメトリが 2 次元(ポリゴンまたはマルチポリゴン)の場合、返されるポイントは球の特定の領域に均等に分布します。ジオメトリが 1 次元(LineString)の場合、返されるポイントはジオメトリのエッジに沿って均等に補間されます。ジオメトリの次元が 0(ポイント)の場合、返されるポイントは入力ポイントから均一にサンプリングされます。混合ディメンションのマルチジオメトリが指定されている場合、ポイントは最もディメンションの大きいコンポーネント ジオメトリからサンプリングされます。

用途戻り値
ee.FeatureCollection.randomPoints(region, points, seed, maxError)FeatureCollection
引数タイプ詳細
regionジオメトリポイントを生成するリージョン。
points整数、デフォルト: 1000生成するポイントの数。
seed長い、デフォルト: 0乱数ジェネレータのシード。
maxErrorErrorMargin(省略可)必要な再投影を実行する際に許容される最大エラー量。

コードエディタ(JavaScript)

// An ee.Geometry to constrain the geographic bounds of random points.
var region = ee.Geometry.Rectangle(
    {coords: [-113.5, 40.0, -110.2, 41.9], geodesic: false});

// Generate 50 random points with the region.
var randomPoints = ee.FeatureCollection.randomPoints(
    {region: region, points: 50, seed: 0, maxError: 1});

print('Random points from within the defined region', randomPoints);
Map.setCenter(-111.802, 40.979, 7);
Map.addLayer(region, {color: 'yellow'}, 'Region');
Map.addLayer(randomPoints, {color: 'black'}, 'Random points');

Python の設定

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

import ee
import geemap.core as geemap

Colab(Python)

# An ee.Geometry to constrain the geographic bounds of random points.
region = ee.Geometry.Rectangle(
    coords=[-113.5, 40.0, -110.2, 41.9], proj='EPSG:4326', geodesic=False
)

# Generate 50 random points with the region.
random_points = ee.FeatureCollection.randomPoints(
    region=region, points=50, seed=0, maxError=1
)

display('Random points from within the defined region', random_points)
m = geemap.Map()
m.set_center(-111.802, 40.979, 7)
m.add_layer(region, {'color': 'yellow'}, 'Region')
m.add_layer(random_points, {'color': 'black'}, 'Random points')
m