Download satellite data with GEE

Sometimes you just like to have the data on your own harddrive.

The moderate-resolution imaging spectroradiometer (MODIS) satellite with 36 spectral bands with varying spatial resolutions (2 bands at 250 m, 5 bands at 500 m and 29 bands at 1 km). The Terra satellite was launched in 1999, the Aqua in 2002. There are a number large number of readily available atmosphere, land and water products. Find an overview here.

In this assignment we are going to use two different products:

MOD13:  The MOD13 product obtained from the MODIS satellite includes the Normalized Difference Vegetation Index (NDVI). Data is available for every 16 days.

MOD15: The Fractional Photosynthetically Active Radiation (FPAR) and Leaf Area Index (LAI) obtained from the MODIS satellite is an 8 daily product with a spatial resolution of 500 meter.

Step 1: Open this script and save it to you private folder.

Step 2: Import the MOD13 (MOD13Q1) and MOD15 products.

importdata

Step 3: print the output of both variables

print(mod13)
print(mod15)

In the console you can find all data in the imagecollection.

outputgee.jpg

Step 4: Select the time period of interest, the location and variable of interest.

 // define study period
var startdate = ee.Date.fromYMD(2010,1,1);
var enddate = ee.Date.fromYMD(2011,12,31);

//  filter data on location and
var modNDVI = mod13.filterDate(startdate,enddate)
                   .filterBounds(Da)
                   .select("NDVI")

//  filter data on location and
var modFpar = mod15.filterDate(startdate,enddate)
                   .filterBounds(Da)
                   .select("Fpar")

//  filter data on location and
var modLAI = mod15.filterDate(startdate,enddate)
                   .filterBounds(Da)
                   .select("Lai")

Step 5: Create monthly maps for all data products. Below an example on how to create monthly data for the NDVI.

// create a list with all months
var months = ee.List.sequence(1,12);

// create a list with all years
var years = ee.List.sequence(2010,2011);

// create monthly maps
var monthlyNDVI =  ee.ImageCollection.fromImages(
  years.map(function (y) {
  return months.map(function(m){
  var w =  modNDVI.filter(ee.Filter.calendarRange(y, y, 'year'))
           .filter(ee.Filter.calendarRange(m, m, 'month'))
           .mean();
  return w.set('year', y)
           .set('month', m)
           .set('date', ee.Date.fromYMD(y,m,1))
           .set('system:time_start',ee.Date.fromYMD(y,m,1)) 

});
}).flatten());

// print the output
print(monthlyNDVI)

Step 6: As all images in the image collection are scaled, we need the multiply each image with the scale factor.

scaleimg.jpg

// Scale the NDVI with fac 0.0001
var scaleNDVI = function(img){
  return img.multiply(0.0001)
}

// scale every image in the collection
monthlyNDVI = monthlyNDVI.map(scaleNDVI);

// Scale the mod15 data
var scalemod15 = function(img){
  return img.multiply(0.01)
}

// Scale every image in the collection
monthlyFpar = monthlyFpar.map(scalemod15)
monthlyLAI = monthlyLAI.map(scalemod15)

step 7: add the mean of the image collection to the map canvas for visual inspection

// add layers to canvas
var colorndvi = {min:0.4, max:1, palette:"52ff0e,52cc22,26b031,276221"};
Map.addLayer(monthlyNDVI.mean().clip(Da),colorndvi,"NDVI");
var colorLAI = {min:0, max:0.8, palette:"befffc,6ae9ff,374eff,6f00ff"};
Map.addLayer(monthlyLAI.mean().clip(Da),colorLAI,"LAI");
var colorFpar = {min:0, max:0.8, palette:"f1ff8b,fbff54,ffc6a5,ff310e"};
Map.addLayer(monthlyFpar.mean().clip(Da),colorFpar,"Fpar");

There are three ways to store an ImageCollection in the Google Earth Engine. (1) to the google drive, (2) to the Google Cloud storage and (3) as an asset. Here the first option is shown. However, currently there is no easy way to batch export large dataseries.

// get metadata
var first = ee.Image(monthlyNDVI.first());
var crs = first.projection().crs().getInfo();
var scale = 1000;
var count =  monthlyNDVI.size().getInfo();

// set the counter
var counter = 0;

// loop through the year
for (var y = 2000; y < 2002 ; y++) {
  // loop through the months
  for (var m = 1; m < 12 ; m++) {

  // get the image
  var img = ee.Image(monthlyNDVI.toList(1, counter).get(0));

  // store the image
  Export.image.toDrive({
       image: img,
       description: y.toString() + m.toString(),
       scale: 1000,
    region: Da
 });
}}

See a final 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