' ---------------------------------------------------------------------- ' DiskFile : atvegind.ave : Atmos (Veg Index) ' Programmer : Tom Van Niel ' Created : 05-Nov-99 ' Revisions : ' Function : Calculates a User Specified Vegetation Index ' ' References : Deering, D. W., J. W. Rouse, R. H. Haas, and J. A. Schell, ' 1975. Measuring forage production of grazing units from ' Landsat MSS data, Proceedings, 10th International ' Symposium on Remote Sensing of Environment, Vol. 2, pp. ' 1169-1178. ' : Huete, A. R., 1987. Soil and sun angle interactions on ' partial canopy spectra: Int. J. Remote Sens, 8:1307-1317. ' : Rouse, J. W., R. H. Haas, J. A. Schell, and D. W. Deering, ' 1973. Monitoring Vegetation Systems in the Great Plains ' with ERTS, Proceedings, Third ERTS Symposium, Vol. 1, ' pp. 48-62. ' Called By : GUI ' Calls : None ' Sister Code: None ' ---------------------------------------------------------------------- ' Vegetation Index Formulas: ' NDVI = (NIR - red) / (NIR + red) [Rouse et al. (1973)] ' SAVI = [(NIR - red) / (NIR + red + L)] * (1 + L) [Huete, 1987] ' TNDVI = (NDVI + 0.5) 1/2 [Deering et al. (1975)] ' Initialize Variables ViList = {"NDVI","SAVI","TNDVI"} AdjustList = {"Automatic Adjustment","Allow Negative Values"} ' Get NIR Grid NIRSrcList = SourceDialog.ShowClass("Select NIR GRID.",Grid) If (NIRSrcList.Count = 0) then return NIL end If (NIRSrcList.Count > 1) then msgbox.ERROR("Must Select only one NIR Grid","NIR GRID SELECT ERROR") return NIL End If (Grid.IsValidDataSetFileName(NIRSrcList.Get(0).GetFileName)) then NIRGrid = Grid.Make(NIRSrcList.Get(0)) Else msgbox.info("Not A Valid Grid. Please Try Again","NIR GRID ERROR") return nil End If (NIRGrid.HasError) then MsgBox.Error("NIR Grid Has an Error, Exiting","NIR GRID ERROR") return Nil End ' Get Red Grid RedSrcList = SourceDialog.ShowClass("Select RED GRID.",Grid) If (RedSrcList.Count = 0) then return NIL end If (RedSrcList.Count > 1) then msgbox.ERROR("Must Select only one RED Grid","RED GRID SELECT ERROR") return NIL End If (Grid.IsValidDataSetFileName(RedSrcList.Get(0).GetFileName)) then RedGrid = Grid.Make(RedSrcList.Get(0)) Else msgbox.info("Not A Valid Grid. Please Try Again","Red GRID ERROR") return nil End If (RedGrid.HasError) then MsgBox.Error("Red Grid Has an Error, Exiting","RED GRID ERROR") return Nil End ' Get VI selection, Scaling Factor, and Negative Adjustment Option from user VI = MsgBox.ListAsString(ViList,"Choose VI to Calculate","VI Selection") If (VI = Nil) then Return Nil End ScalingFactor = MsgBox.Input("Enter Scaling Factor to Adjust VI","Scaling Factor Input",1.AsString) If (ScalingFactor = Nil) then Return Nil End If (ScalingFactor.IsNumber.Not) then MsgBox.Info("Scaling Factor is Not a Valid Number, Exiting.","Please Try Again") Return Nil Else ScalingFactor = ScalingFactor.AsNumber End Adjust = MsgBox.ListAsString(AdjustList,"Enter Negative Value Option"+NL+"(Adjust Negative Values or Allow Negative Values)","Negative Values Option") If (Adjust = Nil) then Return Nil End ' Run VI Calculation If (VI = "NDVI") then ViGrid = ((NIRGrid - RedGrid) / (NIRGrid + RedGrid)) * ScalingFactor ElseIF (VI = "SAVI") then L = MsgBox.Input("Enter L factor","SAVI L Factor Input",0.5.AsString) If (L = Nil) then Return Nil End If (L.IsNumber.Not) then MsgBox.Info("L Factor is Not a Valid Number, Exiting.","Please Try Again") Return Nil Else L = L.AsNumber End ViGrid = (((NIRGrid - RedGrid) / (NIRGrid + RedGrid + L.AsGrid)) * (1.AsGrid + L.AsGrid)) * ScalingFactor Else ViGrid = ((((NIRGrid - RedGrid) / (NIRGrid + RedGrid)) + 0.5.AsGrid) * 0.5.AsGrid) * ScalingFactor End ' Check for Negative Value Adjustment, Adjust automatically If (Adjust = "Automatic Adjustment") then ViStatsList = ViGrid.GetStatistics ViMin = ViStatsList.Get(0) If (ViMin < 0) then ViGrid = ViGrid + ViMin.Abs.AsGrid End End ' Save DataSet ViFN = av.GetProject.GetWorkDir.MakeTmp(VI,"") If (ViGrid.HasError.Not) then ViGrid.SaveDataSet(ViFN) Else MsgBox.Error("Output Grid"++ViFN.AsString++"has an error","ERROR") End