Google earth engine(GEE)——绘制直方图histogram

简介: Google earth engine(GEE)——绘制直方图histogram


很多朋友可能喜欢在GEE中直接进行某些数据的统计和出图,所以今天我们就来讲讲直方图的统计和绘制。

 


首先看看主要用到的GEE当中的方法:

ui.Chart.image.histogram(image, region, scale, maxBuckets, minBucketWidth, maxRaw, maxPixels)


Generates a Chart from an image. Computes and plots histograms of the values of the bands in the specified region of the image.

- X-axis: Histogram buckets (of band value).//恒后一般是你的波段

- Y-axis: Frequency (number of pixels with a band value in the bucket).//相应波段的频率

Returns a chart.


Arguments:

image (Image):

The image to generate a histogram from.

region (Feature|FeatureCollection|Geometry, optional):

The region to reduce. If omitted, uses the entire image.

scale (Number, optional):

The pixel scale used when applying the histogram reducer, in meters.

maxBuckets (Number, optional):

The maximum number of buckets to use when building a histogram; will be rounded up to a power of 2.


构建直方图时使用的最大桶数,也就是列数;将四舍五入到 2 的幂。

minBucketWidth (Number, optional):

The minimum histogram bucket width, or null to allow any power of 2.


最小直方条宽度,或 null 以允许任何 2 的幂。

maxRaw (Number, optional):

The number of values to accumulate before building the initial histogram.


在构建初始直方图之前要累积的值的数量。

maxPixels (Number, optional):

If specified, overrides the maximum number of pixels allowed in the histogram reduction. Defaults to 1e6.


如果指定,则覆盖直方图缩减中允许的最大像素数。默认为 1e6


Returns: ui.Chart

此外还有一个功能要说:

setOptions(options)用于设置你要选择的什么图形,并由很多参数可以设置

DEPRECATED: Use ui.Chart.* instead.目前用这个替代

Sets options used to style this chart.

Returns a new Chart with the passed-in options.


Arguments:

this:chart (Chart):

The Chart instance.

options (Object):

An object defining chart style options such as:

- title (string) The title of the chart.

标题(字符串)图表的标题

- colors (Array) An array of colors used to draw the chart. Its format should follow the Google Visualization API's

颜色(数组)用于绘制图表的颜色数组。其格式应遵循 Google Visualization API 的选项:

options: https://developers.google.com/chart/interactive/docs/customizing_charts

可以将下面的颜色换成

colors: ['#e0440e', '#e6693e', '#ec8f6e', '#f3b49f', '#f6c7b6']

还可以设置长宽:

width: 400,

height: 240,


Returns: Chart

这次用到的数据主要是DEM数据,而且以矩形的形式圈定了一块范围,最后分别统计不同高程处的影像数量。代码很简单:

var elevation = ee.Image('CGIAR/SRTM90_V4');
var colorado = ee.Geometry.Rectangle({
  coords: [-109.05, 37, -102.05, 41],
  geodesic: false
});
// 生成直方图数据.  设置直方图每一条的宽度是多少,或者是2的N次方
var histogram = ui.Chart.image.histogram({
  image: elevation,
  region: colorado,
  scale: 200,
  minBucketWidth: 300
});
histogram.setOptions({
  width: 400,
  height: 240,
  title: 'Histogram of Elevation in Colorado (meters)'
  colors: ['#e0440e', '#e6693e', '#ec8f6e', '#f3b49f', '#f6c7b6']
});
print(histogram);
Map.addLayer(elevation.clip(colorado));
Map.setCenter(-107, 39, 6);


这是选择的美国科罗拉多州的DEM看起来不清晰,因为没有使用相应的色调进行描绘


换了色彩之后是这样的

 



相关文章
|
4月前
|
数据可视化 定位技术 Sentinel
如何用Google Earth Engine快速、大量下载遥感影像数据?
【2月更文挑战第9天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,批量下载指定时间范围、空间范围的遥感影像数据(包括Landsat、Sentinel等)的方法~
1942 1
如何用Google Earth Engine快速、大量下载遥感影像数据?
|
4月前
|
机器学习/深度学习 算法 数据可视化
基于Google Earth Engine云平台构建的多源遥感数据森林地上生物量AGB估算模型含生物量模型应用APP
基于Google Earth Engine云平台构建的多源遥感数据森林地上生物量AGB估算模型含生物量模型应用APP
193 0
|
4月前
GEE——Google dynamic world中在影像导出过程中无法完全导出较大面积影像的解决方案(投影的转换)EPSG:32630和EPSG:4326的区别
GEE——Google dynamic world中在影像导出过程中无法完全导出较大面积影像的解决方案(投影的转换)EPSG:32630和EPSG:4326的区别
92 0
|
4月前
|
存储 编解码 数据可视化
Google Earth Engine获取随机抽样点并均匀分布在栅格的不同数值区中
【2月更文挑战第14天】本文介绍在谷歌地球引擎(Google Earth Engine,GEE)中,按照给定的地表分类数据,对每一种不同的地物类型,分别加以全球范围内随机抽样点自动批量选取的方法~
424 1
Google Earth Engine获取随机抽样点并均匀分布在栅格的不同数值区中
|
4月前
|
API Go 网络架构
GEE Colab——如何从本地/Google云盘/Google Cloud Storage (GCS)上传和下载
GEE Colab——如何从本地/Google云盘/Google Cloud Storage (GCS)上传和下载
241 4
|
4月前
|
机器学习/深度学习 存储 人工智能
GEE Colab——初学者福音快速入门 Google Colab(Colaboratory)
GEE Colab——初学者福音快速入门 Google Colab(Colaboratory)
202 3
|
4月前
|
数据处理
Google Earth Engine(GEE)——sentinel-1数据处理过程中出现错误Dictionary does not contain key: bucketMeans
Google Earth Engine(GEE)——sentinel-1数据处理过程中出现错误Dictionary does not contain key: bucketMeans
80 0
|
4月前
|
编解码 人工智能 算法
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
Google Earth Engine——促进森林温室气体报告的全球时间序列数据集
71 0
|
4月前
|
编解码 人工智能 数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
Google Earth Engine(GEE)——全球道路盘查项目全球道路数据库
100 0
|
4月前
|
编解码
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
Open Google Earth Engine(OEEL)——matrixUnit(...)中产生常量影像
59 0

热门文章

最新文章