- X 轴:直方图分桶(频段值)。
- Y 轴:频次(具有相应波段值的像素数量)。
返回图表。
用法 | 返回 |
---|---|
ui.Chart.image.histogram(image, region, scale, maxBuckets, minBucketWidth, maxRaw, maxPixels) | ui.Chart |
参数 | 类型 | 详细信息 |
---|---|---|
image | 图片 | 要从中生成直方图的图片。 |
region | Feature|FeatureCollection|Geometry,可选 | 要缩减的区域。如果省略,则使用整个图片。 |
scale | 数字,可选 | 应用直方图缩减器时使用的像素比例(以米为单位)。 |
maxBuckets | 数字,可选 | 构建直方图时要使用的最大分桶数;将向上舍入为 2 的幂。 |
minBucketWidth | 数字,可选 | 最小直方图分桶宽度,如果为 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);