ee.FeatureCollection.reduceToImage

각 픽셀과 교차하는 모든 피처의 선택된 속성에 리듀서를 적용하여 피처 컬렉션에서 이미지를 만듭니다.

사용반환 값
FeatureCollection.reduceToImage(properties, reducer)이미지
인수유형세부정보
다음과 같은 경우: collectionFeatureCollection각 출력 픽셀과 교차할 기능 모음입니다.
properties목록각 기능에서 선택하여 리듀서에 전달할 속성입니다.
reducer감소기교차하는 각 기능의 속성을 픽셀에 저장할 최종 결과로 결합하는 리듀서입니다.

코드 편집기 (JavaScript)

// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
             .filter('country_lg == "Belgium"');

// Create an image from features; pixel values are determined from reduction of
// property values of the features intersecting each pixel.
var image = fc.reduceToImage({
  properties: ['gwh_estimt'],
  reducer: ee.Reducer.sum()
});

// The goal is to sum the electricity generated in 2015 for the power plants
// intersecting 10 km cells and view the result as a map layer.
// ee.FeatureCollection.reduceToImage does not allow the image projection to be
// set because it is waiting on downstream functions that include "crs",
// "scale", and "crsTransform" parameters to define it (e.g., Export.image.*).
// Here, we'll force the projection with ee.Image.reproject so the result can be
// viewed in the map. Note that using small scales with reproject while viewing
// large regions breaks the features that make Earth Engine fast and may result
// in poor performance and/or errors.
image = image.reproject('EPSG:3035', null, 10000);

// Display the image on the map.
Map.setCenter(4.3376, 50.947, 8);
Map.setLocked(true);
Map.addLayer(
    image.updateMask(image.gt(0)),
    {min: 0, max: 2000, palette: ['yellow', 'orange', 'red']},
    'Total estimated annual electricity generation, 2015');
Map.addLayer(fc, null, 'Belgian power plants');

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"'
)

# Create an image from features pixel values are determined from reduction of
# property values of the features intersecting each pixel.
image = fc.reduceToImage(properties=['gwh_estimt'], reducer=ee.Reducer.sum())

# The goal is to sum the electricity generated in 2015 for the power plants
# intersecting 10 km cells and view the result as a map layer.
# ee.FeatureCollection.reduceToImage does not allow the image projection to be
# set because it is waiting on downstream functions that include "crs",
# "scale", and "crsTransform" parameters to define it (e.g., Export.image.*).
# Here, we'll force the projection with ee.Image.reproject so the result can be
# viewed in the map. Note that using small scales with reproject while viewing
# large regions breaks the features that make Earth Engine fast and may result
# in poor performance and/or errors.
image = image.reproject('EPSG:3035', None, 10000)

# Display the image on the map.
m = geemap.Map()
m.set_center(4.3376, 50.947, 8)
m.add_layer(
    image.updateMask(image.gt(0)),
    {'min': 0, 'max': 2000, 'palette': ['yellow', 'orange', 'red']},
    'Total estimated annual electricity generation, 2015',
)
m.add_layer(fc, None, 'Belgian power plants')
m