5
Using ModelBuilder to Create Feature Classes Models are workflows that can be created in ArcGIS to automate geoprocessing tasks, and can be saved to ArcToolbox and executed as necessary. Models are created in ArcGIS Desktop 10 using the ModelBuilder window. The procedure below outlines the steps necessary to create a simple model, save the model to a new toolbox, and execute the model to perform basic geoprocessing tasks. Step 1 Set up your workspace Open ArcMap (Program menu > ArcGIS > ArcMap) and create a new, blank map. Launch the ArcCatalog window using the ArcCatalog button ( ) on the main menu. Each map document has a property called a default geodatabase, which is the location where outputs from tools and models are stored. This property generally defaults to a user's My Documents folder, but it can be changed to any drive and/or directory you may wish to use. It is recommended that you set up a default geodatabase for your model. This is especially useful when running an iterative model with many outputs. The default geodatabase will keep your outputs organized, and having this default path set means you will not have to change each output individually within the tool parameters. In the ArcCatalog window, browse to the workspace where you wish to save your data. If you cannot see your drive or folder in the Catalog tree, use the Connect to Folder button ( ) to establish a connection with your workspace. Right-click the folder and select New > File Geodatabase. Enter a descriptive name and click OK. Right-click the new geodatabase and select Make Default Geodatabase. Save your map (File > Save). Step 2 Add Tools and Parameters Launch ArcToolbox ( ) and ModelBuilder ( ) from the main menu. The Model window will open to a new, blank screen. In this example we will build a workflow to create point feature classes from coordinate values stored in a Microsoft Access database. This process will be an iterative process – meaning we will structure the model to repeat the process for each table stored in the database. In ArcToolbox, browse to the first tool you wish to add to the model. In this case we are adding the Make XY Event Layer tool located in the Data Management Tools > Layers and Table Views toolbox. Click and hold the mouse button to drag the tool to the Model window. The tool appears as a white rectangle connected to its output, as shown in Figure 1 below. Maps, Data and Government Information Centre (MaDGIC) Trent University Library Rev 04/2012 Software: ArcGIS 10 1

Using ModelBuilder to Create Feature Classes · Using ModelBuilder to Create Feature Classes Models are workflows that can be created in ArcGIS to automate geoprocessing tasks, and

Embed Size (px)

Citation preview

Page 1: Using ModelBuilder to Create Feature Classes · Using ModelBuilder to Create Feature Classes Models are workflows that can be created in ArcGIS to automate geoprocessing tasks, and

Using ModelBuilder to Create Feature Classes

Models are workflows that can be created in ArcGIS to automate geoprocessing tasks, and can be saved to ArcToolbox and executed as necessary. Models are created in ArcGIS Desktop 10 using the ModelBuilder window.

The procedure below outlines the steps necessary to create a simple model, save the model to a new toolbox, and execute the model to perform basic geoprocessing tasks.

Step 1 Set up your workspace

Open ArcMap (Program menu > ArcGIS > ArcMap) and create a new, blank map.

Launch the ArcCatalog window using the ArcCatalog button ( ) on the main menu.

Each map document has a property called a default geodatabase, which is the location where outputs from tools and models are stored. This property generally defaults to a user's My Documents folder, but it can be changed to any drive and/or directory you may wish to use.

It is recommended that you set up a default geodatabase for your model. This is especially useful when running an iterative model with many outputs. The default geodatabase will keep your outputs organized, and having this default path set means you will not have to change each output individually within the tool parameters.

In the ArcCatalog window, browse to the workspace where you wish to save your data. If you cannot see your drive or folder in the Catalog tree, use the Connect to Folder button ( ) to establish a connection with your workspace.

Right-click the folder and select New > File Geodatabase. Enter a descriptive name and click OK. Right-click the new geodatabase and select Make Default Geodatabase.

Save your map (File > Save).

Step 2 Add Tools and Parameters

Launch ArcToolbox ( ) and ModelBuilder ( ) from the main menu. The Model window will open to a new, blank screen.

In this example we will build a workflow to create point feature classes from coordinate values stored in a Microsoft Access database. This process will be an iterative process – meaning we will structure the model to repeat the process for each table stored in the database.

In ArcToolbox, browse to the first tool you wish to add to the model. In this case we are adding the Make XY Event Layer tool located in the Data Management Tools > Layers and Table Views toolbox. Click and hold the mouse button to drag the tool to the Model window. The tool appears as a white rectangle connected to its output, as shown in Figure 1 below.

Maps, Data and Government Information Centre (MaDGIC) Trent University Library Rev 04/2012 Software: ArcGIS 10 1

Page 2: Using ModelBuilder to Create Feature Classes · Using ModelBuilder to Create Feature Classes Models are workflows that can be created in ArcGIS to automate geoprocessing tasks, and

Notes about colours: ModelBuilder uses colours to indicate the status of tools and variables. A white shape indicates that all of the tool parameters have not been filled in. This might mean that the model is unfinished, or it could mean that the user who eventually runs the model will be entering the tool parameters at that time. Once the parameters have been entered, the tool will change to yellow, inputs will display as blue, and outputs as green.

