I am trying to generate time series for a set of points in earth engine. I am attempting this for multiple datasets, but for now let's do NDVI with Landsat 8. My problem lies (i think) in step 6. below, as the plot is generated, but with no sign of mutiple sites...
- Data import
var l8sr = ee.Image('LANDSAT/LC08/C01/T1_SR')
The method I am trying to use is as follows:
- Create a multi point geometry, here called
roi
. N.B. The code presented in this question runs perfectly for a single point geometry, but not for multipoint
var roi = ee.Geometry.MultiPoint([[146.007413888888,-17.6536194444444],
[146.061191666666,-17.4442805555555],
[145.960902777777,-17.7890055555555],
[151.937444444444,-24.3380305555555],
[150.468130555555,-23.1586194444444],
[148.506963888888,-21.088375],
[148.591619444444,-21.3626416666666],
[148.186125,-24.9189222222222]])
- Set the time field as milliseconds since 1970-1-1 00:00
var timeField = 'system:time_start'
- A couple of functions which I am using to clean and process data. These have been taken from sources that I dont have to hand, but will update question when I do.
4.a Function to mask cloud using the pixel_qa (quality assurance) band of L8SR data. This is from the code editor example on cloud masking
function maskL8sr(image) {
var cloudShadowBitMask = 1 << 3
var cloudsBitMask = 1 << 5
var qa = image.select('pixel_qa')
var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
.and(qa.bitwiseAnd(cloudsBitMask).eq(0))
return image.updateMask(mask).divide(10000)
.select('B[0-9]*')
.copyProperties(image,['system:time_start'])
}
4.b Create NDVI, time, and constant variables in data
var addVariables = function(image) {
var date = ee.Date(image.get(timeField))
var years = date.difference(ee.Date('1970-01-01'),'year')
return image
.addBands(image.normalizedDifference(['B5','B4']).rename('NDVI'))
.addBands(ee.Image(years).rename('t'))
.float()
.addBands(ee.Image.constant(1))
}
- Apply functions to data and filter by
roi
var filteredLandsat = l8sr
.filterBounds(roi)
.map(maskL8sr)
.map(addVariables)
- Plotting a time series of NDVI. The image that is output from this is one with red points only and no sign of multiple sites being present. I am trying my best to troubleshoot this, but have hit a bit of a wall in my understanding and thought to bring the question to a wider audience...
//Plot a time series of NDVI at a single location
var l8Chart = ui.Chart.image.seriesByRegion(filteredLandsat,
roi,
ee.Reducer.mean(),
'NDVI')
.setChartType('ScatterChart')
.setOptions({
title: 'Landsat 8 NDVI time series at ROI',
vAxis: {title: 'NDVI'},
lineWidth: 1,
pointSize: 4,
series: {
0: {color: '#FF0000'}, // Warrubellen
1: {color: '#FFFF00'}, // Ella Bay
2: {color: '#00FF00'}, // Nyleta Creek
3: {color: '#008000'}, // Deep Water
4: {color: '#00FFFF'}, // Mt Etna Quarry
5: {color: '#0000FF'}, // Eungella 1
6: {color: '#FF00FF'}, // Eungella 2
7: {color: '#800080'} // Carnavon
}
})
print(l8Chart)