/3.2 (Extension.1 Name: "Surfer Extension 2.8" Dependencies: "$AVEXT/Spatial.avx\n" FirstRootClassName: "PMenu" Roots: 2 Roots: 6 Roots: 7 Roots: 8 Roots: 9 Roots: 10 Version: 32 About: "Surfer Extension 2.8 by Johannes Weigel is a tool to convert Surfer Grids into ArcView ASCII Grids and vice versa." InstallScript: 9 UninstallScript: 10 ExtVersion: 2 ) (PMenu.2 Child: 3 Child: 4 Child: 5 Label: "Surfer" ) (Choice.3 Help: "Surfer Grid Importer//Converts large amounts of Surfer ASCII grids to ArcView ASCII Grids" Label: "Surfer (*.grd) to Arc Grid (*.asc)" Click: "Surfer.ImportSurfer" Shortcut: "Keys.None" ) (Choice.4 Help: "Surfer Grid Exporter//Converts large amounts of ArcView ASCII grids to Surfer ASCII Grids" Label: "Arc Grid (*.asc) to Surfer (*.grd)" Click: "Surfer.ExportSurfer" Shortcut: "Keys.None" ) (Choice.5 Help: "Information about surfer//Information about Surfer Extension 2.8 by Johannes Weigel" Label: "About Surfer Extension" Click: "Surfer.Info" Shortcut: "Keys.None" ) (Script.6 Name: "surfer.ExportSurfer" SourceCode: "'Modified:\n'---------------------------------------------------\n'Name: surfer.ExportSurfer\n'Author/Date: Johannes Weigel/ Jan. 22, 2002\n'Bug reports: weigel@ecogis.de\n'Prepared at: Franzius Institute for Hydraulic, Waterways and Coastal Engineering\n' University of Hanover\n'Description: Exports multiple Arc grids to Surfer grids keeping their names\n'Requires: ArcView 3.1 + Spatial Analyst\n'Calls: \n'It is called by: \n'Self: \n'Retur ns:\n'FileName:\n'---------------------------------------------------\n\ncontinueAll=false\n\nfirstFile=true\nfileType=\"ArcView ASCII Grid\"\ntheTitle = \"Import\" ++ fileType ++ \"Files\"\nthePatterns = {\"*.asc\",\"*.*\"}\ntheLabels = {\"ArcView ASCII grids (*.asc)\",\"All Files (*.*)\"}\n\ninFNList = FileDialog.ReturnFiles(thePatterns,theLabels,theTitle,0)\nif (inFNList = NIL) then \n return NIL \nend\nif (inFNList.Count < 1) then \n return NIL \nend\n\ninputFileName=inFNList.Get(0)\ninputBase=inputFileName.getBaseName\ninputPfad=inputF ileName.asString.substitute(inputBase,\"\")\ntextOrdner=inputPfad\n\ndefname=\"autogenerated\".asFileName\ntheFName = FileDialog.Put(defName,\"\", \"Create Surfer ASCII grids in...\")\nif (theFName=nil)\n then return (nil)\nend\n\nOutputPfad=theFName.asString\noutputFileName=theFName\noutputBase=outputFileName.getBaseName\noutputPfad=outputFileName.asString.substitute(outputBase,\"\")\ngridOrdner=outputPfad\n\nnum=inFNList.count.asString\nif (MsgBox.YesNo(\"Are You sure You want to convert the \"+num+\" arc Grids to surfer grids in \"+ \n OutputPfad.left((Outputpfad.count)-1),\"Are you sure?\",true)=false)\n then return (nil)\nend\n\nav.ShowStopButton\nav.UseWaitCursor\nav.ClearStatus\nhowMany=inFNList.count\ni=0\n\nfor each inFN in inFNList\n theName=inFN.asString.Substitute(inputPfad,\"\")\n av.ShowMsg(\"Preparing\"+theName+\"...\")\n importGrid = Grid.MakeFromASCII(inFN,true)\n \n nRows=importGrid.getnumrowsandcols.get(0)\n nRows.setformat(\"d\")\n nCols=importGrid.getnumrowsandcols.get(1)\n nCols.setFormat(\"d\")\n Cellsize=importGrid.getCellSize\n grdNod atStr=\"1.70141E+038\"\n ascNodatStr=\"-9999\"\n xllcorner=importGrid.getExtent.getLeft\n yllcorner=importGrid.getExtent.getBottom\n xurcorner=importGrid.getExtent.getRight\n yurcorner=importGrid.getExtent.getTop\n Minimum=importGrid.getStatistics.get(0)\n Maximum=importGrid.getStatistics.get(1)\n \n newxllcorner=(xllCorner+(cellsize/2))\n newxurcorner=(xurcorner-(cellsize/2))\n newyllcorner=(yllCorner+(cellsize/2))\n newyurcorner=(yurCorner-(cellsize/2))\n newxllcorner.setformat(\"d.ddddddd\")\n newyllcorner.set format(\"d.ddddddd\")\n newxurcorner.setformat(\"d.ddddddd\")\n newyurcorner.setformat(\"d.ddddddd\") \n surferHeader=\"DSAA\"+NL+\n ncols.asstring++nrows.asstring+NL+\n newxllcorner.asstring++newxurcorner.asstring+NL+\n newyllcorner.asstring++newyurcorner.asstring+NL+\n Minimum.asstring++maximum.asstring\n \n av.ShowMsg(\"Analyzing \"+theName+\"...\")\n \n tempFN=\"$TEMP/surfer_export.tmp\".asFileName\n if (File.exists(tempFN)) then\n File.Delete(tempFN)\n end\n importGrid. SaveAsASCII(tempFN)\n openFile=LineFile.Make(tempFN, #FILE_PERM_READ)\n headerList={}\n openFile.Read(HeaderList,6)\n outFN=(theName.substitute(\".asc\",\".grd\")).asFileName\n \n newFileStr=\"\"\n av.ShowMsg(\"Converting \"+theName+\"...\")\n \n writeFile=LineFile.Make(outFN, #FILE_PERM_WRITE)\n writeFile.writeElt(surferHeader)\n j=0\n for each num in (0..(nRows-1))\n openFile.setPos(nRows-num+5)\n aLine=openFile.ReadElt.substitute(ascNodatstr,grdNodatStr)\n writeFile.WriteElt(aLine+\" \"+NL)\n j= j+1\n av.setStatus(j/nRows*100)\n end\n writeFile.close\n openFile.close\n file.delete(tempFN)\n if (j<>nRows) then\n MsgBox.Warning(\"Number of Rows is \"+j.asString+\", but expected number is \"+nRows.asstring+\". Check output grid.\",\n \"Warning!\")\n end\n i=i+1\n av.ShowMsg(i.asString++\"of\"++howMany.asString++\"Grids converted.\")\nend\n\nav.ClearStatus\nav.clearmsg\nMsgBox.Info(\"Operation successful.\",\"Ready.\")" ) (Script.7 Name: "surfer.ImportSurfer" SourceCode: "'Modified:\n'---------------------------------------------------\n'Name: surfer.ImportSurfer\n'Author/Date: Johannes Weigel/ Jan. 22, 2002\n'Bug reports: weigel@ecogis.de\n'Prepared at: Franzius Institute for Hydraulic, Waterways and Coastal Engineering\n' University of Hanover\n'Description: Imports multiple surfer ASCII grids keeping their names.\n'Requires: ArcView 3.1\n'Calls: \n'It is called by: \n'Self: \n'Returns:\n'FileName:\n'-------- -------------------------------------------\n\ncontinueAll=false\n\nfirstFile=true\nfileType=\"Surfer Grid\"\ntheTitle = \"Import\" ++ fileType ++ \"Files\"\nthePatterns = {\"*.grd\",\"*.*\"}\ntheLabels = {\"Surfer ASCII grids (*.grd)\",\"All Files (*.*)\"}\n\ninFNList = FileDialog.ReturnFiles(thePatterns,theLabels,theTitle,0)\nif (inFNList = NIL) then \n return NIL \nend\nif (inFNList.Count < 1) then \n return NIL \nend\n\ninputFileName=inFNList.Get(0)\ninputBase=inputFileName.getBaseName\ninputPfad=inputFileName.asString.substitute(inpu tBase,\"\")\ntextOrdner=inputPfad\n\ndefname=\"autogenerated\".asFileName\ntheFName = FileDialog.Put(defName,\"\", \"Create Arc ASCII grids in...\")\nif (theFName=nil)\n then return (nil)\nend\n\nOutputPfad=theFName.asString\noutputFileName=theFName\noutputBase=outputFileName.getBaseName\noutputPfad=outputFileName.asString.substitute(outputBase,\"\")\ngridOrdner=outputPfad\n\nnum=inFNList.count.asString\nif (MsgBox.YesNo(\"Are You sure You want to convert the \"+num+\" Surfer grids to Arc grids in \"\n +OutputPfad.left((Outputpfad.coun t)-1),\"Are you sure?\",true)=false) then\n return (nil)\nend\n\nav.ShowStopButton\nav.UseWaitCursor\nav.ClearStatus\nhowMany=inFNList.count\ni=0\nnodataStr=\"1.70141e+038\"\ntheprocess=false\n\nfor each inFN in inFNList\n openFile=LineFile.Make(inFN, #FILE_PERM_READ)\n headerList=list.Make\n str=openFile.Read(headerList,5)\n\n theName=inFN.asString.Substitute(inputPfad,\"\")\n av.ShowMsg(\"Analyzing\"+theName+\"...\")\n outFN=(theName.substitute(\".grd\",\".asc\")).asFileName\n 'Herausfinden der Parameter\n errors=0\n novals=0\n theTitle=headerList.get(0)\n if (theTitle=nil) then\n novals=novals+1\n end\n theCols=headerList.get(1).Extract(0)\n if (theCols=nil) then\n novals=novals+1\n else\n if (theCols.isNumber.not) then\n errors=errors+1\n end\n end\n theRows=headerList.get(1).Extract(1)\n if (theRows=nil) then\n novals=novals+1\n else\n if (theRows.isNumber.not) then\n errors=errors+1\n end\n end\n theRWleft=headerList.get(2).Extract(0)\n if (theRWle ft=nil) then\n novals=novals+1\n else\n if (theRWleft.isNumber.not) then\n errors=errors+1\n end\n end \n theRWright=headerList.get(2).Extract(1)\n if (theRWright=nil) then\n novals=novals+1\n else\n if (theRWright.isNumber.not) then\n errors=errors+1\n end\n end\n theHWlow=headerList.get(3).Extract(0)\n if (theHWlow=nil) then\n novals=novals+1\n else\n if (theHWlow.isNumber.not) then\n errors=errors+1\n end\n end\n theHWup=heade rList.get(3).Extract(1)\n if (theHWup=nil) then\n novals=novals+1\n else\n if (theHWup.isNumber.not) then\n errors=errors+1\n end\n end\n theMin=headerList.get(4).Extract(0)\n if (theMin=nil) then\n novals=novals+1\n end\n theMax=headerList.get(4).extract(1)\n if (theMax=nil) then\n novals=novals+1\n end\n if (novals>0) then\n MsgBox.Warning(\"Some expected parameters in the grid header could not be identified. \"+\n \"Please verify that the source file i s an ASCII Surfer grid file.\",\"Problem!\")\n return nil\n end\n if (errors>0) then\n Msgbox.Warning(errors.asString+\" of 6 parameters in the grid header of '\"+inFN.getBaseName+\n \"' contain non-numeric values. Operation can not be continued.\",\"Problem!\")\n return nil\n end\n theXCellSize=((theRWright.asNumber-theRWleft.asNumber)/(theCols.asNumber-1)).abs\n theYCellSize=((theHWup.asNumber-theHWlow.asNumber)/(theRows.asNumber-1)).abs\n if ((theXCellSize<>theYCellSize) and (theproc ess<>nil)) then\n theprocess=MsgBox.AllYesno(\"X Cell Size is \"+theXCellSize.asString+\", but Y Cell size is \"+theYCellSize.asString+\n \". Output grid may be shifted! Continue with mean values?\",\"Problem!\",false)\n if (theprocess=false) then\n return nil\n end\n themeansize=(thexcellsize+theycellsize)/2\n thexcellsize=themeansize\n theycellsize=themeansize\n end \n if ((theTitle<>\"DSAA\") and (continueAll=false)) then\n answer=MsgBox.AllYesNo(\"The file '\"+inFN.g etBaseName+\"' doesn't seem to be a valid surfer grid file. \"+\n \"First item is expected to be 'DSAA', not '\"+theTitle+\"'. Continue anyway?\",\"Warning!\",false)\n if (answer=nil) then\n continueAll=true\n end\n if (answer=false) then\n return nil\n end\n end\n\n therwleftnum=therwleft.asnumber-(theXCellSize/2)\n therwleftnum.setformat(\"ddddddd.ddddd\")\n thehwlownum=theHWlow.asnumber-(theYCellSize/2)\n thehwlownum.setformat(\"ddddddd.ddddd\")\n \n theRWleft=therwleft num.asstring\n theHWlow=thehwlownum.asstring\n newHeader=\"ncols \"+theCols+NL+\n \"nrows \"+theRows+NL+\n \"xllcorner \"+theRWleft+NL+\n \"yllcorner \"+theHWlow+NL+\n \"cellsize \"+theXCellSize.asString+NL+\n \"nodata_value \"+nodataStr\n \n newFileStr=\"\"\n av.ShowMsg(\"Converting \"+theName+\"...\")\n nRows=theRows.asNumber\n \n tempFile=lineFile.Make(\"$TEMP/surfer_import.tmp\".asFileName,#FILE_PERM_WRITE)\n j=0\n dataLine=\"\"\n while (not (openFile.isatend))\n aLine=openFile.ReadElt.trim.substitute(NL,\"\")\n if (aLine.trim<>\"\") then\n dataLine=dataLine+\" \"+aLine\n else\n 'msgBox.report(\"Schreibe \"+dataline+\" an Stelle \"+(nRows-j+5).asstring,\"\")\n if (dataline.trim<>\"\") then\n tempFile.WriteElt(dataLine)\n end\n dataLine=\"\"\n j=j+1\n av.setStatus(j/nRows*100)\n end\n end\n 'last line\n if (dataLine.trim<>\"\") then\n tempFile.WriteElt(dataLine)\n end\n\n openFile.close\n writeFile=LineFile.Make(outFN, #FILE_PERM_WRITE)\n writeFile.writeElt(newHeader)\n j=0\n for each num in 1..(nRows)\n tempFile.setPos(nRows-num)\n \n aLine=tempFile.ReadElt\n\n 'msgbox.report(aline,\"\")\n writeFile.WriteElt(aLine+\" \"+NL)\n j=j+1\n av.setStatus(j/nRows*100)\n end\n tempFile.close\n File.delete(\"$TEMP/surfer_import.tmp\".asFileName)\n writeFile.close\n if (j<>nRows) then\n MsgBox.Warning(\"Number of Rows is \"+j.asString+\", but expected number is \"+theRows+\". Check output grid.\", \n \"Warning!\")\n 'return nil\n end\n \n i=i+1\n av.ShowMsg(i.asString++\"of\"++howMany.asString++\"Grids converted.\")\nend\n\nav.ClearStatus\nav.clearmsg\nMsgBox.Info(\"Operation successful.\",\"Ready.\")" ) (Script.8 Name: "surfer.Info" SourceCode: "'Modified:\n'---------------------------------------------------\n'Name: surfer.Info\n'Author/Date: Johannes Weigel/ Jan. 22, 2002\n'Bug reports: weigel@ecogis.de\n'Prepared at: Franzius Institute for Hydraulic, Waterways and Coastal Engineering\n' University of Hanover\n'Description: Provides information about Surfer Extension\n'Requires: ArcView 3.1\n'Calls: \n'It is called by: \n'Self: \n'Returns:\n'FileName:\n'----------------------------- ----------------------\n\nMsgBox.Info(\"Surfer Extension 2.8 by Johannes Weigel.\"+NL+\n \"Portions of this work include intellectual property of Johannes Weigel and are used herein with permission. \"+\n \"Copyright (C) 2002-2004 by Johannes Weigel. All rights reserved. For further information please write to weigel@ecogis.de.\",\n \"About Surfer Extension\")\n" ) (Script.9 Name: "surfer.Install" SourceCode: "'Modified:\n'---------------------------------------------------\n'Name: surfer.Install\n'Author/Date: Johannes Weigel/ June 08, 2002\n'Bug reports: weigel@ecogis.de\n'Prepared at: Franzius Institute for Hydraulic, Waterways and Coastal Engineering, University of Hanover\n'---------------------------------------------------\n'Description: Activates the surfer Extension\n'Requires: ArcView 3.1\n'Calls: \n'It is called by: \n'Self: \n'Returns:\n'FileName:\n'---- -----------------------------------------------\n\nif (av.GetProject=nil)\n then return(nil)\nend\ntheProject=av.GetProject\n\ntheMenuBar=theProject.FindGUI(\"View\").GetMenuBar\ntheMenu=theMenuBar.FindByLabel(\"Window\")\n\nif (theMenu=nil)\n then theMenu=theMenuBar.FindByLabel(\"Fenster\")\nend\nif (theMenu<>nil)\n then theMenuBar.Add(self.Get(0),theMenuBar.GetControls.Find(theMenu))\nelse\n theMenuBar.Add(self.Get(0),999)\nend\nav.setName(av.getName+\" + Surfer Extension\")\n\n\n" ) (Script.10 Name: "surfer.Uninstall" SourceCode: "'Modified:\n'---------------------------------------------------\n'Name: surfer.Uninstall\n'Author/Date: Johannes Weigel/ June 08, 2002\n'Bug reports: weigel@ecogis.de\n'Prepared at: Franzius Institute for Hydraulic, Waterways and Coastal Engineering, University of Hanover\n'---------------------------------------------------\n'Description: Deactivates the surfer extension\n'Requires: ArcView 3.1\n'Calls: \n'It is called by: \n'Self: \n'Returns:\n'FileName:\n' ---------------------------------------------------\n\nif (av.GetProject=nil)\n then return(nil)\nend\ntheProject=av.GetProject\n\nif (theProject.isClosing)\n then return (nil)\nend\n\ntheMenuBar=theProject.FindGUI(\"View\").GetMenuBar\ntheMenuBar.Remove(self.Get(0))\nav.setName(av.getName.substitute(\" + Surfer Extension\",\"\"))\n\n\n" )