ui.Chart.image.histogram
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สร้างแผนภูมิจากรูปภาพ คำนวณและพล็อตฮิสโตแกรมของค่าแถบในภูมิภาคที่ระบุของรูปภาพ
- แกน X: ที่เก็บข้อมูลฮิสโตแกรม (ของค่าแถบ)
- แกน Y: ความถี่ (จำนวนพิกเซลที่มีค่าแถบในกลุ่ม)
แสดงผลแผนภูมิ
การใช้งาน | การคืนสินค้า |
---|
ui.Chart.image.histogram(image, region, scale, maxBuckets, minBucketWidth, maxRaw, maxPixels) | ui.Chart |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
image | รูปภาพ | รูปภาพที่จะสร้างฮิสโทแกรม |
region | Feature|FeatureCollection|Geometry, ไม่บังคับ | ภูมิภาคที่จะลด หากละไว้ ให้ใช้ทั้งรูปภาพ |
scale | หมายเลข (ไม่บังคับ) | มาตราส่วนพิกเซลที่ใช้เมื่อใช้ตัวลดฮิสโตแกรมในหน่วยเมตร |
maxBuckets | หมายเลข (ไม่บังคับ) | จำนวนที่เก็บข้อมูลสูงสุดที่จะใช้เมื่อสร้างฮิสโตแกรม โดยจะปัดขึ้นเป็นเลขยกกำลังของ 2 |
minBucketWidth | หมายเลข (ไม่บังคับ) | ความกว้างของ Bucket ฮิสโทแกรมขั้นต่ำ หรือ null เพื่ออนุญาตให้ใช้กำลัง 2 ใดก็ได้ |
maxRaw | หมายเลข (ไม่บังคับ) | จำนวนค่าที่จะสะสมก่อนสร้างฮิสโทแกรมเริ่มต้น |
maxPixels | หมายเลข (ไม่บังคับ) | หากระบุไว้ จะลบล้างจำนวนพิกเซลสูงสุดที่อนุญาตในการลดฮิสโทแกรม ค่าเริ่มต้นคือ 1e6 |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (JavaScript)
// Define a MODIS surface reflectance composite.
var modisSr = ee.ImageCollection('MODIS/006/MOD09A1')
.filter(ee.Filter.date('2018-06-01', '2018-09-01'))
.select(['sur_refl_b01', 'sur_refl_b02', 'sur_refl_b06'])
.mean();
// Define a region to calculate histogram for.
var histRegion = ee.Geometry.Rectangle([-112.60, 40.60, -111.18, 41.22]);
// Define the chart and print it to the console.
var chart =
ui.Chart.image.histogram({image: modisSr, region: histRegion, scale: 500})
.setSeriesNames(['Red', 'NIR', 'SWIR'])
.setOptions({
title: 'MODIS SR Reflectance Histogram',
hAxis: {
title: 'Reflectance (scaled by 1e4)',
titleTextStyle: {italic: false, bold: true},
},
vAxis:
{title: 'Count', titleTextStyle: {italic: false, bold: true}},
colors: ['cf513e', '1d6b99', 'f0af07']
});
print(chart);
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eGenerates a chart displaying the frequency distribution of pixel values within a specified image region.\u003c/p\u003e\n"],["\u003cp\u003eThe chart plots histograms for each band of the image, showing the number of pixels with values falling within specific ranges (buckets).\u003c/p\u003e\n"],["\u003cp\u003eUsers can customize the chart by defining the region, scale, and bucket parameters, as well as the maximum number of input values and pixels used in the calculation.\u003c/p\u003e\n"],["\u003cp\u003eThe chart is rendered with customizable axes, titles, and color options for each band.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eui.Chart.image.histogram()\u003c/code\u003e returns a \u003ccode\u003eui.Chart\u003c/code\u003e object, allowing for further manipulation and display within the Earth Engine Code Editor.\u003c/p\u003e\n"]]],["This code generates a histogram chart from an image, plotting band values against their frequency. It utilizes `ui.Chart.image.histogram` with arguments like `image`, `region`, and `scale` to define the data and spatial parameters. Optional settings include `maxBuckets`, `minBucketWidth`, `maxRaw`, and `maxPixels`. The x-axis represents histogram buckets (band value), while the y-axis shows frequency (pixel count). The example demonstrates its application with MODIS surface reflectance data, defining a region and customizing chart appearance.\n"],null,["# ui.Chart.image.histogram\n\n\u003cbr /\u003e\n\nGenerates a Chart from an image. Computes and plots histograms of the values of the bands in the specified region of the image.\n\n\u003cbr /\u003e\n\n- X-axis: Histogram buckets (of band value).\n\n- Y-axis: Frequency (number of pixels with a band value in the bucket).\n\nReturns a chart.\n\n| Usage | Returns |\n|------------------------------------------------------------------------------------------------------------------------------|----------|\n| `ui.Chart.image.histogram(image, `*region* `, `*scale* `, `*maxBuckets* `, `*minBucketWidth* `, `*maxRaw* `, `*maxPixels*`)` | ui.Chart |\n\n| Argument | Type | Details |\n|------------------|------------------------------------------------|-----------------------------------------------------------------------------------------------------------|\n| `image` | Image | The image to generate a histogram from. |\n| `region` | Feature\\|FeatureCollection\\|Geometry, optional | The region to reduce. If omitted, uses the entire image. |\n| `scale` | Number, optional | The pixel scale used when applying the histogram reducer, in meters. |\n| `maxBuckets` | Number, optional | The maximum number of buckets to use when building a histogram; will be rounded up to a power of 2. |\n| `minBucketWidth` | Number, optional | The minimum histogram bucket width, or null to allow any power of 2. |\n| `maxRaw` | Number, optional | The number of values to accumulate before building the initial histogram. |\n| `maxPixels` | Number, optional | If specified, overrides the maximum number of pixels allowed in the histogram reduction. Defaults to 1e6. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Define a MODIS surface reflectance composite.\nvar modisSr = ee.ImageCollection('MODIS/006/MOD09A1')\n .filter(ee.Filter.date('2018-06-01', '2018-09-01'))\n .select(['sur_refl_b01', 'sur_refl_b02', 'sur_refl_b06'])\n .mean();\n\n// Define a region to calculate histogram for.\nvar histRegion = ee.Geometry.Rectangle([-112.60, 40.60, -111.18, 41.22]);\n\n// Define the chart and print it to the console.\nvar chart =\n ui.Chart.image.histogram({image: modisSr, region: histRegion, scale: 500})\n .setSeriesNames(['Red', 'NIR', 'SWIR'])\n .setOptions({\n title: 'MODIS SR Reflectance Histogram',\n hAxis: {\n title: 'Reflectance (scaled by 1e4)',\n titleTextStyle: {italic: false, bold: true},\n },\n vAxis:\n {title: 'Count', titleTextStyle: {italic: false, bold: true}},\n colors: ['cf513e', '1d6b99', 'f0af07']\n });\nprint(chart);\n```"]]