' Description: Imports a DEM file and automatically creates ' a grid theme in a decimal degree coordinate system rather than ' arc seconds (default). ' ' Name: Spatial.DEMShift ' ' Requires: Spatial Analyst Extension ' ' Self: ' ' Returns: ' ' FileName: demshft.ave theView = av.GetActiveDoc ' SET PATTERNS AND TITLE ' theTitle = "Import" ++ "DEM" ++ "Files" thePatterns = {"*.dem","*.*"} theLabels = {"DEM Files (*.dem)", "All Files (*.*)"} ' FIND THE FILE ' inFNList = FileDialog.ReturnFiles(thePatterns,theLabels,theTitle,0) if (inFNList = NIL) then return NIL end if (inFNList.Count < 1) then return NIL end firstTime = TRUE for each inFN in inFNList if (firstTime) then def = av.GetProject.MakeFileName("imgrd", "") else def = FileName.GetCWD.MakeTmp("imgrd","") end ' theTmp = FileName.GetCWD.MakeTmp("tmp","") ' def = av.GetProject.MakeFileName("imgrd", "") ' FIND THE OUTPUT NAME FOR GRID ' gridFN = SourceManager.PutDataSet(GRID,"Output Grid :" ++ inFN.GetBaseName,def,TRUE) if (gridFN = NIL) then continue end ' PERFORM CONVERSION ' r = Grid.MakeFromDEM(inFN) 'GRID SHIFT SECTION ' theRec = r.GetExtent theBot = theRec.GetBottom theLeft = theRec.GetLeft theSize = r.GetCellSize theNewGrid = r.Shift(((theLeft/3600)@(theBot/3600)),(theSize/3600)) theNewGrid.SaveDataSet(gridFn) theNewGtheme = GTheme.Make(theNewGrid) theView.AddTheme(theNewGtheme) ' SAVE DATA SET WITH NAME GIVEN BY USER status = Grid.GetVerify Grid.SetVerify(#GRID_VERIFY_OFF) if (r.SaveDataSet(gridFN).Not) then Grid.SetVerify(status) continue end Grid.SetVerify(status) ' ERROR CHECKING ' if (r.HasError) then MsgBox.Error("File" ++ inFN.GetBaseName ++ "can not be imported as a Grid", "Import Error") continue end firstTime = FALSE end