Intro to ArcToolbox, Geoprocessing and ModelBuilder (for GISC 6382) UTD-Briggs 1/16/2008 Geoprocessing is simply the modification and analysis of spatial (geographic) data. ArcToolbox contains a set of tools to accomplish this processing. Modelbuilder is a graphical interface which allows you to organize multi-step processing and keep track of what you have done. See Geoprocessing in ArcGIS on P:\ drive for documentation. For 9.2 updates, see Whats_New_In Arctoolbox.pdf 1. ArcToolbox, Geoprocessing, ModelBuilder Overview Greatly enhanced in ArcGIS 9---it’s the big change over 8.x Dockable window in ArcCatalog or ArcMap, rather than a separate module Has command line interface available for traditionalists and/or power users Tools supports all data types (coverages, shapefiles, gdb, raster) rather than primarily coverages Greatly expanded set of geoprocessing tools o Available for all the analyses in original, command line ArInfo 7, plus more Supports multi- step workflow via Modelbuilder and/or scripting 2. Opening and Using ArcToolbox (pp 101-127 in Geoprocessing in ArcGIS available on p:drive as .pdf) In ArcCatalog, ArcToolbox is available at the bottom of the Catalog tree (left pane) --if its not there, on Main Menu, go to Tools>Options>General tab and put check by Toolboxes This is the most assured place to look for tools: --System Toolboxes: all ESRI tools, and nobody can customize (i.e. remove tools!) from here! --My Toolboxes: all models & tools you create in any ArcMap or ArcCat application on this computer It’s often helpful also to open an ArcToolbox window (click ), which can be customized (see #5) In ArcMap, use the Launch ArcToolbox button on the Main Toolbar to open ArcToolbox --It opens as a window. Dock it where you wish. (Do this now) --For Geoprocessing, it’s generally best to use ArcMap since you can display results as you proceed --any customization (removing or adding toolboxes, etc..) are saved with the map document; they will not show if you open a new map document, but will be listed in ArcCat under Personal Toolboxes 3. Toolbox organization and creation Toolboxes simply contain Toolsets (nothing more than optional subfolders for organization), which hold individual tools Toolboxes Toolsets Tools Toolboxes can also store: Models (created through Modelbuilder) Scripts (written in Python, Jscript or VBScipt) Click the + box to see further toolsets and tools. When you right click in ArcCatalog and select a process (eg. to Define a projection) you are, in fact, running a tool which is also accessible via ArcToolbox. 4. Tool Availability Tools available for you to actually use depend on: --the level of your ArcGIS license (ArcView, ArcEditor, ArcInfo) --the extensions that you have licensed (3D Analyst, etc.) --whether ArcInfo Workstation is loaded (adds Coverage Toolbox) If you get the message “license does not authorize you to use this tool,” try the following 1 --go to Tools>Extensions and select the extension corresponding to the tool category you are using (e.g., if tool is listed under Spatial Analyst in ArcToolbox, select the Spatial Analyst extension --close the Extension window and try again 5. Adding your own toolbox and Customizing the Available Tools Note the first toolbox at the top on the previous page (called #1-My Tools—the #1 causes it to sort to the top!). To add a toolbox in ArcMap: --right click in the ArcToolbox window (or on My Toolboxes) and select New Toolbox. Name as desired (e.g. #1-YourInitials) --the toolbox is saved by default as: C:\Documents and Settings\UserID\Application Data\ESRI\ArcToolbox\My Toolboxes\#1-YourInitials.tbx --to see this, right click on new toolbox and select Properties You can customize available tools by removing, cutting /pasting, or dragging/dropping tools between tool boxes or toolsets e.g select any existing tool and drag it to another toolbox or toolset (best not to modift To add a toolset, right click on the toolbox and select New/Toolset --if you are in ArcMap and you save the map document, this customization will be present when you reopen --if you open another map document in ArcMap this customization and any new toolboxes will not show --if you are in ArcCatalog all new toolboxes created in all map documents, or any ArcCatalog session, will be listed in the left pane under My Toolboxes (my need to close/reopen ArcCatalog) You can move any new toolbox you create to other locations, but then it will not show up here in ArcCatalog. To bring into ArcCatalog toolboxes located elsewhere: --open ArcCatolog and navigate to the folder containing the desired toolbox (or model) --drag the toolbox (or just a model within a toolbox) to MyTooolboxes (in the left pane of ArcCatalog) --do this now for the toolbox #SampleModels in P:\briggs\g6382\Exercise_data\avcat (note: you cannot place one toolbox inside another. Also, must use ArcCatalog, not Windows Explorer) 6. Finding the Tool you want and getting Help on Using it --to list tools, click + boxes in the main ArcToolbox window to list tools by category. --This is tedious given the number of tools now available. --Note that different tools can have the same name in different tool sets e.g. Analysis Tools>Extract>Clip e.g. Data Management Tools>Raster>Clip --And the logic of the categories is not obvious! Why are Raster tools under Data Management? There is a Conversion Tools toolbox, as well as a Conversion Toolset in Coverage Tools (Note: Coverage Toolset only available if ArcInfo workstation installed on computer) --to find a tool, click Search tab at the bottom of the ArcToolbox window (Note: this is not the same as doing a search in ArcGIS Desktop Help) Type in a word describing the action that you would like to take, then click the Search button (at top) (e.g. enter Import ) --potential tools are displayed --select the one you want and click the Locate button at bottom of the window (e.g. select Import from Interchange file.Note: only available if ArcInfo workstation installed) You are moved to the Favorites tab, and the tool is highlighted. If you can’t find the tool this way, try going through a search in ArcGIS Desktop Help --for help with using a tool , right click on the tool and select Help --this opens ArcGIS Desktop Help for that command --this must be done in the ArcToolbox window; its not accessible via left side ArcCatalog tree! --click the Expand All box to see all information --understanding parameters --all tools have one or more parameters --essentially, these are pieces of information that the tool needs in order to run --some parameters are required, such as the name of the input data set 2 --some parameters are optional and usually have a default set, which you can change if desired --use Help for information on selecting the parameters 7. Running Tools—four ways to do it 1. with dialog box. --Double click the tool to open its dialog box, fill in parameter values, and click OK to run the tool. --this runs tools one at a time --we saw an example of doing this last week when we projected a shapefile --it is also the same as running processes by right-clicking in ArcCatalog—with many more available! 2. at command line. Type the tool name and its parameter values at a command line, then press Enter to run the tool. --Use the show/hide command line window tool to open the command line --type the command, press the Space Bar to select parameter options, press Enter to run --it is also possible to run multiple lines, and thus tools, simultaneously (hold CTRL key when pressing enter to get a new line without running current line) --we will not cover this in this class (Covered in GISC 5317 Computer Programming for GIS) 3. Build and run a graphical model that executes a sequence of geoprocessing tools. --you can create a model that runs the sequence of geoprocessing tools making up your work flow. --you can then alter parameter values (e.g specify a different input data set) then rerun the entire model with a single click. --this is very powerful and very useful and will be the focus of this course (GISC 6382 Applied GIS) 4. Create and run a script that runs geoprocessing tools. Use system batch processing scripts for repetitive tasks, such as those that run the same tool on multiple inputs, or create your own scripts that run geoprocessing tools. --think of this as a code equivalent of the graphical model --advantage over the graphical model is that it permits decision trees, looping and other logical controls. --covered in GISC 5317 Computer Programming for GIS 8. Running a Tool from its Dialog: Converting E00 Files to Coverages (must have ARCINFO level) Copy the folder avcat from P:\briggs\g6382\Exercise_data \to c:\usr\ (not My Documents) Double-click the Import from Interchange file tool. Its Dialog box opens. Specify the parameters as follows Feature Type: COVER (don’t use auto) Input Interchange File: Q:\g6382\DataSets\E00\Collin_CNTY.E00 Output DataSet: c:\usrravcat\\Col_cnty Click OK, and the E00 file is converted to a coverage (and an info folder is added to the directory if not there) Use the Add data button to bring the coverage into ArcMap Comments: This conversion not available via ArcCatalog import or export; must be done with arcToolbox This tool is only available if ArcInfo workstation installed. Its part of the Coverage Toolset You have to convert E00 files to coverages first, then you can convert them to shapefiles etc.. The conversion toolset in the Coverages toolbox has extra conversion tools not available elsewhere Warning: coverages do not support blanks in coverage names or blanks in the directory path to the coverage. Consequently, you will encounter problems running this tool if you try to save the output in My Documents or similar folders with blanks in the path name. 9.Using Graphical Models We will focus on using graphical models. They are very useful and powerful. They allow you to: 1. --keep track of, and document, the processing steps (workflow) that you carried out 2. --re-run the analysis to experiment with different parameters to see how results are affected 3. --carry out repetitive, multi-step tasks 4. --rerun the analysis if you find a mistake 5. --provide other users (e.g. operational staff members) with an exact workflow that they can replicate 9.0 Initiating a new graphical model: --if needed, open ArcCat (or ArcMap), click for ArcToolbox, and create a personal toolbox as in #5 (call it #1-your_initials) --right click personal toolbox and select New>Model, which opens the Modelbuilder window 3 --Go to Model>Model Properties, and in the tag of General, as desired: Name the model: e.g. ModelEx2 Label the model with a longer, more descriptive label (Keep it short since this is used in directory trees—I usually duplicate the Name ) Description allows detailed documentation of what model does, (if you will give this model to others to use, you may want to write a formal Help file—click the Help tab to do this) Also, see 9.5 below for information on documentation which is generated automatically --its quite extensive. Place check in Store relative path names if you intend to distribute this model to other users. --all pathnames will then have their root in the folder containing this Model (do not do this now) Click OK --Use Model>Diagram Properties to customize how the model window is displayed on the screen --this can be useful when you want to print the model in final form after development -Go to Model>Save to save the model It should now be listed at the top of Arctoolbox window (if open) in #1-your_initials toolbox, and also in left pane of ArcCatalog under My Toolboxes/#1-your_initials 9.1 Opening an existing model --right click on the model (indicated by icon) and select Edit (not Open!), for example: System Toolboxes>Spatial Statistics Tools>Mapping Clusters>Hot Spot Analysis with Rendering 9.2 Building a graphic model (including Defining a Projection, Creating a gdb, and Importing data.) We will build a model to replicate some of the steps we carried out one-at-a-time in ArcCatalog last week. It may help to narrow the ArcCatalog window to show only the left-most panel, and place on left of screen. Bring in spatial data (shapefile), and Define its projection: --go to ArcToolbox>Data Mngmnt. Tools>Proj. & Trans.>Define Projection --drag this to the Modelbuilder window, --it will display in black & white “skeleton form” — not ready to run --double click the Define Projection process box (square) to open Dialog to set the parameters --note that this is the same “dialog” that we used last week to run Define in ArcCatlog --specify input dataset: c:\usr\avcat\daycare.shp --click next to Coordinate system box (should say Unknown) and select projection as NAD 83 North Central Texas FIPS 4202 (feet) zone, then click OK or Apply and close Boxes should become solid colors (indicating “ready to run”) Reposition boxes so that they run vertically down left side Create personal GDB --go to ArcToolbox>Data Mngmnt. Tools>Workspace>Create File GDB (or Personal GDB) --drag this to the Modelbuilder window, to right of existing boxes --double click the square process box and dialog box opens—again, same box as used last week --navigate to output location folder in top box (or drag a folder from ArcCat tree into this box) --type name of GDB in bottom box e.g. DFWnew, and click OK, or Apply then close dialog --Everything solid color again--rearrange so boxes are vertical. Create Feature Data Set --go to ArcToolbox>Data Mngmnt. Tools>Workspace>Create Feature Data Set --drag this to the Modelbuilder window, below green oval labeled DFWnew.mdb --double click the process box and fill in the parameters as follows: Output Location: click the down arrow and select DFWnew.mdb (relevant names already in the model are listed for selection) Output Feature Data Set: type in Plano Click Edit button to select a Spatial Reference System (SRS) --as we said last week, this is critically important since choice of SRS will determine --coordinate system (projection) of data to be stored --the geographic area for which data can be stored (the spatial extent) --the accuracy with which locations can be recorded (the precision) Generally, import from an existing data set which is: 4 --in the desired projection --covers an area which is “comfortably” larger than the area of any layer you intend to store in this feature dataset --for this example, use tracts.shp to import the SRS If you select from an existing, predefined projection, you must define the spatial extent (otherwise subsequent data imports may fail). To do this, --click X/Y Domain tab --enter X and Y coordinates for the corners of your data set --but you probably don’t know these!!! --you could get them by bringing in an ESRI data set for the world (or the US) --see Appendix in ArcCatalog.doc for how to do this. It’s a lot of trouble! Add Feature Classes to Feature Data Set --go to ArcToolbox>Conversion Tools>To Geodatabase>Feature Class to Feature Class --drag this to the Modelbuilder window, to the left of the Plano feature data set and below daycares.shp oval --double click to open dialog box and fill in parameters as follows: (note how parameter boxes requiring info have green dots till info is entered) Input Features: click down arrow and select daycare.shp (relevant names already in the model are listed for selection) Output Location: click down area and select Plano (relevant names already in the model are listed for selection) Output Feature Class Name: type in Daycare Fill in other parameter boxes as desired for optional control of data brought in and click OK Saving the Model -Go to Model>Save to save the model Click OK Note: Dragging and Dropping Files If you are in ArcMap, you can drag a layer to the square Process box. It will automatically become the Input Data Set and an oval input box is added to the model diagram. You can also drag files from within ArcCatalog onto the model. You can also drag and drop files from Windows Explorer/My Computer but do not do this for spatial files; it will only work successfully for single files such as attribute tables (e.g. .dbf files and similar) 9.3 Using the Link tool (and removing links) Note how Processes boxes (squares) have been linked with parameter boxes (ovals), based on the parameters entered. As an alternative to entering parameters, you can use the link tool to graphically link process boxes (squares) to parameter boxes (ovals), and the corresponding parameter values are automatically filled in. --drag another Feature Class to Feature Class process box to the model and place to the right of Plano --use the link tool to link it to Plano feature data set, as Output Location (if option box opens) --link is added but boxes remain in skeleton form (not ready to run) --drag the tracts.shp file from ArcCatalog to the Model and place above Feature Class process box --use the link tool to link to Feature Class process box, as Input Feature(if option box opens) --link is added but boxes still remain in skeleton form (not ready to run) --you will still need to double click the Feature class process box and enter an Output Feature Class Name (e.g. tracts) When you use the link tool, sometimes parameters get assigned to the wrong box. To avoid this, you can set an option to be prompted to select the appropriate parameter --go to ArcCatalog>Tools>Options>Geoprocessing tab and place check in Modelbuilder box --this a allows you to select appropriate parameter (Overall, I’ve generally found it just as easy to open the process dialog and enter parameters.) To remove links, (irrespective of how they were created) --use the Select tool and click on the link so that it is selected --press the Delete key 5 9.4 Running the Model The final model should look something like this. You can run processes whenever convenient. To run the entire model (or processes not yet run) --click the run icon , or go to Model>Run Entire Model --all processes not yet run will be run --a window opens providing you with execution information --check this for red or green text, indicating problems --if none are found, close the window --after running, boxes in model will have grey shadows to show that they have run --you will need to close the execution progress box to proceed (#9.5 explains where this information is stored for later retrieval) To re-run a model Go to Model>Validate entire model (p. 319) --this checks all parameters for validity (e.g. is an input data set available?) --it also sets all processes back to the “ready to run” state, so that you can re-run the model (grey shadow disappears) --if/when you re-run the model, any gdbs or feature classes created in previous runs will be overwritten (good or bad!) To run part of a model --use selection tool to select one (or a group) of processes --click the run icon --this runs the selected processes and all earlier processes not yet run (I’ve had problems with everything running anyway!) 9.5 Adding to the Model (an example for projecting data) o Go to Data Management Tools>Projections and Transformations>Feature > and drag Project tool to the ModelBuilder window and place below daycares oval Use Link tool to link process box to daycares input file as Input Dataset Double click to open the tools dialog box, and fill in it parameters (info it needs) as follows Click icon at end of 3nd box and name usr/avcat/daycare_prj.shp Click icon at end of 4rd box , click Select button, and select Predefined>Geographic>North America>North American Datum NAD 1983 click Add and you are returned to the Project window—click OK click the Run icon Just the Project process should run. Note that a new shp file has been created daycare_project.shp Pre-view in ArcCatalog to see that it is in lat/long. Comment on projecting data: in an operational environment you should very seldom need to project data!!! You Define the projection when new data is brought into the organization. You use Feature Class to Feature Class to load it into a Geodatabase Feature Data Set --it is automatically reprojected (if necessary) as it is loaded 9.5 Documenting and Printing Model and Accessing Processing Information To add free-floating text (title, notes, etc.) to the ModelBuilder window: --right-click on any empty section of the Modelbuilder Window and select Create Label --double click the label and edit as desired --move label to desired location --the label stays in same position (approximately!) when you re-arrange model elements 6 --right-click on any element (box) in the ModelBuilder window and select Create Label --double click the label and edit as desired (use ctrl-Enter for new line) --move label to desired location relative to the box (above, below, side, etc.) --note the grey line linking label to box as you move the label --the label stays in same position relative to box when you move the box To print the model diagram, sgo to Model>Print (p 322-326) --Use Model>Diagram Properties to customize its appearance, if desired (see p. 304-315) To view processing information for a single process: --right-click on the process (square box) and select View Messages --however, the formatting is much better if you view all, as below. To view all the processing information, go to Model>Report (p 327-328) --check the View report in a window button and click OK --click the Expand/Collapse All link in the upper right --full documentation on the model and its processing is displayed --right click somewhere in this window for Print and other options To export this processing information so that it can be used in other applications (e.g. a report) --close the Report window (if it’s open), and again go to Model>Report --check the Save Report to a File button, enter an appropriate file name, and click OK --the file is saved as an .xml file --you can open the file in any .xml complaint software (e.g. Internet Explorer) 9.6 Exporting the model as a Script (p. 333-334) --go to Model>Export>To script and select the desired language Python, Jscript, or VBScript --you can then build more sophisticated processing control than available in the graphic window --it’s also an excellent way to start learning how to write scripts 10. Setting Environment Settings (p. 177-219) Basically, these are defaults that you can set and thus: --avoid repeated information input or option selection --ensure consistency in processing the data (multiple entry leads to errors!) Environmental Settings apply to a tool (or a process, since a tool runs a process). However, they can be set at three hierarchical levels: -- the Application Level (apply to all Geoprocessing that you do) --at the Model Level (apply to all processes run in a given model, and override Application settings) --at the Process level (for a particular time that you run a process, and override Model settings) Settings applied at lower levels (e.g. the Process level) override settings at higher level (e.g. Model level), so it’s a good idea to set at the higher (e.g. application level) then override as needed when you do specific things. Note: I have had trouble getting these to work correctly!!! To establish settings at the Application Level: On ArcCatalog Main menu, go to Tools>Options, click Geoprocessing tab click Environments button --click on to see and set the settings under any one category, For example, select General Settings In Current Workspace, navigate to C:\Documents and Settings\your_id\ My Documents This will “fill in” this location as the base folder whenever a file reference is needed. You could also set Output Coordinate System to State Plane TX North Central Zone. --then all data sets created would default to this projection --to do this, change Same as Input to As Specified Below (click down arrow) --then select the projection system To establish settings at the Model level (overriding the Application level): On the Model main menu, go to Model>Model Properties Click the Environments tab Click expansion for settings you want to override (e.g. General Settings) Check box for setting you want override (or set, if not already done at Application level) 7 (e.g Current Workspace) then click Values button Click on General Settings, Click the down arrow in Current Workspace box and select avcat Click OK, then click OK again to close properties box --this folder will be the default source/destination for files in this model --since this is your model, you can be as explicit as you like Note: Generally, it is important for Models to set the Output Coordinate System to a desired reference system otherwise you run the risk of having data in the model with inconsistent projections systems, thus potentially generating invalid results. (See # 11 below) To establish settings at the Process level (overriding Application and/or Model level): A. For a tool in ArcToolbox, double click the tool you want to run e.g. go to ArcToolbox>Analysis Tools>Extract> and double click Select tool Click the Environments button at lower right. You receive the same dialog box as with Application level. Set as desired. For example, you could change the settings to output data in lat/long coordinates go to General Settings and modify the two Output Coordinate System lines --click down arrow to change Same as Input to As Specified Below --click and Select Predefined>Geographic>North America>North American Datum 1983 Click Add button, then OK buttons until you return to the Select dialog Use daycare.shp from c:\ as input--but be sure that the main model above has run other wise its initial projection will not be defined and it will fail. Select just daycares with ZIP = , or do nothing and it will select all. After running the process, Preview the output data in ArcCatlog. It should be in lat/long. B. For a process in a model, right click the process box, select Properties, click Environments tab For example, drag the Select tool into the Model Builder window and go to Environments tab You receive the same dialog box as with Application level. Set as desired. e.g. set the output coordinate system to lat/long as we did when running the tool Use the the link tool to connect the Select process to daycares Run the model, then Preview the output (daycares_Select.shp) in ArcCatalog 11. Coordinate System Management in ModelBuilder When you process data in ArcMap, all data in the data display window is automatically projected (providing its projection is defined) to the same projection as the data frame into which it is brought (See Arcmap1.doc for exact details). Consequently, you are less likely to encounter problems with inconsistent projections. When you bring data into Modelbuilder, it may be in any coordinate system (datum & projection). Consequently you need to adopt some strategy to ensure consistent coordinate systems. For example -ensure all data is in the same coordinate system before it is brought into Modelbuilder (for example, re-project shapefiles as needed) --store all data in a Geodatabase Feature Dataset, either as a part of the model or external to it --use Output Coordinate System setting in Environmental Settings to create consistency Ex_2: Exercise for ArcToolbox and Modelbuilder Use ModelBuilder to replicate the processing requested in Exercise 1 for ArcCatalog (ex1_arccat.doc) For help, refer to Geoprocessing in ArcGIS available at P:\ArcGIS_9-Help\ESRI_Library_9\ArcGIS_Desktop --other topics which you might want to explore which are not covered in the demo include: 1. Use of “variables” pp. 270-283 3. Dealing with no data pp. 268-269, 284-288 4. Branching and process control pp. 289-296 --there are substantial enhancements to Modelbuilder in 9.2, see P:\briggs\g6382\Info_materials\Whats_New_In Arctoolbox.pdf which is extracted from P:\ArcGIS_9-Help\ESRI_Library_9\ArcGIS_Desktop\ Whats_New_In_ArcGIS_92.pdf 8