공지사항:
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 액세스 권한을 유지하기 위해
비상업용 자격 요건을 인증해야 합니다. 2025년 9월 26일까지 인증하지 않으면 액세스가 보류될 수 있습니다.
ee.Image.sample
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이미지의 픽셀을 샘플링하여 FeatureCollection으로 반환합니다. 각 특징에는 입력 이미지의 밴드당 속성이 하나씩 있습니다. 기본 동작은 마스크 처리된 픽셀과 교차하는 기능을 삭제하여 null 값 속성이 생성되는 것입니다 (dropNulls 인수 참고).
사용 | 반환 값 |
---|
Image.sample(region, scale, projection, factor, numPixels, seed, dropNulls, tileScale, geometries) | FeatureCollection |
인수 | 유형 | 세부정보 |
---|
다음과 같은 경우: image | 이미지 | 샘플링할 이미지입니다. |
region | 기하학, 기본값: null | 샘플링할 리전입니다. 지정하지 않으면 이미지의 전체 설치 공간을 사용합니다. |
scale | 부동 소수점 수, 기본값: null | 샘플링할 투영의 명목상 스케일(미터)입니다. |
projection | 예상, 기본값: null | 샘플링할 투영입니다. 지정하지 않으면 이미지의 첫 번째 밴드의 투영이 사용됩니다. 크기 조정 외에 지정된 경우 지정된 크기로 다시 조정됩니다. |
factor | 부동 소수점 수, 기본값: null | (0, 1] 범위의 다운샘플링 요소입니다. 지정된 경우 'numPixels'를 지정하면 안 됩니다. 기본값은 서브샘플링 없음입니다. |
numPixels | long, 기본값: null | 샘플링할 대략적인 픽셀 수입니다. 지정된 경우 'factor'는 지정하면 안 됩니다. |
seed | 정수, 기본값: 0 | 하위 샘플링에 사용할 무작위 순서 지정 시드입니다. |
dropNulls | 불리언, 기본값: true | 결과를 필터링하여 null 값 속성이 있는 기능을 삭제합니다. |
tileScale | 부동 소수점 수, 기본값: 1 | 집계 타일 크기를 줄이는 데 사용되는 확장 요소입니다. 더 큰 tileScale (예: 2 또는 4)를 사용하면 기본값으로 메모리가 부족한 계산을 실행할 수 있습니다. |
geometries | 불리언, 기본값: false | true인 경우 샘플링된 픽셀의 중심을 출력 피처의 geometry 속성으로 추가합니다. 그렇지 않으면 지오메트리가 생략되어 메모리가 절약됩니다. |
예
코드 편집기 (JavaScript)
// Demonstrate extracting pixels from an image as features with
// ee.Image.sample(), and show how the features are aligned with the pixels.
// An image with one band of elevation data.
var image = ee.Image('CGIAR/SRTM90_V4');
var VIS_MIN = 1620;
var VIS_MAX = 1650;
Map.addLayer(image, {min: VIS_MIN, max: VIS_MAX}, 'SRTM');
// Region to sample.
var region = ee.Geometry.Polygon(
[[[-110.006, 40.002],
[-110.006, 39.999],
[-109.995, 39.999],
[-109.995, 40.002]]], null, false);
// Show region on the map.
Map.setCenter(-110, 40, 16);
Map.addLayer(ee.FeatureCollection([region]).style({"color": "00FF0022"}));
// Perform sampling; convert image pixels to features.
var samples = image.sample({
region: region,
// Default (false) is no geometries in the output.
// When set to true, each feature has a Point geometry at the center of the
// image pixel.
geometries: true,
// The scale is not specified, so the resolution of the image will be used,
// and there is a feature for every pixel. If we give a scale parameter, the
// image will be resampled and there will be more or fewer features.
//
// scale: 200,
});
// Visualize sample data using ee.FeatureCollection.style().
var styled = samples
.map(function (feature) {
return feature.set('style', {
pointSize: feature.getNumber('elevation').unitScale(VIS_MIN, VIS_MAX)
.multiply(15),
});
})
.style({
color: '000000FF',
fillColor: '00000000',
styleProperty: 'style',
neighborhood: 6, // increase to correctly draw large points
});
Map.addLayer(styled);
// Each sample feature has a point geometry and a property named 'elevation'
// corresponding to the band named 'elevation' of the image. If there are
// multiple bands they will become multiple properties. This will print:
//
// geometry: Point (-110.01, 40.00)
// properties:
// elevation: 1639
print(samples.first());
Python 설정
Python API 및 geemap
를 사용한 대화형 개발에 관한 자세한 내용은
Python 환경 페이지를 참고하세요.
import ee
import geemap.core as geemap
Colab (Python)
# Demonstrate extracting pixels from an image as features with
# ee.Image.sample(), and show how the features are aligned with the pixels.
# An image with one band of elevation data.
image = ee.Image('CGIAR/SRTM90_V4')
vis_min = 1620
vis_max = 1650
m = geemap.Map()
m.add_layer(image, {'min': vis_min, 'max': vis_max}, 'SRTM')
# Region to sample.
region = ee.Geometry.Polygon(
[[
[-110.006, 40.002],
[-110.006, 39.999],
[-109.995, 39.999],
[-109.995, 40.002],
]],
None,
False,
)
# Show region on the map.
m.set_center(-110, 40, 16)
m.add_layer(ee.FeatureCollection([region]).style(color='00FF0022'))
# Perform sampling convert image pixels to features.
samples = image.sample(
region=region,
# Default (False) is no geometries in the output.
# When set to True, each feature has a Point geometry at the center of the
# image pixel.
geometries=True,
# The scale is not specified, so the resolution of the image will be used,
# and there is a feature for every pixel. If we give a scale parameter, the
# image will be resampled and there will be more or fewer features.
#
# scale=200,
)
def scale_point_size(feature):
elevation = feature.getNumber('elevation')
point_size = elevation.unitScale(vis_min, vis_max).multiply(15)
feature.set('style', {'pointSize': point_size})
return feature
# Visualize sample data using ee.FeatureCollection.style().
styled = samples.map(scale_point_size).style(
color='000000FF',
fillColor='00000000',
styleProperty='style',
neighborhood=6, # increase to correctly draw large points
)
m.add_layer(styled)
display(m)
# Each sample feature has a point geometry and a property named 'elevation'
# corresponding to the band named 'elevation' of the image. If there are
# multiple bands they will become multiple properties. This will print:
#
# geometry: Point (-110.01, 40.00)
# properties:
# elevation: 1639
display(samples.first())
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[],[]]