Make a movie with Google Earth Engine

Create awesome time-lapse movies with the GEE.

Step 1: import the Landsat 4, 5 7 and 8 Image Collections

Step 2: draw a geometry of your area of interest.

Tip! The larger your polygon the longer it takes to process.

Step 3: Copy the bandnames as specified below into your script.

var l4names = ee.List(["B1","B2","B3","B4","B5","B6","B7","fmask"])
var l5names = ee.List(["B1","B2","B3","B4","B5","B6","B7","fmask"])
var l7names = ee.List(["B1","B2","B3","B4","B5","B6_VCID_1","B6_VCID_2","B7","B8","fmask"])
var l8names = ee.List(["B1","B2","B3","B4","B5","B6","B7","B8","B9","B10","B11","BQA"])

// bands
var l4Bands = ee.List(['blue','green','red','nir','swir1','tir','swir2','fmask'])
var l5Bands = ee.List(['blue','green','red','nir','swir1','tir','swir2','fmask'])
var l7Bands = ee.List(['blue','green','red','nir','swir1','tir1','tir2', 'swir2','pan','fmask'])
var l8Bands = ee.List(['b1','blue','green','red','nir','swir1','swir2','cir','tir1','tir2','pan','BQA'])

Step 4: Filter based on location

// Filter based on location
var l4images  = l4.filterBounds(geometry)
var l5images  = l5.filterBounds(geometry)
var l7images  = l7.filterBounds(geometry)
var l8images  = l8.filterBounds(geometry)

Step 5: Remove the clouds from the images

// 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 = CloudScore.select('cloud');
  //get pixels above the threshold
  var cloud01 = quality.gt(cloud_thresh);
  //create a mask from high likelihood pixels
  var cloudmask = image.mask().and(cloud01.not());
  //mask those pixels from the image
  return image.updateMask(cloudmask);
};

// mask all clouds in the image collection
l4images = l4images.map(cloudfunction);
l5images = l5images.map(cloudfunction);
l7images = l7images.map(cloudfunction);
l8images = l8images.map(cloudfunction);

Step 5: Rename the bands

l4images = l4images.select(l4names,l4Bands);
l5images = l5images.select(l5names,l5Bands);
l7images = l7images.select(l7names,l7Bands);
l8images = l8images.select(l8names,l8Bands);

Step 6: Combine all images into a single collection.

// Combine all data in single collection
var myCollection = ee.ImageCollection((l4images.merge(l5images)).merge(l7images).merge(l8images));

Step 7: Select the Red, Green and blue bands

// select rgb
var myCollection = myCollection.select(['red','green','blue'])

Step 8: Create one map for each year.

var yearlymap = ee.ImageCollection(years.map(function (y) {
      var image = myCollection.filter(ee.Filter.calendarRange(y, y, 'year'))
                              .median();
      return image.set('year', 2000)
                  .set('date', ee.Date.fromYMD(y,1,1))
                  .set('system:time_start',ee.Date.fromYMD(y,1,1));
}));

Step 9: Make it a 8 bit format.

var coll4Video = yearlymap
  .map(function(image) {
    return image.multiply(512).uint8();   // need to make it 8-bit
  });

Step 10: Export the video to your drive

Export.video.toDrive({
    collection: coll4Video,
    description: "myvideo" ,
    scale: 30,
    framesPerSecond: 2,
    region: geometry
});

see an example here.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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