Earth Engine에서 벡터-래스터 변환은 featureCollection.reduceToImage()
메서드로 처리됩니다. 이 메서드는 각 지형지물 아래의 픽셀에 지정된 속성의 값을 할당합니다. 이 예에서는 카운티 데이터를 사용하여 각 카운티의 면적을 나타내는 이미지를 만듭니다.
코드 편집기 (JavaScript)
// Load a collection of US counties. var counties = ee.FeatureCollection('TIGER/2018/Counties'); // Make an image out of the land area attribute. var landAreaImg = counties .filter(ee.Filter.notNull(['ALAND'])) .reduceToImage({ properties: ['ALAND'], reducer: ee.Reducer.first() }); // Display the county land area image. Map.setCenter(-99.976, 40.38, 5); Map.addLayer(landAreaImg, { min: 3e8, max: 1.5e10, palette: ['FCFDBF', 'FDAE78', 'EE605E', 'B63679', '711F81', '2C105C'] });
import ee import geemap.core as geemap
Colab (Python)
# Load a collection of US counties. counties = ee.FeatureCollection('TIGER/2018/Counties') # Make an image out of the land area attribute. land_area_img = counties.filter(ee.Filter.notNull(['ALAND'])).reduceToImage( properties=['ALAND'], reducer=ee.Reducer.first() ) # Display the county land area image. m = geemap.Map() m.set_center(-99.976, 40.38, 5) m.add_layer( land_area_img, { 'min': 3e8, 'max': 1.5e10, 'palette': ['FCFDBF', 'FDAE78', 'EE605E', 'B63679', '711F81', '2C105C'], }, ) m
중복된 지형지물의 속성을 집계하는 방법을 나타내는 감소기를 지정합니다. 이전 예에서는 겹치는 부분이 없으므로 ee.Reducer.first()
으로 충분합니다. 이 예와 같이 데이터를 사전 필터링하여 이미지로 변환할 수 없는 null을 제거합니다.
출력은 색상 그라데이션을 카운티 크기에 매핑하는 그림 1과 같이 표시됩니다. Earth Engine의 모든 이미지 출력 리듀서와 마찬가지로, 크기는 출력에 의해 동적으로 설정됩니다. 이 경우 크기는 코드 편집기의 확대/축소 수준에 해당합니다.

reduceToImage()
가 'TIGER/2018/Counties' FeatureCollection
의 'ALAND'(토지 면적) 속성을 사용한 결과입니다.