Send feedback
ee.FeatureCollection.reduceToImage
Stay organized with collections
Save and categorize content based on your preferences.
Creates an image from a feature collection by applying a reducer over the selected properties of all the features that intersect each pixel.
Usage Returns FeatureCollection. reduceToImage (properties, reducer)
Image
Argument Type Details this: collection
FeatureCollection Feature collection to intersect with each output pixel. properties
List Properties to select from each feature and pass into the reducer. reducer
Reducer A Reducer to combine the properties of each intersecting feature into a final result to store in the pixel.
Examples
Code Editor (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 setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
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
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["`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`."]]],[]]