3

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...

  1. Data import
var l8sr = ee.Image('LANDSAT/LC08/C01/T1_SR')

The method I am trying to use is as follows:

  1. 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]])

  1. Set the time field as milliseconds since 1970-1-1 00:00
var timeField = 'system:time_start'
  1. 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))
}
  1. Apply functions to data and filter by roi
var filteredLandsat = l8sr
.filterBounds(roi)
.map(maskL8sr)
.map(addVariables)
  1. 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)
5
  • 1
    I don't think the featureCollection is a workaround, as much as the correct way to do it. It uses the strength of Earth Engine in distributed computing as it was meant to be done. But smarter minds than me could probably give a better answer. Sep 1, 2019 at 12:39
  • Thanks @SeanRoulet I have edited my edit to give you credit for suggesting it is actually correct and not a work around. Hopefully one of these smarter minds can enlighten us!
    – JMilner
    Sep 1, 2019 at 12:43
  • Are you working in Australia? Sep 1, 2019 at 12:47
  • 1
    Instead of the edit of your question, put it in the Answer box, that way your question appears as answered (albeit answering it yourself). In future, if other users search for it they will see that an answer exists. I would add it, but you did come up with the answer alone... (though I confess I had started thinking about it, and you beat me to the punch!) Sep 1, 2019 at 13:03
  • I am working in Australia, yes! I will put it in the answers, but will remain hopeful for a proper explanation
    – JMilner
    Sep 1, 2019 at 13:15

2 Answers 2

3

Since posting this, (and with a helpful comment from @Sean Roulet) it seems the "correct" way to do this is to replace the ee.Geometry.MultiPoint() with a ee.FeatureCollection() containing several ee.Geometry.Point() as follows:

var roi_list = [ee.Feature(ee.Geometry.Point(146.007413888888,-17.6536194444444), {name: 'Warrubellen'}),
           ee.Feature(ee.Geometry.Point(146.061191666666,-17.4442805555555), {name: 'Ella Bay'}),
           ee.Feature(ee.Geometry.Point(145.960902777777,-17.7890055555555), {name: 'Nyleta Creek'}),
           ee.Feature(ee.Geometry.Point(151.937444444444,-24.3380305555555), {name: 'Deep Water'}),
           ee.Feature(ee.Geometry.Point(150.468130555555,-23.1586194444444), {name: 'Mt Etna Quarry'}),
           ee.Feature(ee.Geometry.Point(148.506963888888,-21.088375), {name: 'Eungella 1'}),
           ee.Feature(ee.Geometry.Point(148.591619444444,-21.3626416666666), {name: 'Eungella 2'}),
           ee.Feature(ee.Geometry.Point(148.186125,-24.9189222222222), {name: 'Carnavon'})]

var roi = ee.FeatureCollection(roi_list);

So now, the question presented here is more based on whether it is possible to do what I have done below, without using a FeatureCollection(), and instead just using ee.Geometry.MultiPoint(), or if not, why google earth engine is unable to do this...?

1

I agree with the OP that it's weird that it's not easy to convert an ee.Geometry.MultiPoint to an FeatureCollection. One workaround is to extract the coordinates as a list and then map through the list rebuilding points wrapped in features.

So if you have a Multipoint in mypoints you can get them as a FeatureCollection myfeats like this:

var myfeats = ee.FeatureCollection(mypoints.coordinates().map(function(x) {return ee.Feature(ee.Geometry.Point(x))}))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.