I have to create NDVI's for multiple raster images, and so want to find out the most efficient way to do it.
The code below works, but I wondered if there was a more efficient way to do it?
# Strip out the red and near infrared bands
arcpy.CompositeBands_management(input_raster + r"\Band_3", "raster_red")
arcpy.CompositeBands_management(input_raster + r"\Band_4", "raster_nearir")
# Create the ndvi numerator and denominators
arcpy.Minus_3d("raster_nearir", "raster_red", "numerator")
arcpy.Plus_3d("raster_nearir", "raster_red", "denominator")
# Set local variables
top = arcpy.sa.Raster("numerator")
bottom = arcpy.sa.Raster("denominator")
# Execute Divide
raster_ndvi = top / bottom
# Save the output
raster_ndvi.save("ndvi_result")```