前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Google Earth Engine(GEE)——矢量柱状图和组图

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

作者头像
此星光明
发布2024-02-02 08:10:50
1500
发布2024-02-02 08:10:50
举报

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 中的元素数。

代码语言:javascript
复制
// 加载 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)

代码语言:javascript
复制
从一组特征生成图表。绘制跨要素组的给定属性的值。具有相同 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')

代码语言:javascript
复制
// 导入案例数据资料
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);
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-02-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • ui.Chart.feature.histogram
    • Arguments:
      • Returns: ui.Chart
      • ui.Chart.feature.groups
        • Arguments:
          • Returns: ui.Chart
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档