Google Earth Engine(GEE)——矢量柱状图和组图

ui.Chart.feature.histogram

ui.Chart.feature.histogram(features, property, maxBucketsminBucketWidthmaxRaw)

Generates a Chart from a set of features. Computes and plots a histogram of the given property.

- X-axis = Histogram buckets (of property value).

- Y-axis = Frequency (i.e. the number of features whose value of property lands within the x-axis bucket bounds).

Returns a chart.

Arguments:

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

The features to include in the chart.

property (String):

The name of the property to generate the histogram for.

maxBuckets (Number, optional):

The maximum number of buckets to use when building a histogram; will be rounded up to a power of 2. Not used when the value of property is non-numeric.

minBucketWidth (Number, optional):

The minimum histogram bucket width, or null to allow any power of 2. Not used when property is non-numeric.

maxRaw (Number, optional):

The number of values to accumulate before building the initial histogram. Not used when property is non-numeric.

Returns: ui.Chart

x 轴由选定属性值范围的值箱定义;y 轴是给定 bin 中的元素数。

 
// 加载 PRISM 气候法线图像集合;将图像转换为波段。
var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands();

// 为美国西部的一个地区制作气候变量的点样本。
var region = ee.Geometry.Rectangle(-123.41, 40.43, -116.38, 45.14);
var climSamp = normClim.sample(region, 5000);

// 定义图表并将其打印到控制台。
var chart =
    ui.Chart.feature//这里柱状图的函数是直接应用的
        .histogram({features: climSamp, property: '07_ppt', maxBuckets: 30})
        .setOptions({
          title: 'July Precipitation Distribution for NW USA',
          hAxis: {
            title: 'Precipitation (mm)',
            titleTextStyle: {italic: false, bold: true}
          },
          vAxis: {
            title: 'Pixel count',
            titleTextStyle: {italic: false, bold: true}
          },
          colors: ['1d6b99'],
          legend: {position: 'none'}
        });
print(chart);

ui.Chart.feature.groups

ui.Chart.feature.groups(features, xProperty, yProperty, seriesProperty)

从一组特征生成图表。绘制跨要素组的给定属性的值。具有相同 groupProperty 值的要素将被分组并绘制为单个系列。

Generates a Chart from a set of features. Plots the value of a given property across groups of features. Features with the same value of groupProperty will be grouped and plotted as a single series.

- X-axis = xProperty values.

- Y-axis = yProperty values.

- Series = Feature groups, by seriesProperty.

Returns a chart.

Arguments:

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

The features to include in the chart.

xProperty (String):

Property to be used as the label for each feature on the x-axis.

yProperty (String):

Property to be plotted on the y-axis.

seriesProperty (String):

Property used to determine feature groups. Features with the same value of groupProperty will be plotted as a single series on the chart.

Returns: ui.Chart

 特征沿 x 轴绘制,由选定属性的值标记。系列由给定属性的唯一值集定义的列表示。Y 轴位置由给定属性的值定义。通过将图表类型设置为'ScatterChart'.setChartType('ScatterChart')),可以将此图更改为散点图 。或者,如果时间为x轴的变量,你可能更愿意使用一个折线图: .setChartType('LineChart')

// 导入案例数据资料
var ecoregions = ee.FeatureCollection('projects/google/charts_feature_example');

// 设置图标
var chart =
    ui.Chart.feature
        .groups({设置组内的信息,
          features: ecoregions,
          xProperty: 'label',
          yProperty: '01_tmean',
          seriesProperty: 'warm'
        })
        .setSeriesNames(['Warm', 'Cold'])
        .setChartType('ColumnChart')
        .setOptions({
          title: 'Average January Temperature by Ecoregion',
          hAxis:
              {title: 'Ecoregion', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'Jan temp (°C)',
            titleTextStyle: {italic: false, bold: true}
          },
          bar: {groupWidth: '80%'},
          colors: ['cf513e', '1d6b99'],
          isStacked: true
        });
print(chart);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此星光明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值