1

Modis product have range of value NDVI from -2000 to 10000, but I need this range of value modify on range from -0,2 to 1 This is my code for finding NDVI in region:

var California = ee.Feature(    // California.
    ee.Geometry.Point(-119.37744140625,37.62815420124975),
    {label: 'California'});
var Utah = ee.Feature(  // Utah.
    ee.Geometry.Point(-111.5386962890625,38.1120855331916475),
    {label: 'Utah'});
var Coloredo = ee.Feature(  // Coloredo.
    ee.Geometry.Point(-106.6827392578125,38.98844856696302),
    {label: 'Coloredo'});
var sites = new ee.FeatureCollection([California, Utah, Coloredo]);
Map.addLayer(sites)
var collection = ee.ImageCollection ('MODIS/MOD13Q1')
  .filterDate(ee.Date('2012-01-01'),ee.Date('2014-12-31'))

//function to create mask from SmmaryQA
var maskQA = function(image) {
  return image.updateMask(image.select("SummaryQA").eq(0));
};

var goodCollection = collection.map(maskQA)
Map.addLayer(goodCollection)

//var nas= googCollection.multiply(0.00001)
//var evi1 = function(evi){
  //return evi.updateMask(goodCollection * 0.0001)
//};
//var areaImageSqKm = goodCollection.multiply(0.00001);
//var fallowedArea = fallowed.multiply(areaImageSqKm);  
//var evi2 = collection.map(evi1)

var NDVITimeSeries = ui.Chart.image.seriesByRegion(
    goodCollection, sites, ee.Reducer.mean(),'NDVI', 5000, 'system:time_start', 'label')
        .setChartType('ScatterChart')
        .setOptions({
          title: 'Temporal development of MODIS product',
          vAxis: {title: 'NDVI'},
          lineWidth: 1,
          pointSize: 1,
        });

print(NDVITimeSeries)

How do I recalculate the value range?

  • Why do you need to recalculate the range? You could just change the labels in your chart to read -0.2 to 1 instead of -2000 to 10000 and the rest of the chart would not change at all. – Kersten Jan 4 '17 at 9:06
  • You could improve this question by removing the commented out lines that are note relevant. – Tyler Erickson Feb 3 '17 at 23:19
1

You can add a new band with a rescaled NDVI values, by mapping a function over the collection:

// Add a rescaled NDVI band to each image in the collection.
goodCollection = goodCollection.map(
  function(img) {
    var rescaled_NDVI = img.select('NDVI')
                           .multiply(0.0001)
                           .rename('NDVI_rescaled');
    return img.addBands(rescaled_NDVI);
  }
);

You will then need to update your charting code to use the new band:

var NDVITimeSeries = ui.Chart.image.seriesByRegion({
    imageCollection: goodCollection,
    regions: sites,
    reducer: ee.Reducer.mean(),
    band: 'NDVI_rescaled',
    scale: 5000,
    xProperty: 'system:time_start',
    seriesProperty: 'label'
  }).setChartType('ScatterChart')
    .setOptions({
      title: 'Temporal development of MODIS product',
      vAxis: {title: 'NDVI'},
      lineWidth: 1,
      pointSize: 1,
    });

The scaling factor of 0.0001 was obtained from the USGS MOD13Q1 product page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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