公告 :所有在
2025 年 4 月 15 日 之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件 ,才能继续使用 Earth Engine。
发送反馈
ee.FeatureCollection.reduceToImage
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
通过对与每个像素相交的所有要素的所选属性应用归约函数,从要素集合创建图像。
用法 返回 FeatureCollection. reduceToImage (properties, reducer)
图片
参数 类型 详细信息 此:collection
FeatureCollection 要与每个输出像素相交的要素集合。 properties
列表 要从每个特征中选择并传递到 reducer 中的属性。 reducer
缩减器 一种用于将每个相交要素的属性合并到最终结果中以存储在像素中的 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
发送反馈
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可 获得了许可,并且代码示例已根据 Apache 2.0 许可 获得了许可。有关详情,请参阅 Google 开发者网站政策 。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
需要向我们提供更多信息?
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-26。"],[[["`reduceToImage` creates an image from a FeatureCollection by applying a reducer to feature properties within each pixel."],["The reducer combines the properties of features intersecting a pixel into a single pixel value in the output image."],["You must specify the properties to include and the reducer to use when calling `reduceToImage`."],["Output image projection is determined by subsequent operations like `reproject` or `Export`."]]],[]]