' Description: Creates a hillshade grid from a converted DEM source in decimal degrees ' by calculating an appropriate Zfactor ' ' Name: Spatial.DEMShade ' ' Requires: Spatial Analyst Extension ' ' Self: ' ' Returns: ' ' FileName: demshad.ave theView = av.GetActiveDoc ' CREATE HILLSHADE FOR ACTIVE GTHEME ' t = theView.GetActiveThemes.Get(0) ' OBTAIN PARAMETERS FOR HILLSHADE ' status = TRUE while (status) paramList = MsgBox.MultiInput("Input parameters for hillshade:","Compute Hillshade",{"Azimuth (0 - 360):","Altitude (0 - 90):"},{"315","45"}) if (paramList.Count <2) then return NIL end theAzimuth = paramList.Get(0) theAltitude = paramList.Get(1) if (theAzimuth.IsNumber and ((theAzimuth.AsNumber >= 0) and (theAzimuth.AsNumber <= 360))) then azOK = TRUE else azOK = FALSE MsgBox.Info("Azimuth must be a number from 0 to 360","Compute Hillshade") end if (theAltitude.IsNumber and ((theAltitude.AsNumber >= 0) and (theAltitude.AsNumber <= 90))) then alOK = TRUE else alOK = FALSE MsgBox.Info("Altitude must be a number from 0 to 90","Compute Hillshade") end if (azOK and alOK) then status = FALSE else status = TRUE end end ' OBTAIN GRID FROM THEME AND CREATE HILLSHADE ' g = t.GetGrid 'r = g.HillShade(theAzimuth.AsNumber,theAltitude.AsNumber,NIL) 'zFactor = ( 1 / length of degree of long ) * 3600 theRec = t.ReturnExtent theLatitudeBottom = theRec.GetBottom.Abs theLatitudeTop = theRec.GetTop.Abs if (theLatitudeTop > theLatitudeBottom) then theDiff = theLatitudeTop - theLatitudeBottom theHalfDiff = theDiff / 2 theLatitude = theLatitudeTop - theHalfDiff else theDiff = theLatitudeBottom - theLatitudeTop theHalfDiff = theDiff / 2 theLatitude = theLatitudeTop + theHalfDiff end ' USE .abs TO MAKE SURE THE Z FACTOR IS A POSITIVE VALUE ' THE MULTIPLIER (3600 / 360) CAN BE ADJUSTED TO INCREASE OR DECREASE THE ' Z FACTOR WHICH WILL CHANGE THE LENGTH OF SHADOWS zFactor = ( 1 / (6370997*(theLatitude.Cos)*(Number.GetPi/180))) * (3600 / 360) msgbox.info(zfactor.abs.AsString,"Z factor") r = g.HillShade(theAzimuth.AsNumber,theAltitude.AsNumber,zFactor.abs) ' RENAME DATA SET ' aFN = av.GetProject.GetWorkDir.MakeTmp("hlshd", "") r.Rename(aFN) ' ERROR CHECK ' if (r.HasError) then return NIL end ' CREATE A THEME ' gthm = GTheme.Make(r) ' CREATE APPROPRIATE LEGEND FOR THEME ' theLegend = gthm.GetLegend theLegend.Area(gthm,"Value",9) theSymbolList = theLegend.GetSymbols theNullSymbol = theSymbolList.Get(theSymbolList.Count - 1) theSymbolList.Remove(theSymbolList.Count - 1) theSymbolList.RampColors(Color.GetBlack,Color.GetWhite) theSymbolList.Add(theNullSymbol) gthm.UpdateLegend ' SET NAME OF THEME ' gthm.SetName("Hillshade of " + t.GetName) ' ADD THEME TO THE SPECIFIED VIEW ' theView.AddTheme(gthm)