ee.ImageCollection.reduceToImage
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สร้างรูปภาพจาก FeatureCollection โดยใช้ Reducer กับพร็อพเพอร์ตี้ที่เลือกของฟีเจอร์ทั้งหมดที่ตัดกับแต่ละพิกเซล
การใช้งาน | การคืนสินค้า |
---|
ImageCollection.reduceToImage(properties, reducer) | รูปภาพ |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
ดังนี้ collection | FeatureCollection | ชุดฟีเจอร์ที่จะตัดกับพิกเซลเอาต์พุตแต่ละพิกเซล |
properties | รายการ | พร็อพเพอร์ตี้ที่จะเลือกจากแต่ละฟีเจอร์และส่งไปยังตัวลด |
reducer | ตัวลดตำแหน่ง | ตัวลดเพื่อรวมคุณสมบัติของฟีเจอร์ที่ตัดกันแต่ละรายการเป็นผลลัพธ์สุดท้ายเพื่อจัดเก็บในพิกเซล |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (JavaScript)
var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
.filterBounds(ee.Geometry.BBox(-124.0, 43.2, -116.5, 46.3))
.filterDate('2021', '2022');
// Image visualization settings.
var visParams = {
bands: ['B4', 'B3', 'B2'],
min: 0.01,
max: 0.25
};
Map.addLayer(col.mean(), visParams, 'RGB mean');
// Reduce the geometry (footprint) of images in the collection to an image.
// Image property values are applied to the pixels intersecting each
// image's geometry and then a per-pixel reduction is performed according
// to the selected reducer. Here, the image cloud cover property is assigned
// to the pixels intersecting image geometry and then reduced to a single
// image representing the per-pixel mean image cloud cover.
var meanCloudCover = col.reduceToImage({
properties: ['CLOUD_COVER'],
reducer: ee.Reducer.mean()
});
Map.setCenter(-119.87, 44.76, 6);
Map.addLayer(meanCloudCover, {min: 0, max: 50}, 'Cloud cover mean');
การตั้งค่า Python
ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap
เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
import ee
import geemap.core as geemap
Colab (Python)
col = (
ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')
.filterBounds(ee.Geometry.BBox(-124.0, 43.2, -116.5, 46.3))
.filterDate('2021', '2022')
)
# Image visualization settings.
vis_params = {'bands': ['B4', 'B3', 'B2'], 'min': 0.01, 'max': 0.25}
m = geemap.Map()
m.add_layer(col.mean(), vis_params, 'RGB mean')
# Reduce the geometry (footprint) of images in the collection to an image.
# Image property values are applied to the pixels intersecting each
# image's geometry and then a per-pixel reduction is performed according
# to the selected reducer. Here, the image cloud cover property is assigned
# to the pixels intersecting image geometry and then reduced to a single
# image representing the per-pixel mean image cloud cover.
mean_cloud_cover = col.reduceToImage(
properties=['CLOUD_COVER'], reducer=ee.Reducer.mean()
)
m.set_center(-119.87, 44.76, 6)
m.add_layer(mean_cloud_cover, {'min': 0, 'max': 50}, 'Cloud cover mean')
m
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003ereduceToImage\u003c/code\u003e transforms an image collection into a single image by applying a reducer to pixel-intersecting features.\u003c/p\u003e\n"],["\u003cp\u003eIt uses specified properties from each feature within the collection for the reduction process.\u003c/p\u003e\n"],["\u003cp\u003eUsers define a reducer (e.g., mean, median) to combine intersecting feature properties into a final pixel value in the output image.\u003c/p\u003e\n"],["\u003cp\u003eThis function is helpful for tasks like calculating mean cloud cover across a collection of satellite images, as shown in the provided example.\u003c/p\u003e\n"]]],[],null,["# ee.ImageCollection.reduceToImage\n\nCreates an image from a feature collection by applying a reducer over the selected properties of all the features that intersect each pixel.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------------------------------|---------|\n| ImageCollection.reduceToImage`(properties, reducer)` | Image |\n\n| Argument | Type | Details |\n|--------------------|-------------------|-------------------------------------------------------------------------------------------------------------|\n| this: `collection` | FeatureCollection | Feature collection to intersect with each output pixel. |\n| `properties` | List | Properties to select from each feature and pass into the reducer. |\n| `reducer` | Reducer | A Reducer to combine the properties of each intersecting feature into a final result to store in the pixel. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nvar col = ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.BBox(-124.0, 43.2, -116.5, 46.3))\n .filterDate('2021', '2022');\n\n// Image visualization settings.\nvar visParams = {\n bands: ['B4', 'B3', 'B2'],\n min: 0.01,\n max: 0.25\n};\nMap.addLayer(col.mean(), visParams, 'RGB mean');\n\n// Reduce the geometry (footprint) of images in the collection to an image.\n// Image property values are applied to the pixels intersecting each\n// image's geometry and then a per-pixel reduction is performed according\n// to the selected reducer. Here, the image cloud cover property is assigned\n// to the pixels intersecting image geometry and then reduced to a single\n// image representing the per-pixel mean image cloud cover.\nvar meanCloudCover = col.reduceToImage({\n properties: ['CLOUD_COVER'],\n reducer: ee.Reducer.mean()\n});\n\nMap.setCenter(-119.87, 44.76, 6);\nMap.addLayer(meanCloudCover, {min: 0, max: 50}, 'Cloud cover mean');\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\ncol = (\n ee.ImageCollection('LANDSAT/LC08/C02/T1_TOA')\n .filterBounds(ee.Geometry.BBox(-124.0, 43.2, -116.5, 46.3))\n .filterDate('2021', '2022')\n)\n\n# Image visualization settings.\nvis_params = {'bands': ['B4', 'B3', 'B2'], 'min': 0.01, 'max': 0.25}\nm = geemap.Map()\nm.add_layer(col.mean(), vis_params, 'RGB mean')\n\n# Reduce the geometry (footprint) of images in the collection to an image.\n# Image property values are applied to the pixels intersecting each\n# image's geometry and then a per-pixel reduction is performed according\n# to the selected reducer. Here, the image cloud cover property is assigned\n# to the pixels intersecting image geometry and then reduced to a single\n# image representing the per-pixel mean image cloud cover.\nmean_cloud_cover = col.reduceToImage(\n properties=['CLOUD_COVER'], reducer=ee.Reducer.mean()\n)\n\nm.set_center(-119.87, 44.76, 6)\nm.add_layer(mean_cloud_cover, {'min': 0, 'max': 50}, 'Cloud cover mean')\nm\n```"]]