ee.FeatureCollection.reduceToImage

यह फ़ंक्शन, फ़ीचर कलेक्शन से इमेज बनाता है. इसके लिए, यह फ़ंक्शन उन सभी फ़ीचर की चुनी गई प्रॉपर्टी पर रिड्यूसर लागू करता है जो हर पिक्सल को इंटरसेक्ट करती हैं.

इस्तेमालरिटर्न
FeatureCollection.reduceToImage(properties, reducer)इमेज
आर्ग्यूमेंटटाइपविवरण
यह: collectionFeatureCollectionहर आउटपुट पिक्सल के साथ इंटरसेक्ट करने के लिए, फ़ीचर कलेक्शन.
propertiesसूचीहर सुविधा से चुनने के लिए प्रॉपर्टी और उन्हें रिड्यूसर में पास करने के लिए प्रॉपर्टी.
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