当前位置: 首页 > news >正文

GEE 图表——sentinel-2和Landsat-8 影像各波段的图表展示和对比

简介

GEE 图表——sentinel-2和Landsat-8 影像各波段的图表展示和对比

函数

ui.Chart.image.regions(image, regionsreducerscaleseriesPropertyxLabels)

Generates a Chart from an image. Extracts and plots the value of each band in one or more regions.

从图像中生成图表。提取并绘制一个或多个区域中每个波段的值。

  • X-axis = Band labeled by xProperty (default: band name).

  • Y-axis = Reducer output.

  • Series = Region labeled by seriesProperty (default: 'system:index').

Returns a chart.

Arguments:

image (Image):

Image to extract band values from.

regions (Feature|FeatureCollection|Geometry|List<Feature>|List<Geometry>, optional):

Regions to reduce. Defaults to the image's footprint.

reducer (Reducer, optional):

Reducer that generates the value(s) for the y-axis. Must return a single value per band.

scale (Number, optional):

The pixel scale in meters.

seriesProperty (String, optional):

Property to be used as the label for each region in the legend. Defaults to 'system:index'.

xLabels (List<Object>, optional):

A list of labels used for bands on the x-axis. Must have the same number of elements as the image bands. If omitted, bands will be labeled with their names. If the labels are numeric (e.g. wavelengths), x-axis will be continuous.

Returns: ui.Chart

setChartType(chartType)

Sets the chartType of this chart.

Returns this chart.

Arguments:

this:ui.chart (ui.Chart):

The ui.Chart instance.

chartType (String):

The chart type; e.g 'ScatterChart', 'LineChart', and 'ColumnChart'. For the complete list of charts, see: https://developers.google.com/chart/interactive/docs/gallery

Returns: ui.Chart

setOptions(options)

Sets options used to style this chart.

Returns this chart.

Arguments:

this:ui.chart (ui.Chart):

The ui.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 options: https://developers.google.com/chart/interactive/docs/customizing_charts

Returns: ui.Chart

代码

/*** 利用哨兵-2 展示光谱特征* 使用哨兵-2 QA 波段屏蔽云层的功能* 参数 {ee.Image} 图像 圣天诺-2 图像* 返回 {ee.Image} 云遮蔽的哨兵-2 图像*/var water = /* color: #0b0dd6 */ee.Geometry.Point([-105.14670897556627, 40.52974114741079]),vegetation = /* color: #5f9f00 */ee.Geometry.Point([-105.1499286288265, 40.56408842507554]),builtUp = /* color: #660404 */ee.Geometry.Point([-105.0799766177181, 40.571912420808935]);var dateStart = '2020-05-01'
var dateEnd = '2020-06-01'
Map.setCenter(-105.0381, 40.5538, 12); //centers on Fort Collins, COfunction maskS2clouds(image) {var qa = image.select('QA60');// Bits 10 and 11 are clouds and cirrus, respectively.var cloudBitMask = 1 << 10;var cirrusBitMask = 1 << 11;// Both flags should be set to zero, indicating clear conditions.var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(qa.bitwiseAnd(cirrusBitMask).eq(0));return image.updateMask(mask).divide(10000);
}var s2 = ee.ImageCollection('COPERNICUS/S2_SR').filterDate(dateStart, dateEnd)// Pre-filter to get less cloudy granules..filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',20)).map(maskS2clouds);var visualization = {min: 0.0,max: 0.3,bands: ['B4', 'B3', 'B2'],
};var COLOR = {WATER: '0b0dd6',VEG: '5f9f00',BUILT: '660404'
};// 绘制光谱特征图
// 三个已知位置。
var fWater = ee.Feature(water, {'label': 'water'});
var fVegetation = ee.Feature(vegetation, {'label': 'veg.'});
var fBuiltUp = ee.Feature(builtUp, {'label': 'built-up'});var LCpoints = ee.FeatureCollection([fWater, fVegetation, fBuiltUp]);
var s2ic = s2.filterBounds(LCpoints)
var s2image = s2ic.mean()var s2image = s2image.select(['B2','B3','B4','B5','B6','B7','B8'])
var bandChart = ui.Chart.image.regions({image: s2image,regions: LCpoints,scale: 10,seriesProperty: 'label'
});
bandChart.setChartType('LineChart');
bandChart.setOptions({title: 'Sentinel-2 TOA band values near Fort Collins, CO',hAxis: {title: 'Band'},vAxis: {title: 'Reflectance'},lineWidth: 2,pointSize: 6,series: {0: {color: COLOR.WATER},1: {color: COLOR.VEG},2: {color: COLOR.BUILT}}
});var wavelengths = [.458, .543, .650, .698, .733, .773, .785];var spectraChart = ui.Chart.image.regions({image: s2image,regions: LCpoints,scale: 30,seriesProperty: 'label',xLabels: wavelengths
});
spectraChart.setChartType('LineChart');
spectraChart.setOptions({title: 'Landsat 8 TOA spectra near Fort Collins, CO',hAxis: {title: 'Wavelength (micrometers)'},vAxis: {title: 'Reflectance'},lineWidth: 2,pointSize: 6,series: {0: {color: COLOR.WATER},1: {color: COLOR.VEG},2: {color: COLOR.BUILT}  }
});Map.addLayer(s2image)
print(bandChart);
print(spectraChart);

结果


http://www.mrgr.cn/news/68973.html

相关文章:

  • uniapp ios app以framwork形式接入sentry
  • SpringCloud 微服务消息队列灰度方案 (RocketMQ 4.x)
  • 使用大语言模型创建 Graph 数据
  • 自动驾驶仿真:软件在环(SIL)测试详解(精简版入门)
  • UE5材质篇 4 材质表面雨滴打落
  • 琐碎笔记——pytest实现前置、后置、参数化、跳过用例执行以及重试
  • 测试-弱网测试使用Fiddler工具(2)
  • 岛屿数量问题
  • 轻松上云:使用Python与阿里云OSS实现文件上传
  • 在研究中经常使用的数据可视化工具并进行分析
  • 文章解读与仿真程序复现思路——电网技术EI\CSCD\北大核心《基于凸多面体仿射变换的用户侧灵活性资源多元聚合方法》
  • 青少年心理韧性测评:多维度视角下的评估与提升
  • 小北的字节跳动青训营与LangChain实战课:深入探索输出解析器与Pydantic解析器重构(持续更新中~~~)
  • python画图|灵活的subplot_mosaic()函数-初逢
  • 搭建react项目
  • 43python数据分析numpy基础之det计算矩阵的行列式
  • STM32H750 COMP模拟比较器
  • 星环大数据平台--TDH部署
  • 有什么初学算法的书籍推荐?
  • 【Syncfusion系列】Diagram 杂谈第一篇
  • 人工智能技术的应用前景及未来发展:改变工作与生活的力量
  • JavaScript 表单
  • 【leetcode】动态规划刷题总结-划分问题
  • pytorch torch.tile用法
  • 大数据-216 数据挖掘 机器学习理论 - KMeans 基于轮廓系数来选择 n_clusters
  • 连锁餐饮收银系统源码(收银端+扫码点餐+自营外卖+营销)