'BATCH CONVERT (LOADED) GRID THEMES TO IDRISI32 .rst FORMAT 'MODIFIED FROM Holger Schäuble's av2idrisi 'REQUIRES av2idrisi.dll, downloadable from "http://arcscripts.esri.com/details.asp?dbid=11746" 'LOADING SCRIPTS ' 1. Double-click on an empty area on the bar containing all buttons, The "Customize" dialog appears ' 2. In the "Type" pull-down, select "View" ' 3. In the "Category" pull-down, select "Buttons", The display right below the pull down changes to show an array of buttons ' 4. Slide the scrollbar (below the button display) to the right and select the last button by clicking on it, Now click on "New" ' 5. A new blank button appears. Double-click on the blank area to the right of the entry "Click" (just below the button display) ' 6. The "Script Manager" Dialog appears, Click on "New", Enter any name in the input box that appears (prefix it with "Z_" so that it goes in the last) ' 7. A new blank script document (With the name just specified) appears. Delete whatever is on it... ' 8. Either copy-paste this ENTIRE script on the document, or, click on the button with the open-folder icon (tooltip reads "Load text file") and navigate to this file ' 9. Either done, click on the button with the tick-mark icon ("compile"). If spatial analyst is not loaded, there will be some error message, Load it ' 10. After the script is compiled (the tick-mark buton should be grayed out), close the script window and return to the view ' 11. Click on the new button to run the script theView = av.GetActiveDoc theThemes = theView.GetActiveThemes Option = 1 'Grid2Idrisi Filetyp = 1 'Binary theBool = msgbox.YesNo("Shall the new raster images be written in"+NL+"the new Idrisi32 format. No will convert them"+NL+"to the old Idrisi image format instead.","Grid2Idrisi32",TRUE) if(theBool) then i32flag = 1 else i32flag = 0 end theProg = System.GetEnvVar(\"AVHOME\") + "\bin32\\" + "av2idrisi.dll\" theDll = Dll.Make(theProg.AsFileName) if(theDll = NIL) then msgbox.error("Cannot find av2idrisi.dll in the BIN32 directory.","Error") return NIL end ConFunc = DllProc.Make(theDll,"av2idrisi",#DLLPROC_TYPE_INT32, {#DLLPROC_TYPE_STR,#DLLPROC_TYPE_STR,#DLLPROC_TYPE_INT32,#DLLPROC_TYPE_INT32, #DLLPROC_TYPE_INT32,#DLLPROC_TYPE_INT32,#DLLPROC_TYPE_STR}) for each thm in theThemes theName = thm.GetName firstFN = FileName.GetCWD.MakeTmp(thm.GetGrid.GetSrcName.GetFileName.GetBaseName,"") if(i32flag = 1) then theOutFN = FileDialog.Put(firstFN,"*.rst","Save "+theName+" as IDRISI32 raster") else theOutFN = FileDialog.Put(firstFN,"*.img","Save "+theName+" as IDRISI raster") end if(theOutFN = NIL) then continue end Infile = thm.GetGrid.GetSrcName.GetFileName.AsString Outfile = theOutFN.GetFullName if(thm.GetGrid.IsInteger) then Datentyp = 1 'ArcView Integer als Idrisi integer theMin = thm.GetGrid.GetStatistics.Get(0) theMax = thm.GetGrid.GetStatistics.Get(1) if((theMin < -32768) OR (theMax > 32767)) then Datentyp = 2 'ArcView Integer als Idrisi real end else Datentyp = 2 'Float end av.ClearMsg av.ClearStatus err = ConFunc.Call({Infile,Outfile,Option,Datentyp,Filetyp,i32flag,theName}) if(err=1) then msgbox.error("Error, conversion of "+theName+" failed.", "Error") else av.ShowMsg("Conversion finished successfully.") end end