Double-click the tool in the Model window to view its parameters.

In the XY Table field, browse to the location of your inputs. In this case, our tables are stored in a Microsoft Access database, so we will browse to that location and select the first table in the list (L0403) as our input. You can also have your tables stored as text files within a folder. In this case you would browse to the folder containing your files and select the first file in the list.

The X Field and Y Field are inputs for longitude and latitude, respectively. The software will attempt to guess at which fields in the input table contain this information. Verify that the correct fields have been entered. If there is an error, use the drop down arrows to change the fields accordingly.

The Layer Name or Table View provides the name of the output layer.

The Spatial Reference indicates the geographic or projected coordinate system that should be applied to your data.

Figure 2 - Tool parameters for the Make XY Event Layer tool

Enter the parameters that apply to your data set and click OK. The Model window will now display the tool and its input and output in colour, as shown in Figure 3.

Figure 3 – Make XY Event layer model with parameters filled

Maps, Data and Government Information Centre (MaDGIC) Trent University Library Rev 04/2012 Software: ArcGIS 10 2

Page 3: Using ModelBuilder to Create Feature Classes · Using ModelBuilder to Create Feature Classes Models are workflows that can be created in ArcGIS to automate geoprocessing tasks, and

Step 3 Create an iterative list

As mentioned previously, this model will be an iterative workflow – this means that the entire process will be executed for each input table stored in the database or directory you have identified. There are several methods of iteration available in ArcGIS – for more information visit ArcGIS Desktop Help and search for the topic ModelBuilder. In this example we will be using the list method of iteration.

To set the tool's input as a list, right-click the input (the blue oval) and select Properties. View the General tab and ensure that the option 'A list of values' is checked as shown below. Click OK.

Double-click the input to open the batch processing grid. This grid displays an entry for each list item to be processed by the model. Initially you will only see the first input entered in step 2. Double-click the row number to view its properties.

Click the + sign to add another item to the list. If necessary, browse to the location of your input tables and select the second one in the list. Repeat this step for each table you wish to process. The figure below displays the batch processing grid with two entries, which means the output from this model will be two XY event layers.

Maps, Data and Government Information Centre (MaDGIC) Trent University Library Rev 04/2012 Software: ArcGIS 10 3

Page 4: Using ModelBuilder to Create Feature Classes · Using ModelBuilder to Create Feature Classes Models are workflows that can be created in ArcGIS to automate geoprocessing tasks, and

Step 4 Build the model

The first process in our model is now complete. We will continue to build our model using the output from the first step as the input for our second step. Our goal in this model is to create a point shapefile from the input tables stored in our database. Now that we have an XY event layer, we can use the Copy Features tool to create a feature class that will display the point data from our table.

Repeat the steps to add the Copy Features tool to the Model window. The Copy Features tool is located in the Data Management Tools > Features toolbox.

Double-click the tool to view its parameters. Click the drop-down arrow beside the Input Features text box and select the output from the previous process as your input. The output will display with an iterative list icon if it is a list, or a layer icon if it is a single layer.

Ensure that the output feature class is set to the appropriate workspace and that your output has a descriptive name. Accept all other defaults and click OK. Your model will now appear as shown in the figure below.

Model showing two complete processes

Once you have chosen the list of XY event layers as your input, the iterative list is carried through to the next process. Double-click the Copy Features tool again to view the batch processing grid. In some cases, the output name of subsequent entries will default to the same output name as the first table in the list. Ensure that each entry has a unique, descriptive name so that you can identify the data later on.

This model is now set to receive a list of input tables from a database, create an XY event layer from the coordinate values within each table, and then copy the features to a feature class.

Step 5 Create Model Parameters

Model parameters are shown when you open the tool dialog of the model from ArcToolbox or ArcCatalog. If you set a variable as a parameter and then save and close the model then, the next time the model is opened, the user will be prompted to select an input for that parameter. If the input is not set as a parameter, then the model will process the same data each time.

In this model, we want the user to be able to select the input tables to be processed. To create the parameter, right-click on the first input in the model (the input table) and select Model Parameter. A 'P' will appear beside the input in the Model window as shown below.

Maps, Data and Government Information Centre (MaDGIC) Trent University Library Rev 04/2012 Software: ArcGIS 10 4

Page 5: Using ModelBuilder to Create Feature Classes · Using ModelBuilder to Create Feature Classes Models are workflows that can be created in ArcGIS to automate geoprocessing tasks, and

Step 6 Validate and Save the Model

Use the Validate Model button ( ) to check for errors.

Assuming that no errors are found, you can now save the model for future use. It is important to save to a directory to which you have write access. If the model is saved to a location where you do not have write access then it will be inaccessible for future use.

Click the Save icon, or navigate to Model > Save in the Model window.

If necessary, navigate to the My Toolboxes folder and click the New Toolbox icon ( ).

Name the toolbox and then double-click to open it in the Save dialog. Give the model a descriptive name and click Save. The model is now available for use in the My Toolboxes folder.

Note: More information about models and ModelBuilder is available here.

Maps, Data and Government Information Centre (MaDGIC) Trent University Library Rev 04/2012 Software: ArcGIS 10 5