Wednesday, 16 January 2019

modis - Combine two collections (MOD13Q1 and MYD13Q1) from Google Earth Engine



Need to combine two image NDVI collections (MOD13Q1 and MYD13Q1) in Google Earth Engine but don't know how to proceed.


My proposed workflow is to combine the two NDVI products from two collections to create a multi-temporal dataset. Then, from there will create a stacked image (image layer stacking) composed of NDVI images from the combined dataset, which will be later used for classification.


var region = ee.Geometry.Rectangle(xxlon, xxlat, xxlon, xxlat);
var roi = region;

// Load MODIS MOD13Q1 dataset.
var MOD13Q1_fullCollection = ee.ImageCollection('MODIS/MOD13Q1').select('NDVI');
var MOD13Q1_dateFilter = MOD13Q1_fullCollection.filterDate('2015-01-01','2017-12-31');
var MOD13Q1 = MOD13Q1_date.filterBounds(roi);
print (MOD13Q1);


// Load MODIS MOD13Q1 dataset.
var MYD13Q1_fullCollection = ee.ImageCollection('MODIS/MYD13Q1').select('NDVI');
var MYD13Q1_date = MYD13Q1_fullCollection.filterDate('2015-01-01','2017-12-31');
var MYD13Q1 = MYD13Q1_date.filterBounds(roi);
print (MYD13Q1);

var stackCollection = function(collection){
var first = ee.Image(collection.first()).select([]);
var appendbands = function(image, previous){

return ee.Image(previous).addBands(image.reproject('EPSG:4326',null,232));
};
return ee.Image(collection.iterate(appendbands,first));
};

var stacked = stackCollection(supposed_to_be_the_combined_NDVI_from_two_collections);

Answer



My guess is you are trying to combine the two 16-day composites into a synthethic 8-day composite containing data from both Aqua and Terra (as has been proposed in many research papers).


You can do this by simply merging both collections and then sorting according to the central acquisition date.


https://code.earthengine.google.com/84430216d1ce67eeeb7f067dd6db581e



// Load MODIS MOD13Q1 dataset.
var MOD13Q1 = ee.ImageCollection('MODIS/MOD13Q1')
.select('NDVI')
.filterDate('2015-01-01','2017-12-31')
.filterBounds(roi)
print(MOD13Q1);

// Load MODIS MYD13Q1 dataset.
var MYD13Q1 = ee.ImageCollection('MODIS/MYD13Q1')
.select('NDVI')

.filterDate('2015-01-01','2017-12-31')
.filterBounds(roi)
print(MYD13Q1);

// merge collections
var MOD_merged = MOD13Q1.merge(MYD13Q1)
print(MOD_merged)

// sort by date
var MOD_merge_sorted = MOD_merged.sort("system:time_start")

print(MOD_merge_sorted)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...