0

I have a script that was written in Python in PyCharm.

The script is something meant to run once then all the indices I list in the python can run from PyCharm rather than opening the ArcMap or ArcGIS Pro software everytime.

When running the script I get the NDVI that is expected, however the CLG index does not provide a reading as expected.

The Clgreen using the Arcpy provides an output, while the Clgreen2 using the ArcGIS fails in giving an output.

import arcpy
import arcgis
from datetime import date

output = r'C:\Users\john\Desktop\testing\RedEdge\Exports'
raster = r'C:\Users\john\Desktop\testing\RedEdge\Exports\RedEdge.tif'

today = date.today()
date = today.strftime("%d-%m-%Y")

#formulas - indices
NDVI = arcpy.ia.NDVI(raster, nir_band_id=5, red_band_id=3)
Clgreen = arcpy.ia.CIg(raster,nir_band_id=5, green_band_id=2)
Clgreen2 = arcgis.raster.cig(raster,band_indexes="5 2", astype=None)

#save
Clgreen.save(output+'\\'+date+'_' +'clgreen.tif')
Clgreen2.save(output+'\\'+date+'_' +'clgreen2.tif')
NDVI.save(output+'\\'+date+'_'+'ndvi2.tif')

print('scripting was successfull ! ')

Clg Indices in photoviewer

When imported into GIS

Image 1 is Clgreen in imageviewer and image 2 is in ArcGIS PRO.

  • So the questions I have is why is the output of the Clgreen not shown in ArcMap or ArcGIS pro, but shows fine in imageviewer

  • What would the reason be that the Clgreen2 is failing?

  • 1
    Try different stretch settings under symbology in ArcMap/Pro – BERA Mar 18 at 8:29
  • I guess, it is CIG ('C'hlorophyll 'I'ndex - 'G'reen) instead of CLG. – Kübra Mar 18 at 9:35
  • As in arcpy.ia.CIg – Kübra Mar 18 at 9:42
  • Thanks @BERA, I did change the Strech to be from - 1 to 5 ( it was at a maximum of 30000) do you perhaps know how to set the maximum in python so it doesnt have a max of 30000? – john10710 Mar 19 at 7:49
  • @Kübra thanks, but I dont think its the ( Chlorophyll index - green) , the formula requests the NIR and Green bands to calculate the values. BERA indicated the stretch was wrong, which solved the problem i had with "CLgreen". but i am unsure why the " CLgreen2" didnt work, not giving an output and failing. – john10710 Mar 19 at 7:54

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.