'''********************************************************** PCI Geomatics(C) - NDVI Workflow **********************************************************''' print "" print "" print "***************************************************************" print "" print " -= PCI Geomatics(C) =-" print " NDVI Workflow" print " Last modified July 07, 2015" print " Developed on Geomatica 2015 SP1 " print "" print "***************************************************************" # This script runs the following PPFs in a top-down sequence on a single image # 1. FIMPORT # 2. PCIMOD # 3. MODEL import os import pci from pci.fimport import fimport from pci.pcimod import pcimod from pci.model import model from pci.exceptions import * # ------------------------------------------------ # Ingest Image # ------------------------------------------------ # This FIMPORT ppf ingests the image into pix format print "" print "STEP 1" print "Ingesting Image..." fili = r"Y:\VariousSensors\Landsat8\SantaBarbara_California\LC80420362013124LGN00\LC80420362013124LGN00_MTL.txt-MS" filo = r"C:\test\PythonNDVI.pix" fimport(fili, filo, [], "", "") print "File has been ingested" # ------------------------------------------------ # Add a channel to the image # ------------------------------------------------ # This PCIMOD ppf creates a new channel in the ingested pix file. For NDVI a 32-bit channel is required print "" print "STEP 2" print "Adding required channel..." pciop = "ADD" pcival = [0,0,0,1] pcimod(filo,pciop,pcival) print "Channel has been added" # ------------------------------------------------ # Perform NDVI calculation # ------------------------------------------------ # This MODEL ppf runs the NDVI equation: 32bit channel = (NIR ? Red)/(NIR + Red) print "" print "STEP 3" print "Calculating NVDI..." source = "%9 = (%5-%4)/(%5+%4)" # These bands will change based on your image. model (filo, source, []) print "NDVI has been calculated" # ------------------------------------------------ # Open ingested file # ------------------------------------------------ print "" print "STEP 4" print "Opening file in Focus... Once it is open you can load your NDVI band from the files tab." file = r"C:\test\PythonNDVI.pix" os.system("start " +file) print "" print "End of Workflow"
Normalized Difference Vegetation Index (NDVI)
PCI Geomatics -
Comments