I try to find a correlation between a linear trend of two NDVI time series before and after a specific day in time. And that I want to repeat (iterate/map?) for a lot of points globally distributed. This is the code @Daniel Well helped me with:
var conflicts = ee.FeatureCollection([
ee.Feature(ee.Geometry.Point([12.492297, 41.89024]), {conflictDate: '2010-01-01'}),
ee.Feature(ee.Geometry.Point([12.453361, 41.902216]), {conflictDate: '1990-01-01'})
])
var startDate = '1989-01-01'
var endDate = '2013-12-16'
var timeSeries = ee.ImageCollection('NASA/GIMMS/3GV0')
.filterDate(startDate, endDate)
.select(['ndvi'])
.map(function (image) {
return image.addBands(
ee.Image(image.getNumber('system:time_start'))
.subtract(ee.Date(startDate).millis())
.divide(1000*3600*24) // days
.int()
.rename('t')
)
})
var conflictsWithSlopes = conflicts.map(addSlopes)
print(conflictsWithSlopes)
print('slope change stats', conflictsWithSlopes.aggregate_stats('slopeChange'))
// Other aggregate_*() functions...
function addSlopes(conflict) {
var conflictDate = conflict.getString('conflictDate')
var beforeSlope = getSlope(timeSeries, conflict, startDate, conflictDate)
var afterSlope = getSlope(timeSeries, conflict, conflictDate, endDate)
return conflict
.set('beforeSlope', beforeSlope)
.set('afterSlope', afterSlope)
.set('slopeChange', afterSlope.subtract(beforeSlope))
}
function getSlope(timeSeries, conflict, startDate, endDate) {
return timeSeries
.select(['t', 'ndvi'])
.filterDate(startDate, endDate)
.reduce(ee.Reducer.linearFit())
.select('scale')
.reduceRegion({
// If your conflict regions aren't points,
// you might want to use a mean or median reducer
reducer: ee.Reducer.first(),
geometry: conflict.geometry(),
scale: 8000
})
.getNumber('scale')
}
Now I would like to use conflict points (around 9000) and their corresponding dates (like in the example) stored in a FC Link The conflict coordinates column is called "coordinate" and the date "date_start".
So far I have tried this:
var conflicts = conflicttable.select(['coordinate']);
var conflictDate = conflicttable.select(['date_start']);
and I get this error: FeatureCollection (Error) Error in map(ID=000000000000000005a2): DateRange: Parameter 'start' is required.