Saturday 26 May 2018

Change the label of the ui.Chart.image.seriesByRegion in Google Earth Engine



I would like to change the label of the chart in Google Earth Engine. I had the code:


var image= ee.FeatureCollection('ft:1OXpMKiwvIBC__iYcgjyW23A2oMr89IQlC3cLqk3q')
.filter(ee.Filter.or(ee.Filter.eq('name', 'Lake Tekapo')));
print (image);
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(image)
.filterDate('2017-01-01','2017-05-01');
// Map a function over the Landsat 8 TOA collection to add an NDVI band.
function test(image) {
var equation = image.expression(

'(7.27 * B4/B3) - 1.7',
{
B3: image.select('B4'),
B4: image.select('B3'),
}).rename('TEST').float();
return image.addBands(equation).set('system:time_start',
image.get('system:time_start'));
}
var test =collection.map(test).select(['TEST']);
print (test,'median');

//CHART TIME SERIES
// Define customization options.
var options = {
title: 'TEST over time in regions',
hAxis: {title: 'Time'},
vAxis: {title: 'TEST values'},
lineWidth: 1,
series: {
0: {color: '00FF00'},
1: {color: '0000FF'},

}};
// Create a time series chart.
var tempTimeSeries = ui.Chart.image.seriesByRegion(
test, image, ee.Reducer.mean(), 'TEST',300)
.setChartType('LineChart')
.setOptions(options);
// Display.
print(tempTimeSeries);

I would like that the chart of the lable is the property name of the feature (name = Lake Tekapo) instead of the Id of the feature (id = 2819) (see the figure attached).



enter image description here




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...