Google earth engine(GEE)——平均气温计算并且显示直方图

简介: Google earth engine(GEE)——平均气温计算并且显示直方图


美国三个州的平均气温计算并且显示直方图


完整的图形是这样的


这是我改了代码之后显示了一年十二个月的一个数据,坐标标签直接改成数字了

 


这里面有一个数据集OREGONSTATE/PRISM/Norm81m

用数据的时候可以引用这个文章


Daly, C., Halbleib, M., Smith, J.I., Gibson, W.P., Doggett, M.K., Taylor, G.H., Curtis, J., and Pasteris, P.A. 2008. Physiographically-sensitive mapping of temperature and precipitation across the conterminous United States. International Journal of Climatology, 28: 2031-2064

[Daly, C., J.I. Smith, and K.V. Olson. 2015. Mapping atmospheric moisture climatologies across the conterminous United States. PloS ONE 10(10):e0141140. doi:10.1371/journal.pone.0141140.

ee.Filter.notNull(properties)

如果所有命名属性不为空,则返回一个过滤器。

Returns a filter that passes if all the named properties are not null.


Arguments:

properties (List)过滤的值是一个列表,


Returns: Filter

这次主要用到的函数

ui.Chart.feature.byProperty(features, xProperties, seriesProperty)

Generates a Chart from a set of features. Plots property values of one or more features.

- X-axis = Property name, labeled by xProperties (default: all properties).

- Y-axis = Property value (must be numeric).

- Series = Features, labeled by seriesProperty (default: 'system:index').矢量属性值

All properties except seriesProperty are included on the x-axis by default.

默认情况下,除 seriesProperty 之外的所有属性都包含在 x 轴上。

Returns a chart.


Arguments:

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

The features to include in the chart.

xProperties (List<String>|Object|String, optional):

One of (1) a property to be plotted on the x-axis; (2) a list of properties to be plotted on the x-axis; or (3) a (property, label) dictionary specifying labels for properties to be used as values on the x-axis. If omitted, all properties will be plotted on the x-axis, labeled with their names.

seriesProperty (String, optional):

The name of the property used to label each feature in the legend. Defaults to 'system:index'.


Returns: ui.Chart

通过这个案例就是给出的三个州气温,明尼苏达州,德克萨斯州和佛罗里达州,1月,四月,7月和10月,如果想多个月份,只管在months加入元素即可

//导入研究区
var states = ee.FeatureCollection('TIGER/2018/States');
// 导入温度法线并将月份特征转换为波段。
var normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m')
  .select(['tmean'])
  .toBands();
// 计算每个月每个州的平均值
states = normClim.reduceRegions({
  collection: states,
  reducer: ee.Reducer.mean(),
  scale: 5e4})
  .filter(ee.Filter.notNull(['01_tmean']));
// 计算每个州1月和7月的温度均值然后给与这个州添加温度差值属性
states = states.map(function(state) {
  var julyTemp = ee.Number(state.get('06_tmean'));
  var janTemp = ee.Number(state.get('01_tmean'));
  return state.set('seasonal_delta', julyTemp.subtract(janTemp));
});
// 选择极端的州的天气,通过再次通过merge选取
var extremeStates =
  states.limit(1, '01_tmean')                 // Coldest.
  .merge(states.limit(1, '07_tmean', false))  // Hottest.
  .merge(states.limit(1, 'seasonal_delta'));  // Least variation.
// 分别定义属性值在图表中,对应的月份和对应的温度所匹配
// Define properties to chart.
var months = {
  '01_tmean': 1,
  '02_tmean': 2,
  '03_tmean': 3,
  '04_tmean': 4,
  '05_tmean': 5,
  '06_tmean': 6,
  '07_tmean': 7,
  '08_tmean': 8,
  '09_tmean': 9,
  '10_tmean': 10,
  '11_tmean': 11,
  '12_tmean': 12
};
// Prepare the chart.
var extremeTempsChart =
  ui.Chart.feature.byProperty(extremeStates, months, 'NAME')
    .setChartType('LineChart')
    .setOptions({
      title: 'Average Temperatures in U.S. States',
      hAxis: {
        title: 'Month',
        ticks: [{v: months['01_tmean'], f: 'January'},
                {v: months['02_tmean'], f: '2'},
                {v: months['03_tmean'], f: '3'},
                {v: months['04_tmean'], f: 'April'},
                {v: months['05_tmean'], f: '5'},
                {v: months['06_tmean'], f: '6'},
                {v: months['07_tmean'], f: 'July'},                
                {v: months['08_tmean'], f: '8'},
                {v: months['09_tmean'], f: '9'},
                {v: months['10_tmean'], f: 'October'},
                {v: months['11_tmean'], f: '11'},
                {v: months['12_tmean'], f: '12'},]
      },
      vAxis: {
        title: 'Temperature (Celsius)'
      },
      lineWidth: 1,
      pointSize: 3
    });
print(extremeTempsChart);


相关文章
|
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——促进森林温室气体报告的全球时间序列数据集
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
|
4月前
Google Earth Engine(GEE)——导出指定区域的河流和流域范围
Google Earth Engine(GEE)——导出指定区域的河流和流域范围
174 0

热门文章

最新文章