0

I've wrote this code for Nitrogen Index. but it returns error. how can I solved this?

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

error massage:

Layer 2: Layer error: Image.subtract, argument 'image2': Invalid type. Expected: Image. Actual: Dictionary.

> Map.centerObject(geometry);
> 
> var hyperion = ee.ImageCollection('EO1/HYPERION')
> .filterBounds(geometry) .filterDate('2000-01-01','2018-01-01')
> .toBands() .clip(geometry);
> 
> print(hyperion);
> 
> var NDRE = hyperion.expression(   '(B137 - B31)/(B137 + B31)' ,{  
> 'B137':hyperion.select('EO1H1660372010258110PC_SGS_01_B137') ,   'B31'
> : hyperion.select('EO1H1660372010258110PC_SGS_01_B031')
> }).rename('NDRE');
> 
> var min = NDRE.reduceRegion({   reducer: ee.Reducer.min(),   geometry:
> geometry,   scale: 30,   maxPixels: 1e9 }); print(min);
> 
> 
> var max = NDRE.reduceRegion({   reducer: ee.Reducer.max(),   geometry:
> geometry,   scale: 30,   maxPixels: 1e9 }); print(max);
> 
> var CCCI = hyperion.expression(   '(NDRE - min)/(max - min)' ,{  
> 'NDRE':NDRE ,   'min' :
> NDRE.reduceRegion(ee.Reducer.min(),geometry,30),   'max' :
> NDRE.reduceRegion(ee.Reducer.max(),geometry,30) });
> 
> Map.addLayer(NDRE);
> 
> Map.addLayer(CCCI)
  • What do you want for min and max in your calculation of CCCI? – Kevin Jul 21 at 10:57
  • NDRE min and max must be imported to CCCI equation. – Johny Astine Jul 21 at 12:34
  • Sorry if I did not make it clear. I meant what value you expect from min and max? The min and max value across NDRE band? – Kevin Jul 21 at 13:08
  • yes. I need min and max values which extracted from NDRE. – Johny Astine Jul 22 at 6:40
  • Then you need to use NDRE.reduceRegion(ee.Reducer.min(),geometry,30).get('NDRE') for min value, and the same thing for max value. This is because reduceRegion returns a dictionary, not a value. – Kevin Jul 22 at 13:51

Your Answer

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

Browse other questions tagged or ask your own question.