I am trying to run NDVI calculations with Arcpy. My script is running but ArcGIS crashes each time I try to run it. Here is the part of the script with the problem:
for raster in rasterList:
try:
#Define the inputs
arcpy.AddMessage('Calculating NDVI for ' + raster)
NIR = raster + "\Band_1"
Red = raster + "\Band_2"
#Define outputs �?? Note: These will need to be deleted if you need to run this script again
NIR_out = "NIR.tif"
Red_out = "Red.tif"
#Copy raster and map algebra �?? makes new rasters of Red and NearIR
arcpy.AddMessage('exporting raster bands for calculation')
arcpy.CopyRaster_management(NIR, NIR_out)
arcpy.AddMessage('NIR band exported successfully')
arcpy.CopyRaster_management(Red, Red_out)
arcpy.AddMessage('Red band exported successfully')
#Create Numerator and Denominator rasters as variables and NDVI output (note that arcpy.sa.Float returns a floating point raster)
result = "NDVI.tif"
NIRfloat = float(NIR)
Redfloat = float(Red)
Num = Raster(NIRfloat) - Raster(Redfloat)