ภาพรวมของตัวลด
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ตัวลดข้อมูลเป็นวิธีรวบรวมข้อมูลตามช่วงเวลา พื้นที่ แถบ อาร์เรย์ และโครงสร้างข้อมูลอื่นๆ ใน Earth Engine คลาส ee.Reducer
จะระบุวิธีรวบรวมข้อมูล ตัวลดขนาดในคลาสนี้สามารถระบุสถิติง่ายๆ เพื่อใช้สำหรับการรวม (เช่น ค่าต่ำสุด ค่าสูงสุด ค่าเฉลี่ย ค่ามัธยฐาน ค่าเบี่ยงเบนมาตรฐาน ฯลฯ) หรือสรุปข้อมูลอินพุตที่ซับซ้อนมากขึ้น (เช่น ฮิสโตแกรม การหาค่าสัมประสิทธ์เชิงเส้น รายการ) การลดอาจเกิดขึ้นเมื่อเวลาผ่านไป (imageCollection.reduce()
), พื้นที่ (image.reduceRegion()
,
image.reduceNeighborhood()
), แบนด์ (image.reduce()
) หรือพื้นที่แอตทริบิวต์ของ FeatureCollection
(featureCollection.reduceColumns()
หรือเมธอด FeatureCollection
ที่ขึ้นต้นด้วย aggregate_
)
ตัวลดจะนําชุดข้อมูลอินพุตไปสร้างเอาต์พุตรายการเดียว เมื่อใช้ตัวลดข้อมูลอินพุตรายการเดียวกับรูปภาพหลายย่านความถี่ Earth Engine จะทําซ้ำตัวลดข้อมูลนั้นโดยอัตโนมัติและใช้กับแต่ละย่านความถี่แยกกัน ด้วยเหตุนี้ รูปภาพเอาต์พุตจึงมีจำนวนแถบเท่ากับรูปภาพอินพุต โดยแต่ละแถบในเอาต์พุตเป็นการลดจำนวนพิกเซลจากแถบที่เกี่ยวข้องในข้อมูลอินพุต ตัวลดบางรายการใช้ทูเพลตของชุดข้อมูลอินพุต ระบบจะไม่ทำซ้ำตัวลดขนาดเหล่านี้โดยอัตโนมัติสำหรับแต่ละย่านความถี่ ตัวอย่างเช่น ee.Reducer.LinearRegression()
จะนําชุดข้อมูลตัวทำนายหลายชุด (แสดงตัวแปรอิสระในการถดถอย) ตามลําดับที่เจาะจง (ดูตัวลดการถดถอย)
ตัวลดบางรายการจะสร้างเอาต์พุตหลายรายการ เช่น ee.Reducer.minMax()
,
ee.Reducer.histogram()
หรือ ee.Reducer.toList()
เช่น
เครื่องมือแก้ไขโค้ด (JavaScript)
// Load and filter the Sentinel-2 image collection.
var collection = ee.ImageCollection('COPERNICUS/S2_HARMONIZED')
.filterDate('2016-01-01', '2016-12-31')
.filterBounds(ee.Geometry.Point([-81.31, 29.90]));
// Reduce the collection.
var extrema = collection.reduce(ee.Reducer.minMax());
การตั้งค่า Python
ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap
สําหรับการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
import ee
import geemap.core as geemap
Colab (Python)
# Load and filter the Sentinel-2 image collection.
collection = (
ee.ImageCollection('COPERNICUS/S2_HARMONIZED')
.filterDate('2016-01-01', '2016-12-31')
.filterBounds(ee.Geometry.Point([-81.31, 29.90]))
)
# Reduce the collection.
extrema = collection.reduce(ee.Reducer.minMax())
ซึ่งจะสร้างเอาต์พุตที่มีจำนวนแถบเป็น 2 เท่าของอินพุต โดยชื่อแถบในเอาต์พุตจะมี "_min" หรือ "_max" ต่อท้ายชื่อแถบ
ประเภทเอาต์พุตควรตรงกับการคํานวณ เช่น ตัวลดที่ใช้กับ ImageCollection
จะให้เอาต์พุตเป็น Image
เนื่องจากระบบจะตีความเอาต์พุตเป็นค่าพิกเซล คุณจึงต้องใช้ตัวลดที่มีเอาต์พุตที่เป็นตัวเลขเพื่อลด ImageCollection
(ตัวลดอย่าง toList()
หรือ histogram()
จะใช้ไม่ได้)
โดยค่าเริ่มต้น การลดค่าพิกเซลจะถ่วงน้ำหนักตามมาสก์ แต่คุณเปลี่ยนลักษณะการทํางานนี้ได้ (ดูส่วนการถ่วงน้ำหนัก) ระบบจะไม่ใช้พิกเซลที่มีมาสก์เท่ากับ 0 ในการลดขนาด
การรวมตัวลด
หากต้องการใช้ตัวลดหลายรายการกับอินพุตเดียวกัน คุณควรcombine()
ตัวลดเพื่อประสิทธิภาพ กล่าวโดยละเอียดคือ การเรียกใช้ combine()
ในรีดิวเซอร์ที่มีการตั้งค่า sharedInputs
เป็น true
จะส่งผลให้มีการเรียกใช้ข้อมูลเพียงครั้งเดียว เช่น หากต้องการคํานวณค่าเฉลี่ยและค่าเบี่ยงเบนมาตรฐานของพิกเซลในรูปภาพ คุณอาจใช้โค้ดประมาณนี้
เครื่องมือแก้ไขโค้ด (JavaScript)
// Load a Landsat 8 image.
var image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318');
// Combine the mean and standard deviation reducers.
var reducers = ee.Reducer.mean().combine({
reducer2: ee.Reducer.stdDev(),
sharedInputs: true
});
// Use the combined reducer to get the mean and SD of the image.
var stats = image.reduceRegion({
reducer: reducers,
bestEffort: true,
});
// Display the dictionary of band means and SDs.
print(stats);
การตั้งค่า Python
ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap
สําหรับการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
import ee
import geemap.core as geemap
Colab (Python)
# Load a Landsat 8 image.
image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318')
# Combine the mean and standard deviation reducers.
reducers = ee.Reducer.mean().combine(
reducer2=ee.Reducer.stdDev(), sharedInputs=True
)
# Use the combined reducer to get the mean and SD of the image.
stats = image.reduceRegion(reducer=reducers, bestEffort=True)
# Display the dictionary of band means and SDs.
display(stats)
ในเอาต์พุต โปรดทราบว่าระบบได้เพิ่มชื่อตัวลดขนาดต่อท้ายชื่ออินพุตเพื่อแยกเอาต์พุตของตัวลดขนาด ลักษณะการทำงานนี้มีผลกับเอาต์พุตรูปภาพด้วย ซึ่งจะมีชื่อของตัวลดต่อท้ายชื่อแบนด์เอาต์พุต
หากคุณกำลังรวมตัวลดที่ใช้อินพุตที่ไม่มีน้ำหนักเข้ากับตัวลดที่ใช้อินพุตที่มีน้ำหนัก อินพุตที่มีน้ำหนักทั้งหมดต้องอยู่ก่อนอินพุตที่ไม่มีน้ำหนักทั้งหมด
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\u003cp\u003eReducers in Earth Engine aggregate data over time, space, bands, arrays, and other data structures, using methods like \u003ccode\u003ereduceRegion()\u003c/code\u003e and \u003ccode\u003ereduce()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eReducers can calculate simple statistics (e.g., mean, minimum) or more complex summaries (e.g., histograms, linear regressions) on images, image collections, and feature collections.\u003c/p\u003e\n"],["\u003cp\u003eWhen applied to multi-band images, single input reducers are automatically applied to each band, producing an output with the same number of bands.\u003c/p\u003e\n"],["\u003cp\u003eReducers can be combined using \u003ccode\u003ecombine()\u003c/code\u003e for efficient processing, allowing multiple calculations in a single pass over the data.\u003c/p\u003e\n"],["\u003cp\u003eBy default, pixel values in reductions are weighted by their mask, meaning pixels with a mask of 0 are excluded from the calculation.\u003c/p\u003e\n"]]],[],null,["# Reducer Overview\n\nReducers are the way to aggregate data over time, space, bands, arrays and other data\nstructures in Earth Engine. The `ee.Reducer` class specifies how data is\naggregated. The reducers in this class can specify a simple statistic to use for the\naggregation (e.g. minimum, maximum, mean, median, standard deviation, etc.), or a more complex\nsummary of the input data (e.g. histogram, linear regression, list). Reductions may occur over\ntime (`imageCollection.reduce()`), space (`image.reduceRegion()`,\n`image.reduceNeighborhood()`), bands (`image.reduce()`), or the\nattribute space of a `FeatureCollection` (`featureCollection.reduceColumns()`\nor `FeatureCollection` methods that start with `aggregate_`).\n\nReducers have inputs and outputs\n--------------------------------\n\n\nReducers take an input dataset and produce a single output. When a single input reducer is\napplied to a multi-band image, Earth Engine automatically replicates the reducer and applies\nit separately to each band. As a result, the output image has the same number of bands as the\ninput image; each band in the output is the reduction of pixels from the corresponding band in\nthe input data. Some reducers take tuples of input datasets. These reducers will not be\nautomatically replicated for each band. For example,\n`ee.Reducer.LinearRegression()` takes multiple predictor datasets (representing\nindependent variables in the regression) in a particular order (see\n[Regression reducers](/earth-engine/guides/reducers_regression)).\n\n\nSome reducers produce multiple outputs, for example `ee.Reducer.minMax()`,\n`ee.Reducer.histogram()` or `ee.Reducer.toList()`. For example:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load and filter the Sentinel-2 image collection.\nvar collection = ee.ImageCollection('COPERNICUS/S2_HARMONIZED')\n .filterDate('2016-01-01', '2016-12-31')\n .filterBounds(ee.Geometry.Point([-81.31, 29.90]));\n\n// Reduce the collection.\nvar extrema = collection.reduce(ee.Reducer.minMax());\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\n# Load and filter the Sentinel-2 image collection.\ncollection = (\n ee.ImageCollection('COPERNICUS/S2_HARMONIZED')\n .filterDate('2016-01-01', '2016-12-31')\n .filterBounds(ee.Geometry.Point([-81.31, 29.90]))\n)\n\n# Reduce the collection.\nextrema = collection.reduce(ee.Reducer.minMax())\n```\n\n\nThis will produce an output with twice the number of bands of the inputs, where band names in\nthe output have '_min' or '_max' appended to the band name.\n\n\nThe output type should match the computation. For example, a reducer applied to an\n`ImageCollection` has an `Image` output. Because the output is\ninterpreted as a pixel value, you must use reducers with a numeric output to reduce an\n`ImageCollection` (reducers like `toList()` or\n`histogram()` won't work).\n\nReducers use weighted inputs\n----------------------------\n\n\nBy default, reductions over pixel values are weighted by their mask, though this behavior can\nbe changed (see the [Weighting section](/earth-engine/guides/reducers_weighting)). Pixels with mask\nequal to 0 will not be used in the reduction.\n\nCombining reducers\n------------------\n\n\nIf your intent is to apply multiple reducers to the same inputs, it's good practice to\n`combine()` the reducers for efficiency. Specifically, calling\n`combine()` on a reducer with `sharedInputs` set to\n`true` will result in only a single pass over the data. For example, to compute the\nmean and standard deviation of pixels in an image, you could use something like this:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a Landsat 8 image.\nvar image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318');\n\n// Combine the mean and standard deviation reducers.\nvar reducers = ee.Reducer.mean().combine({\n reducer2: ee.Reducer.stdDev(),\n sharedInputs: true\n});\n\n// Use the combined reducer to get the mean and SD of the image.\nvar stats = image.reduceRegion({\n reducer: reducers,\n bestEffort: true,\n});\n\n// Display the dictionary of band means and SDs.\nprint(stats);\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\n# Load a Landsat 8 image.\nimage = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318')\n\n# Combine the mean and standard deviation reducers.\nreducers = ee.Reducer.mean().combine(\n reducer2=ee.Reducer.stdDev(), sharedInputs=True\n)\n\n# Use the combined reducer to get the mean and SD of the image.\nstats = image.reduceRegion(reducer=reducers, bestEffort=True)\n\n# Display the dictionary of band means and SDs.\ndisplay(stats)\n```\n\n\nIn the output, note that the names of the reducers have been appended to the names of the\ninputs to distinguish the reducer outputs. This behavior also applies to image outputs, which\nwill have the name of the reducer appended to output band names.\n\n\nIf you are combining reducers using unweighted inputs and reducers using weighted inputs, all\nweighted inputs must be before all unweighted inputs."]]