0

I'm using Google Earth Engine to calculate the 5th and 95th percentiles of the intraannual coefficient of variation (CV) of the NDVI within a polygon (my area of interest). My code actually runs and the results seem to be OK when I look the CV map in GEE, but percentiles within my aoi are exactly the same number when I use a reduce.Region function.

What could be wrong with my code?

//study area
    var geometry = ee.Geometry.Polygon(
              [[-60, -30],
               [-60, -28],
               [-62, -28],
               [-62, -30]],null, false);
    Map.addLayer(geometry, null, 'geometry');
    Map.setCenter(-61, -29, 6);

//temporal subset of MODIS NDVI 
    var NDVI = ee.ImageCollection('MODIS/006/MOD13Q1')
    .filterDate('2001-01-01', '2001-12-31')
    .select(['NDVI']);

// NDVI functional attributes 
    var NDVImean = NDVI.mean();
    var NDVIsd = NDVI.reduce(ee.Reducer.stdDev());
    var NDVIcv = NDVIsd.divide(NDVImean); // Intraannual Coeficient of variation of NDVI
    Map.addLayer(NDVIcv, null, 'NDVIcv');

//Percentiles of NDVImean within geometry
    var quartM = NDVImean.reduceRegion({
              reducer: ee.Reducer.percentile([5,95]),
              geometry: geometry,
              crs:'EPSG:4326',
              scale: 231.656358,
              bestEffort: true,
              maxPixels: 100000
              });
    print ('percentiles of NDVImean', quartM)

//Percentiles of NDVIcv within geometry
    var quartCV = NDVIcv.reduceRegion({
              reducer: ee.Reducer.percentile([5,95]),
              geometry: geometry,
              crs:'EPSG:4326',
              scale: 231.656358,
              bestEffort: true,
              maxPixels: 100000
              });
    print ('percentiles of NDVIcv', quartCV) 

code link: https://code.earthengine.google.com/de6d677c879e4a9b5240e849ff620bdd

0

It seems like your NDVIcv percentiles are correct as well. Upon inspecting the histogram of the image within the geometry,

var quartCV = NDVIcv.reduceRegion({
              reducer: ee.Reducer.histogram(),//percentile([1,99]),
              geometry: geometry,
              crs:'EPSG:4326',
              scale: 231.656358,
              bestEffort: true,
              maxPixels: 100000
              });

it can be seen that the bucket with value 0.1685536960185088 has more than 99600 values while the highest on other buckets is 141. So, the data is very narrow which gives you same values for 5th and 95th percentile. You can check if its working by using 0 and 100 percentile.

  • Histogram is odd too.. The map shows great spatial heterogeneity, not only a single modal value. With the 'inspector' I can check that there are a lot of different values within my aoi. Mean and standard deviation histograms are 'wide', how can a quotient between them result in a 'narrow' histogram? – hdieguez Sep 9 '19 at 13:43
  • Well the thing to remember is that this histogram is generated in buckets with certain widths and not exact values which means the value shown is mean value of the values contained in that group. I added the NDVIcv layer on map and to check the distribution of pixels in that bucket. It looked like it lined up with the stats. var check = NDVIcv.gte((-1.2599679454374488+0.1685536960185088)/2) .and(NDVIcv.lte((2.9505458898426005+0.1685536960185088)/2)); Map.addLayer(check.clip(geometry).reproject({crs:'EPSG:4326', scale:1000}), null, 'NDVIcv-bucket74'); – Nishanta Khanal Sep 11 '19 at 3:47

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.