Google earth engine(GEE)——在GEE地图上加载图表

简介: Google earth engine(GEE)——在GEE地图上加载图表


本次是加载一个折线图在地图上,主要是展现波段的平均值,重点是如何放在地图上,先看重点:


ui.Chart.image.series(imageCollection, region, reducer, scale, xProperty)

Generates a Chart from an ImageCollection. Plots derived values of each band in a region across images. Usually a time series.

- X-axis: Image, labeled by xProperty value.

- Y-axis: Band value.

- Series: Band names.//波段名字作为序列也就是要显示的内容

Returns a chart.


Arguments:参数中没有什么差异,和之前的都一样

imageCollection (ImageCollection):

An ImageCollection with data to be included in the chart.

region (Feature|FeatureCollection|Geometry):

The region to reduce.

reducer (Reducer, optional):

Reducer that generates the values for the y-axis. Must return a single value. Defaults to ee.Reducer.mean().

scale (Number, optional):

Scale to use with the reducer in meters.

xProperty (String, optional):

Property to be used as the label for each image on the x-axis. Defaults to 'system:time_start'.


Returns: ui.Chart

这个是网地图上加盖图标


ui.Map.Layer(eeObject, visParams, name, shown, opacity)

A layer generated from an Earth Engine object for display on a ui.Map.


Arguments:

eeObject (Collection|Feature|Image, optional)://这里可以是一个影像、矢量或者集合

The object to add to the map. Defaults to an empty ee.Image.默认是一个空的对象

visParams (FeatureVisualizationParameters|ImageVisualizationParameters, optional):

The visualization parameters. See ee.data.getMapId() docs.

name (String, optional):

The name of the layer.

shown (Boolean, optional):

Whether the layer is initially shown. Defaults to true.

opacity (Number, optional):

The layer's opacity represented as a number between 0 and 1. Defaults to 1.


Returns: ui.Map.Layer

当然在最后如果你想加载这上面的化,还需要Map.layers().add(sfLayer);

如何在地图上创造一个标签:直接用ui.Label(“标签显示的内容”)

同样想要实现还得继续用Map.add(label)

如何实现自己加载的线型图的点击?

Map.onClick(callback)

Registers a callback that's fired when the map is clicked.通过点击返回一个值,返回什么东西需要自己写个函数来确定,并让他显示在标签上

Returns an ID which can be passed to unlisten() to unregister the callback.


Arguments:

callback (Function):

The callback to fire when the map is clicked. The callback is passed an object containing the coordinates of the clicked point (with keys lon and lat) and the map widget.


Returns: String

reset(list)

Replaces all elements in list with a new list or, if no list is provided, removes all elements from list.

Returns the elements in the list after the reset is applied.一个列表,选择你要加载的影像显示值和这个点的符号颜色。


Arguments:

this:ui.data.activelist (ui.data.ActiveList):

The ui.data.ActiveList instance.

list (List<Object>, optional):

A list of elements.


Returns: List<Object>

ui.label有一个属性值

setValue(value)

Sets the value of the label.

Returns this label.


Arguments:

this:ui.label (ui.Label):

The ui.Label instance.

value (String):

The value of the label.


Returns: ui.Label

 

 

最后来看一下这一系列复杂的过程的代码:

//选择需要研究的区域,给对焦点坐标形成矩形
var sanFrancisco =
    ee.Geometry.Rectangle(-122.45, 37.74, -122.4, 37.8);
//筛选影像时间和波段的选取
var landsat8Toa = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
    .filterDate('2015-12-25', '2016-12-25')
    .select('B[1-7]');
// 创造一个随时间变化的折线图.
var chart = ui.Chart.image.series({
  imageCollection: landsat8Toa,
  region: sanFrancisco,
  reducer: ee.Reducer.mean(),
  scale: 200
});
//让上面的折线图设置属性并加载到map上
chart.style().set({
  position: 'bottom-right',
  width: '500px',
  height: '300px'
});
Map.add(chart);
// 这个是设置你研究区域要在地图上显示的颜色,设置属性并加载在地图上同时设置地图显示的中心点坐标.
var sfLayer = ui.Map.Layer(sanFrancisco, {color: 'FF0000'}, 'SF');
Map.layers().add(sfLayer);
Map.setCenter(-122.47, 37.7, 9);
// 创造一个标签在地图上.
var label = ui.Label('Click a point on the chart to show the image for that date.');
Map.add(label);
// 设置点击,通过点击可以在标签上显示你想要的东西,是动态的实时的.
chart.onClick(function(xValue, yValue, seriesName) {
  if (!xValue) return;  // Selection was cleared.
  // 当点击你图标上的时间点的时候,你就可以显示当期的影像.
  var equalDate = ee.Filter.equals('system:time_start', xValue);
  var image = ee.Image(landsat8Toa.filter(equalDate).first());
  var l8Layer = ui.Map.Layer(image, {
    gamma: 1.3,
    min: 0,
    max: 0.3,
    bands: ['B4', 'B3', 'B2']
  });
  Map.layers().reset([l8Layer, sfLayer]);
  // 在标签上显示这个时间节点的影像.
  label.setValue((new Date(xValue)).toUTCString());
});


这个自己慢慢研究吧,过程还是比较累的,毕竟你需要完成很多内置功能!


相关文章
|
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
|
3月前
|
域名解析 JavaScript 网络协议
技术心得记录:如何使用google地图的api(整理)
技术心得记录:如何使用google地图的api(整理)
297 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

热门文章

最新文章