お知らせ:
2025 年 4 月 15 日より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、Earth Engine へのアクセスを維持するために
非商用目的での利用資格を確認する必要があります。
ee.FeatureCollection.randomColumn
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
確定的な疑似乱数列をコレクションに追加します。出力は倍精度浮動小数点数です。「均一」分布(デフォルト)を使用する場合、出力は [0, 1] の範囲内になります。「正規」分布を使用する場合、出力は μ=0、σ=1 になりますが、明示的な上限はありません。
用途 | 戻り値 |
---|
FeatureCollection.randomColumn(columnName, seed, distribution, rowKeys) | FeatureCollection |
引数 | タイプ | 詳細 |
---|
this: collection | FeatureCollection | ランダムな列を追加する入力コレクション。 |
columnName | 文字列、デフォルト: 「random」 | 追加する列の名前。 |
seed | 長い、デフォルト: 0 | 乱数の生成時に使用されるシード。 |
distribution | 文字列、デフォルト: "uniform" | 生成する乱数の分布タイプ(「一様」または「正規」のいずれか)。 |
rowKeys | リスト(省略可) | コレクションの要素を一意かつ繰り返し識別できるプロパティのリスト。乱数の生成に使用されます。デフォルトは [system:index] です。 |
例
コードエディタ(JavaScript)
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
print('N features in collection', fc.size());
// Add a uniform distribution random value column to the FeatureCollection.
fc = fc.randomColumn();
// Randomly split the collection into two sets, 30% and 70% of the total.
var randomSample30 = fc.filter('random < 0.3');
print('N features in 30% sample', randomSample30.size());
var randomSample70 = fc.filter('random >= 0.3');
print('N features in 70% sample', randomSample70.size());
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"')
print('N features in collection:', fc.size().getInfo())
# Add a uniform distribution random value column to the FeatureCollection.
fc = fc.randomColumn()
# Randomly split the collection into two sets, 30% and 70% of the total.
random_sample_30 = fc.filter('random < 0.3')
print('N features in 30% sample:', random_sample_30.size().getInfo())
random_sample_70 = fc.filter('random >= 0.3')
print('N features in 70% sample:', random_sample_70.size().getInfo())
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-25 UTC。
[null,null,["最終更新日 2025-07-25 UTC。"],[],["This tool adds a column of pseudorandom numbers to a FeatureCollection. Users can specify the `columnName`, `seed`, and `distribution`. The default distribution, 'uniform', generates numbers between 0 and 1; 'normal' produces numbers with a mean of 0 and a standard deviation of 1. The `randomColumn` method returns the modified FeatureCollection. This is exemplified by creating random splits into subsets. The outputs are double-precision floating point numbers.\n"],null,[]]