ee.FeatureCollection.randomColumn

확정적인 가우스 숫자의 열을 컬렉션에 추가합니다. 출력은 배정밀도 부동 소수점 수입니다. '균일' 분포 (기본값)를 사용하는 경우 출력은 [0, 1) 범위입니다. '정규' 분포를 사용하면 출력의 μ=0, σ=1이지만 명시적인 제한은 없습니다.

사용반환 값
FeatureCollection.randomColumn(columnName, seed, distribution, rowKeys)FeatureCollection
인수유형세부정보
this: collectionFeatureCollection임의의 열을 추가할 입력 컬렉션입니다.
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())