I made this code to get a Linear Regression using the function SAVI in my own collection but it is not working.

Does anyone know why?

``````    // Simple regression of year versus NDVI.

// Define the start date and position to get images covering SatgeArea,
// Bolivia, from 2000-2010.
var start = '2000-01-01';
var end = '2014-12-31';

var region = table

// Filter to Collection
// time of year to avoid seasonal affects, and for each image create
the bands
// we will regress on:
// 1. A 1, so the resulting array has a column of ones to capture the
offset.
// 2. Fractional year past 2000-01-01.
// 3. SAVI.
var col = imageCollection
.sort('system:time_start')
.filterBounds(region)
.map(function(image) {
var date = ee.Date(image.get('system:time_start'));
var yearOffset = date.difference(ee.Date(start), 'year');
var savi = image.expression(
'(1 + L) * float(nir - red)/ (nir + red + L)',
{
'nir': image.select('B4'),
'red': image.select('B3'),
'L': 0.5
});
return

});

print(col)
// Convert to an array. Give the axes names for more readable code.
var array = col.toArray();
var imageAxis = 0;
var bandAxis = 1;

// Slice off the year and ndvi, and solve for the coefficients.
var x = array.arraySlice(bandAxis, 0, 2);
var y = array.arraySlice(bandAxis, 2);
var fit = x.matrixSolve(y);

// Get the coefficient for the year, effectively the slope of the long-term
// NDVI trend.
var slope = fit.arrayGet([1, 0]).clip(region);

// Export the image, specifying scale and region.
Export.image.toDrive({
image: slope,
description: 'SAVI_slope_jan',
scale: 30,
maxPixels: 1e9,
region: table
});
``````

Im using my own collection (images from LE7_SR and LT5_SR) and my own geometry (table). I can map the result (slope) but I cannot download and if I try with a normal collection (ee.ImageCollection) I can. Does anyone know why I cannot download the image from my own collection?

• Are you getting any errors or is the resulting layer not right? – HDunn Nov 21 '17 at 13:11
• Use `Export.image`. If it fails, report back with the error message. If not, wait... – Nicholas Clinton Nov 22 '17 at 1:14