Landuse map from temporal signature

A landuse map from the complete Landsat archive

1. import the Landsat 5, 7 and 8 ImageCollections.


2. Set the time range.

// Define time range
var startyear = 2006;
var endyear = 2016;

// Set date in ee date format
var startdate = ee.Date.fromYMD(startyear,1,1);
var enddate = ee.Date.fromYMD(endyear,12,31)

3. Import a fusion table of your study area.

// The Ca basin
var Ca = ee.FeatureCollection('ft:1ILFPzWUf4dL_tKNY0Rd3EhGtRQoLfzmk_00i9xC3');

4. Filter the ImageCollections based on date and area.

// filter on date and bounds
var l5images = l5.filterDate(startdate,enddate).filterBounds( Ca);
var l7images = l7.filterDate(startdate,enddate).filterBounds( Ca);
var l8images = l8.filterDate(startdate,enddate).filterBounds( Ca);

5. Include a function to remove the clouds

// set cloud threshold
var cloud_thresh = 40;

// Functions
var cloudfunction = function(image){
  //use add the cloud likelihood band to the image
  var CloudScore = ee.Algorithms.Landsat.simpleCloudScore(image);
  //isolate the cloud likelihood band
  var quality ='cloud');
  //get pixels above the threshold
  var cloud01 =;
  //create a mask from high likelihood pixels
  var cloudmask = image.mask().and(cloud01.not());
  //mask those pixels from the image
  return image.updateMask(cloudmask);

6. Run the cloud function on all images in the image collection.

// mask all clouds in the image collection
l5images =;
l7images =;
l8images =;

7. Select the red and NIR bands.

// Select the red and NIR bands
l5images =["B4","B3"]);
l7images =["B4","B3"]);
l8images =["B5","B4"]);

8. Calculate the NDVI for all images.

// calculate ndvi from landsat 8
function l8ndvi(img) {
  var ndvi = img.normalizedDifference(['B5', 'B4']).rename('NDVI');
  return img.addBands(ndvi);

// calculate ndvi from landsat 5 & 7
function l57ndvi(img) {
  var ndvi = img.normalizedDifference(['B4', 'B3']).rename('NDVI');
  return img.addBands(ndvi);

// calculate ndwi for each image in imagecollection
var l5ndvi =;
var l7ndvi =;
var l8ndvi =;

9. Combine all images into a single image collection.

// combine all data in single image collection
var allcollection =  ee.ImageCollection((l5ndvi.merge(l7ndvi)).merge(l8ndvi));

10. Calculate the mean NDVI for each month.

// create list for years
var months = ee.List.sequence(1,12);

// calculate the ndvi for each month
var monthlyNDVI =  ee.ImageCollection.fromImages({
  var w ="NDVI").filter(ee.Filter.calendarRange(m, m, 'month'))
  return w.set('year', 2000)
           .set('month', m)
           .set('date', ee.Date.fromYMD(2000,m,1))


11. show the mean NDVI of the image collection

// the vizualization settings
var ndvi_viz = {min:0.0, max:0.70, palette:"ffe60a,dfffd1,277005"};

// add map to canvas
Map.addLayer("NDVI").mean().clip(Ca),ndvi_viz ,"ndvi")

Find an example here.

Now we are going to plot the temporal signature

12. Select the polygon drawing tool.


13. Draw a polygon on the landuse class of interest.


14.  Specify the name, select Feature collection and give it the property class with number 0.


15. Repeat this procedure for other classes by adding a new layer. Make sure you give the classes different numbers.

16.  Merge the different classes into one featurecollection

// merge into one feature collection
var mergedtable = rice //0
.merge(urban)               //1
.merge(water)               //2
.merge(richforest)          //3
.merge(annualcrops)         //4
.merge(secondaryforest)     //5

17. Display the temporal signature as a chart

// Predefine the chart titles.
var title = {
  title: 'landuseclass',
  hAxis: {title: 'Time'},
  vAxis: {title: 'ndvi'},

// create chart
var chart = ui.Chart.image.seriesByRegion(monthlyNDVI,



Now we need to add the 12 images (1 for each month) as bands to a new image collection. This can be done by the code below.

18. Copy and paste the code below into your code editor

// Create a list with months
var monthnames = ["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"]

// make a list of from the imagecollection
var myNDVIlist ="NDVI").toList(12);

// create a new image from the month January
var myCollection = ee.Image(myNDVIlist.get(0)).rename("jan");

// add the image of each month as band to the image
for (var i = 1; i < myNDVIlist.length().getInfo(); i++) {
  var mymap = ee.Image(myNDVIlist.get(i)).rename(monthnames[i]);
  myCollection = myCollection.addBands(mymap);

19. Use the code below to classify the image.

// set training image collection
var TrainingImage = myCollection;

// define training features
var trainingFeatures = mergedtable;

// define predicion bands
var predictionBands = myCollection.bandNames();

// set training classifier
var classifierTraining ={collection: trainingFeatures, properties: ['class'], scale: 30 });

// set classifier
var classifier = ee.Classifier.svm()
                 .train({features:classifierTraining, classProperty:'class', inputProperties: predictionBands});

// classify
var classified =; 

// add the result to the Map

Map.addLayer(classified.clip(Ca), {min: 0, max: 5,
palette: ['f0ff00','616343','2f00ff','125610','a93e9f','b8fbc0']},'landuse classification')

Find the full example here

One thought on “Landuse map from temporal signature”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s