在剧情标题中包含变量 - Google Earth Engine

时间:2018-05-29 08:20:29

标签: javascript google-earth-engine

有没有办法将变量包含为情节标题?我希望我的标题取决于某个整数的值(取决于 iC_FC_size )。

 onSelectionChanged() {
    this.countOnSelectionChanged();
    this.enableAssociatedActions();
  }

想知道这是否可能?

问候!

2 个答案:

答案 0 :(得分:1)

此脚本在图表上方的标题中包含一个变量:

QueryItem1 = ?Param1?
QueryItem2 = ?Param2?
QueryItem3 = ?Param3?
QueryItem4 = ?Param4?
QueryItem5 = ?Param5?
QueryItem6 = ?Param6?
QueryItem7 = ?Param7?
QueryItem8 = ?Param8?

“。getInfo()”方法将值从服务器端拉到客户端(即您的浏览器)。然后,您可以使用任何Javascript命令(例如,使用“ +”号)将所需的字符串构造为标题。

另一种方法是构建字符串服务器端,然后像这样将其拉出:

var ic = ee.ImageCollection('LANDSAT/LT05/C01/T1_SR');

var size= ic.size().getInfo();

var some_title = 'How many LS5 scenes are there? Exactly ' + size+ ' scenes!';

var some_chart = ui.Chart.array.values(ee.Array([1,5,6,8,6]), 0).setOptions({title: some_title});
print(some_chart);

答案 1 :(得分:0)

要添加到Bert Coerver的答案中: 如果您希望绘图标题中的变量成为FeatureCollection中用作ImageCollection中ROI的多边形的名称,则可以这样做:

var fc = ee.FeatureCollection('ft:some fusion table containing multiple polygons')
    .filter(ee.Filter.eq('name', 'Suriname')); // Here I have already chosen my ROI

// When you are ready to plot:
var area_name = fc.aggregate_array('name').getInfo();
var some_title = 'Name of area: ' + area_name;

var some_chart = ui.Chart.array.values(ee.Array([1,5,6,8,6]), 0).setOptions({title: some_title});
print(some_chart);