1

I am new to GEE (about two weeks) and trying to understand the response of NDVI (as proxy for phenology) to temperature and precipitation in the Oban forest of Nigeria. I am using MOD13Q1 (250 m), MOD11A2 (1000 m), and Monthly GPM (11132 m) or TRMM 3B43 (27830 m).

I want to summarize the 16-day Modis data into monthly and yearly values, then export the values into R for further analysis (trend analysis, regression and lag in NDVI response to climate parameters (temperature and precipitation)).

I have been able to generate, set boundaries, scale, parse for QA and visualize the time series of the data in the current format.

var CRNP_Oban = ee.FeatureCollection("users/sijehasuk/CRNP_Oban2"),
    ndvi = ee.ImageCollection("MODIS/061/MOD13Q1"),
    lst_day = ee.ImageCollection("MODIS/061/MOD11A2");

// 1 ****************************************************************************
/////////////////////////////////////////////////
//// Extract MODIS NDVI data from 16-day MOD13Q1 250m resolution
// Creat Filter of quality pixels
var mask = function(im) {
  return im.updateMask(im.select("SummaryQA").eq(0));
};

// Import NDVI data
var ndvi = ee.ImageCollection(ndvi)
.filterDate('2000-01-01','2020-01-01')
.map(mask)
.select("NDVI")
.filterBounds(CRNP_Oban);

//Rescale
var rescale = function(image) {
    var temp = image.toFloat().multiply(0.0001);
    image = image.addBands(temp);
    return image;
};
var rescaleNDVI = ndvi.map(rescale);

// Charts NDVI time series (mean, max and min) ## NDVI_1 is the rescaled band
print(ui.Chart.image.series(rescaleNDVI.select("NDVI_1"), CRNP_Oban,
    ee.Reducer.mean(), 250));
print(ui.Chart.image.series(rescaleNDVI.select("NDVI_1"), CRNP_Oban,
    ee.Reducer.max(), 250));
print(ui.Chart.image.series(rescaleNDVI.select("NDVI_1"), CRNP_Oban,
    ee.Reducer.min(), 250));

How can I summarize all data into a monthly (single mean image value) and yearly (single mean image value) format (possibly with the minimum, maximum and mean Reducers) that can be exported individually? The reason for the yearly data is to produce a yearly trend and do some regression analysis.

The Code can be accessed here: https://code.earthengine.google.com/?accept_repo=users/sijehasuk/stackexchange Asset can be accessed here: https://code.earthengine.google.com/?asset=users/sijehasuk/CRNP_Oban2

6
  • Please do not delete and re-ask closed questions - gis.stackexchange.com/q/450045/115 was in the process of being reviewed by our community to decide whether it was ready to be re-opened.
    – PolyGeo
    Commented Jan 20, 2023 at 19:35
  • Noted. There was a prompt to edit or delete and reask. I know better now.
    – Geo_CJ
    Commented Jan 20, 2023 at 21:19
  • I have never seen a prompt suggesting to "edit or delete and reask". If you see it again can you bring it to our attention and choose to edit.
    – PolyGeo
    Commented Jan 20, 2023 at 22:17
  • Update the question so it focuses on one problem only. This will help others answer the question. You can edit the question or post a new one.
    – Geo_CJ
    Commented Jan 20, 2023 at 22:41
  • That means you should edit to reduce the scope of the original to one question and then ask another single question as a new one. There is nothing suggesting that you should delete the original.
    – PolyGeo
    Commented Jan 21, 2023 at 4:45

1 Answer 1

2

An easy way to make monthly mean composites is to map over a list containing a sequence of numbers to advance the start date. Then you just need to filter the collection by date, calculate the mean and set the 'time_start' property. Finally, you cast that result into an image collection.

// Number of months: 20 years * 12 months
var months = ee.List.sequence(0, ee.Number(20).multiply(12), 1);
var startDate = '2000-01-01';
print('months',months);

// Map over months and cast into image collection
var monthlyMean = ee.ImageCollection(months.map(function(n){
  // Create start and end dates for each month
  var start = ee.Date(startDate).advance(n, 'months');
  var end = start.advance(1, 'months');
  
  // Filter date and calculate mean
  // Set system:time_start as start
  var filterIm = rescaleNDVI.filterDate(start, end)
                             .mean()
                             .set('system:time_start', start);
  return(filterIm);   
}));

// Monthly values    
print(ui.Chart.image.series(monthlyMean.select("NDVI_1"), CRNP_Oban,
    ee.Reducer.mean(), 250));
print(ui.Chart.image.series(monthlyMean.select("NDVI_1"), CRNP_Oban,
    ee.Reducer.max(), 250));
print(ui.Chart.image.series(monthlyMean.select("NDVI_1"), CRNP_Oban,
    ee.Reducer.min(), 250));
4
  • This does the job. However, there are a lot of months with missing values. So I think I would have to revisit the QA. Is it possible to extract the peak and trough from the chart that this (the mean plot) print(ui.Chart.image.series(monthlyMean.select("NDVI_1"), CRNP_Oban, ee.Reducer.mean(), 250)); produces? I would like to further generate yearly mean peak and trough values.
    – Geo_CJ
    Commented Jan 20, 2023 at 22:47
  • Probably you can extract the peak values with min and max. Commented Jan 21, 2023 at 16:10
  • I've encountered a bit of a problem with this solution. Although, the monthly mean is generated, the system:index converts from date format to a sequence of digits created from 0 to n. How can you assign a new date sequence to the system:index?
    – Geo_CJ
    Commented Mar 5, 2023 at 15:35
  • I think it is already being created in 'system:time_start' Commented Mar 7, 2023 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.