该​​ui.Chart.feature​​​模块包含从渲染图的一组功能​​Feature​​​和​​FeatureCollection​​对象。函数的选择决定了图表中数据的排列方式,即定义 x 轴和 y 轴值的内容以及定义系列的内容。使用以下函数描述和示例来确定最适合您的函数和图表类型。

图表功能总体概述

使用以下绘图作为视觉指南,了解每个函数如何在图表中排列特征及其属性;即,哪些元素定义了 x 值、y 值和系列。

ui.Chart.feature.byFeature

要素按选定属性的值沿 x 轴绘制。系列由属性名称列表定义,其值沿 y 轴绘制。

Google Earth Engine(GEE)——特征和特征集合图表概述和柱状图_GEE

ui.Chart.feature.byProperty

特征属性按名称沿 x 轴绘制;给定属性的值沿 y 轴绘制。系列是由选定属性的值标记的特征。

Google Earth Engine(GEE)——特征和特征集合图表概述和柱状图_echarts_02

ui.Chart.feature.groups

要素按选定属性的值沿 x 轴绘制。系列由给定属性的唯一值定义。Y 轴位置由给定属性的值定义。

Google Earth Engine(GEE)——特征和特征集合图表概述和柱状图_图表_03

ui.Chart.feature.histogram

所选属性值的频率直方图。

  • X 轴:所选属性值的直方图桶
  • Y轴:符合每个直方图桶的特征频率

 简单的举例:

​ui.Chart.feature.byFeature​

从一组特征生成图表。为每个特征绘制一个或多个属性的值:

- X 轴 = 由 xProperty 标记的特征(默认值:'system:index')。

- Y 轴 = yProperties 的值(默认值:所有属性)。

- 系列 = yProperties 的名称。

值沿 x 轴以与输入要素相同的顺序排列。

Generates a Chart from a set of features. Plots the value of one or more properties for each feature:

- X-axis = Features labeled by xProperty (default: 'system:index').

- Y-axis = Values of yProperties (default: all properties).

- Series = Names of yProperties.

The values are ordered along the x-axis in the same order as the input features.

Returns a chart.

Arguments:

功能(功能|功能集合|列表<功能>):
要包含在图表中的功能。

xProperty(字符串,可选):
用作 x 轴上每个要素的值的属性。默认为“系统:索引”。

yProperties(列表<字符串>|字符串,可选):
y 轴上使用的一个或多个属性。如果省略,所有要素的所有属性都将绘制在 y 轴上(xProperty 除外)。

features (Feature|FeatureCollection|List<Feature>):

The features to include in the chart.

xProperty (String, optional):

The property used as the value of each feature on the x-axis. Defaults to 'system:index'.

yProperties (List<String>|String, optional):

Property or properties used on the y-axis. If omitted, all properties of all features will be charted on the y-axis (except xProperty).

Returns: ui.Chart

柱状图

Google Earth Engine(GEE)——特征和特征集合图表概述和柱状图_chart_04

 特征沿 x 轴绘制,由选定属性的值标记。系列由属性名称列表定义的相邻列表示,其值沿 y 轴绘制。

// 导入一个矢量集合
var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example');

// 定义图表并打印到console中
var chart =
ui.Chart.feature
.byFeature({//选择你要表示的波段名称这里是平均温度
features: ecoregions.select('[0-9][0-9]_tmean|label'),
xProperty: 'label',//定义X的属性
})
.setSeriesNames([
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct',
'Nov', 'Dec'
])
.setChartType('ColumnChart')//选择类型
.setOptions({//设定选高管图表参数
title: 'Average Monthly Temperature by Ecoregion',
hAxis:
{title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}},
vAxis: {
title: 'Temperature (°C)',
titleTextStyle: {italic: false, bold: true}
},//图例和图表的内容的颜色
colors: [
'604791', '1d6b99', '39a8a7', '0f8755', '76b349', 'f0af07',
'e37d05', 'cf513e', '96356f', '724173', '9c4f97', '696969'
]
});
print(chart);

下一篇会接着写关于条形图和堆积柱状图!