Lesson 7 | Automate the analysis |
SUPPOSE UNEXPECTED CHANGES occur after you’ve finished the analysis. Maybe an updated table of vacant parcels becomes available. Maybe after seeing the results, the city council wants to add or remove criteria or see how a change in threshold values affects the outcome. Of course, you could redo the analysis, but even a small change—especially if it comes at the beginning of the process—could make a lot of tedious work. This is the moment to introduce ModelBuilder™. ModelBuilder can encapsulate your entire workflow in a model—a custom geoprocessing tool that runs with the push of a button.
A model looks like a flowchart or schematic diagram that shows the steps for manufacturing a product. Inputs, outputs, and processes are represented by geometrical shapes. Arrows connect the shapes to show the sequence of operations. For an example, see the sidebar “Understanding a model.”
A model is more than a visual aid; it’s also an engine. The datasets and tools it represents are embedded in the model’s schematic elements, so that running a model sets in motion a chain of geoprocessing operations. In this case, the model will basically repeat the analysis tasks you did in lesson 6.
There are many good reasons to build a model from your analysis. First, since it is a diagram, a model makes the whole workflow transparent and open to scrutiny. This visualization may reveal the analysis’s weaknesses or confirm its validity—either way, it brings the methodology into the open. Second, a model stores, and thereby documents, the workflow, sparing you the task of keeping detailed notes on what you did and why. Third, models are flexible. They easily accommodate the kinds of changes to inputs or parameters mentioned previously with little effort on your part. Fourth, models can be shared with colleagues, saving development work and encouraging collaboration on sound methods and best practices. Fifth, models run quickly—just wait and see.
Exercise 7a: Set up the model
Create an output geodatabase, and set your workspaces
As in lesson 6, you’ll create a new geodatabase to hold your output data. You’ll keep the results in a separate geodatabase simply to avoid confusion between the outputs that were created in lesson 6.
1)Start ArcGIS Pro, and open the LARiverParkSite project.
2)Insert a new map, and name it Lesson7. Close any other maps you may have open.
3)In the Catalog pane, right-click Databases, and click New File Geodatabase. A dialog box will open to save the new geodatabase.
4)Name the new geodatabase ModelOutputs, and click Save.
5)On the Analysis tab, in the Geoprocessing group, click the Environments button.
6)To set the current workspace, click the browse button next to the Current Workspace box, and browse to your new ModelOutputs geodatabase.
7)Set Scratch Workspace to ModelOutputs as well.
8)Compare to the figure, and click OK on the Environments dialog box.
As a reminder, these “environment settings” set the default output location for geoprocessing tools. You can always change the output location for any individual tool, but setting these default workspaces is convenient when trying to keep your outputs in the same geodatabase.
Create a model in the project toolbox
A toolbox is a container of tools. A model is a type of tool (just like Buffer, Identity, and the other tools you’ve worked with) and, as such, must go in a toolbox. However, it can’t go in a system toolbox (like the Analysis toolbox you worked with in lesson 6). An ArcGIS Pro project automatically contains a project toolbox, so when you created the ArcGIS Pro project in lesson 1, the project toolbox was created for you.
1)In the Catalog pane, expand Toolboxes. Here you’ll find a toolbox with the same name as your project.
2)Expand the toolbox, and notice that it is empty.
3)Right-click the project toolbox, and click New > Model.
An empty Model window opens, usually replacing the map view. If it doesn’t open to replace the map view, drag the Model tab to the center of the map, and dock it. You can always return to the map by clicking the map tab at the top of the pane.
Also note that a new tool named Model is in your toolbox, and it has a model icon next to it signifying that the type of tool is a model. Models are a special kind of tool, but you’ll see that, once completed, they can behave like any other tool in the toolbox.
Understanding a model
To get the basic idea, forget about the LA River for a moment and prepare a Saturday morning breakfast. Here is a recipe (workflow) for making a dozen classic American pancakes from scratch. You should pick up the ingredients at your local store and make a batch to celebrate when you have completed this workbook!
The ingredients are symbolized by blue ellipses (inputs). These are prepared in various ways as shown by the orange rectangles (tools or processes). The results are green ellipses (outputs). You stir the basic ingredients to make the flour mix before adding the whipped egg, oil, and buttermilk. The mix should be properly blended before liquids are added; otherwise, you may get clumps of baking powder in the dough, which will lead to some very flat pancakes. After you make the dough, refrigerate it for several hours (or, even better, overnight) to allow time for chemical reaction. Then fry the dough in a pan with your favorite fat and eat it with a good brand of maple syrup. Delicious!
Can anything go wrong? If you follow the arrows, you’re on a tried-and-true path. If you start improvising, you might make the recipe even better—but you might also get your weekend off to an indigestible start.
It’s much the same with an ArcGIS workflow. With a complex analysis, it usually takes trial and error to get the recipe right. Typically, you’ll experiment with several combinations of data, tools, and sequences before finding the best way to solve your problem. Once you find it, you’ll want to save it and share it with friends, just like the pancake recipe.
We experimented a lot with the data and many ArcGIS tools before writing this cookbook (sorry, workbook). Having figured out the workflow, we implemented it in lesson 6. But we also wanted to preserve it, encapsulate it, and make it a formula—as you’ll see, that’s what ModelBuilder is all about.
Set model properties
You’ll rename the model and supply some information about it.
1)With the empty model displayed, on the ModelBuilder ribbon, click the Properties button . A dialog box opens for some basic information about the model.
2)In the Name text box, type ParkSuitabilityAnalysis (no spaces).
3)In the Label text box, type Park Suitability Analysis (using spaces this time).
The label is like a field alias: a name that’s more descriptive or easier to read that will be used while you’re in ArcGIS Pro.
4)Verify that the box is checked for Store tool with relative path.
The model, its input data, and its output data can now be moved without disruption as long as they remain in the same workspaces (folders or geodatabases) relative to each other.
5)Compare to the figure, and click OK.
Note that the name of the model on the tab above the model canvas has updated, but the model in the Catalog pane hasn’t yet. You must save the model to commit any changes made to it.
6)On the ModelBuilder ribbon, in the Model group, click Save .
In the Catalog pane, the model now appears with its new label.
Exercise 7b: Build the model (part 1)
Your model will re-create the analysis workflow from lesson 6. Knowing how much work that lesson entailed should give you insight into why models are such an efficient tool—not only for analysis projects, but for any series of operations that you might want to save, repeat, vary, or use as a basis for further development. Re-creating the analysis will let you focus your attention on the modeling process itself, since the data and geoprocessing tools will be familiar.
The data preparation tasks from lesson 4 won’t be part of the model. A big advantage of models is that it’s easy to rerun them. You don’t want to incorporate operations such as adding fields, calculating field values, joining tables, and so on, which only need to be done once.
In this exercise, you’ll model about half of the analysis steps, saving the remainder for the next exercise. The stopping point is more or less arbitrary, but building a model incrementally is good practice. It’s easier to find and fix problems if you do test runs along the way.
Add data to ModelBuilder
In this section, you’ll add all the input data for the model. This is the opposite of what you did in lesson 6, in which you added layers one at a time as you needed them. Either way is fine: it’s a matter of preference.
1)In the Catalog pane, expand the project database.
2)Press and hold the Ctrl key, and click these five feature classes:
•BlockCentroids
•BlockGroups
•LARiver
•Parks
•VacantParcels
3)With the feature classes selected, drag them from the Catalog pane to the model (as you would drag them to a map).
Although you can probably see only one or two of them without scrolling, each dataset is added as a blue ellipse to the Model window. (These blue ellipses are “input data variables,” but you’ll mostly just call them inputs.) The elements aren’t automatically sized to fit, so you’ll take care of that next.
4)On the ModelBuilder ribbon, in the View group, click the Fit to Window button .
You should see all five elements arranged in the Model window and marked with gray selection handles.
The display of text within ellipses changes as you zoom in or out in the Model window. The places where words divide may change and so may the number of lines of text. Don’t worry if the text display on your screen is different from the lesson figures.
5)Hover over any selected element. Then drag the whole group to the left side of the Model window.
6)Click in empty white space in the Model window to deselect the elements.
Add a tool to ModelBuilder
The first step of the analysis in lesson 6 was to buffer the LA River. So you can start with that.
1)On the ModelBuilder ribbon, in the Insert group, click the Tools button . The Geoprocessing pane displays the list of toolboxes, which should be familiar from lesson 6.
2)Switch the view to Toolboxes (tab at the top of the pane), and browse to the Buffer tool: Analysis Tools > Proximity > Buffer.
3)Drag the Buffer tool from the Geoprocessing pane, and drop it on the model.
The tool is added to the Model window, connected by a small arrow to an Output Feature Class element. The tool and its output are gray, because they’re not ready to run. The tool must be connected to input data, and its parameters must be filled out.
4)Make sure the Buffer tool and Output Feature Class elements are selected (marked with gray selection handles).
If they’re not selected, using the Select tool in the Mode group, use the mouse to draw a box around these elements to select them.
5)Drag the selected elements down, and place them to the right of the LARiver input data element.
The exact position doesn’t matter.
6)Place the pointer over the blue LARiver input data element until the hand pointer appears.
7)With the hand pointer displayed, drag a line from LARiver to Buffer. The line won’t appear until you start dragging.
8)Release the mouse button to connect the input data element to the tool. A menu is displayed to choose which type of connection to make.
9)In the menu, click Input Features. The tool is now connected to data, but there are other parameters to enter for the Buffer tool, so the tool remains gray.
10)Right-click the Buffer tool, and click Open (alternatively, you can double-click the tool).
The familiar geoprocessing tool opens, but this time it is floating above ModelBuilder instead of being contained in the Geoprocessing pane. The input features are set to LARiver, as specified by the connection arrow, and the output feature class is directed to the default geodatabase. You’ll rename this feature class in accordance with your convention.
11)Change the Output Feature Class name to LARiverBuffer.
The default output path should be set by the workspace environment settings you made earlier. If not, use the browse button to browse to the ModelOutputs geodatabase.
12)For the Distance, type 0.5, and set the Linear Unit to Miles in the drop-down menu.
13)Click OK.
In lesson 6, you clicked Run after entering all the parameters to immediately run the tool; in ModelBuilder, clicking OK verifies that the tool is ready to run but doesn’t actually run the tool (yet). The tool and output data elements turn yellow and green, respectively, which means they are properly connected and the parameters filled out.
14)On the ModelBuilder ribbon, in the Model group, click Save.
Buffer the parks
In lesson 6, after buffering the river, you created quarter-mile buffers around existing parks to designate “exclusion zones” when considering where to site a new park.
1)On the ModelBuilder ribbon, click the Tools button, if the pane isn’t open already.
2)Drag another Buffer tool to the model. All the names of the elements (inputs, outputs, and tools) in the model must be unique, so you’ll notice that the tool will be named Buffer (2) when you drop it on the model.
3)Position the tool to the right of Parks.
Last time, you set the input features in the Buffer tool by drawing a connector. Now you’ll do it another way.
4)Open the new Buffer tool by double-clicking it, or right-click it and click Open.
5)Click the Input Features drop-down arrow, and click Parks.
The drop-down menu is filled with the input data elements in the model (as opposed to the layers in the map that you’ve seen in previous lessons). Every input data element (blue ovals) is technically a variable, because you can open it and change the feature class it references.
6)Change the Output Feature Class name to ParksBuffer.
7)For Distance, type 0.25. Set the Linear unit drop-down arrow to Miles.
8)Click the Dissolve Type drop-down arrow, and click Dissolve all output features into a single feature.
You don’t have the visual reason to dissolve the buffers that you had in lesson 6 (you’re not going to look at this tool’s output, just use it as input for the next step), but it doesn’t cause a problem to duplicate the workflow.
9)Compare your dialog box to the figure, and click OK.
Both buffer processes should now be colored in your model.
10)Save the model by clicking the Save button on the ModelBuilder ribbon.
11)Save your project by clicking the Save button at the top of ArcGIS Pro.
Erase park buffers
Now, as in lesson 6, you’ll use the Erase tool to subtract the park buffers from the LA River buffer to remove them from consideration for the new park location.
1)If necessary, open the Geoprocessing pane by clicking the Tools button on the ModelBuilder ribbon.
2)At the top of the Geoprocessing pane, type Erase into the Search box.
3)Drag Erase (Analysis Tools) to the model.
4)Position the tool next to LARiverBuffer.
You may need to zoom out on the model window to see the newly added tool.
Remember from lesson 6 that the Erase tool requires two input feature classes: (1) the Input Features feature class—the features from which areas will be erased—and (2) the Erase Features feature class—the areas that will be erased (the “cookie cutter”).
5)Connect LARiverBuffer to Erase by drawing a line between them (as you did in steps 6–8 under “Add a tool to ModelBuilder”).
6)Click Input Features when prompted to define LARiverBuffer as this parameter.
7)Connect ParksBuffer to Erase by drawing a line between them.
8)When prompted, click Erase Features.
The Erase elements will now be colored because Erase doesn’t require any other parameters. You will go ahead though and rename the output feature class to give it a more descriptive name and stay consistent with lesson 6.
9)Double-click Output Feature Class (the output of Erase).
10)Change the output name to ProximityZone.
The Erase tool is now ready to go, but you can review all the tool parameters to confirm.
11)Double-click the Erase tool to open it.
Note that the tool parameters have been filled out for you by connecting and changing the individual model elements.
12)Close the dialog box by clicking OK.
Depending on how you’ve positioned your elements, your model may be starting to look a little “messy.” As you add more elements to the model, it will become increasingly cluttered and difficult to find things. You’ll use the Auto Layout tool to clean things up.
13)On the ModelBuilder ribbon, in the View group, click the Auto Layout button .
Much better, right? Your resulting layout may look different from the figure, which is fine.
14)Save both the model and the project.
Assign block group demographics to the proximity zone
After erasing the park buffers in lesson 6, you used the Identity tool to overlay the remaining area of interest with block groups to assign census attributes. You’ll do the same thing now in the model.
1)Open the Geoprocessing pane.
2)At the top of the Geoprocessing pane, type Identity into the Search box.
3)Drag Identity (Analysis Tools) to the model, and drop it next to BlockGroups.
4)Double-click Identity to open it.
5)Use the figure to set the parameters.
6)Click OK.
The Identity tool is now colored in the model.
The name of the output of Identity (ProximityZoneDemographics) is too long to fit in the oval, so it is being cut off. The text displayed on the elements in the model is just labels and can be changed. Although each label defaults to the tool or data it represents, you can change the labels to enhance the display and readability of the model.
7)Right-click the output green oval of the Identity tool, and click Rename.
8)Replace the existing text with Proximity Zone Demographics, and press Enter (or click away from the text).
9)Use the Auto Layout button to lay out the model again.
10)Save the model and your project.
Validate and run the model
This is a good time to test run the model. Before running a model, you should validate it to make sure that all is well with the data variables and tool parameters.
1)On the ModelBuilder ribbon, in the Run group, click the Validate button .
Validation ensures that a model has access to its source data. If you rename, move, or delete a feature class referenced by an input data variable, that variable and its dependent processes will turn gray (not ready) when you validate the model. Similarly, if you delete a field from a table, and that field is specified by a tool’s parameter, the tool and its dependent processes will turn gray when you validate.
If nothing turns gray, your model is ready to run.
The next step is to run the model.
2)On the ModelBuilder ribbon, in the Run group, click the Run button .
As it runs, you should get a visual progress report, with each tool turning red as it is processed. A progress dialog box is also displayed including detailed messages.
3)Close the message box when the model is finished running.
In the Model window, the tools and output data elements have drop shadows. This shadowing tells you which of the tools have finished running and that an output has been created.
Now that the tools have run and the model is complete, you can view the results and add them to your map.
4)In the Catalog pane, browse to the ModelOutputs geodatabase.
5)Refresh the geodatabase by right-clicking it and clicking Refresh.
The geodatabase contains four feature classes. They have the names assigned by the tool parameters in ModelBuilder.
6)Open the Lesson7 map by clicking the tab above the model. The map is currently empty except for the basemap.
7)Drag the ProximityZoneDemographics layer to the map.
8)Open the attribute table of the ProximityZoneDemographics layer. Scroll across to see its attributes.
The table has 206 records and includes the demographic attributes from the BlockGroups feature class. It’s the same result that you got in exercise 6b. Configuring the Identity tool is the last step in your current model, so you can assume the other layers are correct if the Identity output is correct.
9)Remove the ProximityZoneDemographics layer from the Lesson7 map.
10)Switch back to the model by clicking the tab above the map.
11)Save the model and your project.
12)Close the model by closing its tab. Close it even if you’re continuing to the next exercise so you can look at how to edit an existing model.
You’ll finish the model in exercise 7c.
Exercise 7c: Build the model (part 2)
In this exercise, you’ll keep following the lesson 6 workflow and finish the analysis model.
In this exercise, you’ll see how ModelBuilder handles operations on layers. In lesson 6, you used attribute and spatial queries to narrow the number of potential park sites. Queries (and, for that matter, any type of feature or record selections) are not made directly on feature classes, but rather on layers. To make feature selections in ModelBuilder, you therefore need a special tool that turns an input feature class into a layer. This tool is appropriately named Make Feature Layer. When you make layers in ModelBuilder, it’s usually to make a selection that can be used as an input to further processes. For a specialized use of the Make Feature Layer tool in ArcGIS Pro, see the sidebar “Apportioning attribute values” in lesson 6.
Select features by demographic attributes
In lesson 6, you used an attribute query to select features in the proximity zone according to the demographic values you assigned from block groups using the Identity tool. You’ll re-create that query now.
1)If necessary, start ArcGIS Pro, and open the LARiverParkSite project.
2)In the Catalog pane, expand the Toolboxes group and find the Park Suitability Analysis model.
3)Right-click the model, and click Edit. The model reopens for editing.
4)Open the Tools list and search for Make Feature Layer in the list of tools, and then drag it to the model.
The Make Feature Layer tool is similar to Select By Attributes, but instead of selecting and highlighting the features that satisfy an expression, it creates a temporary layer that filters the features. Both tools allow you to define a query to limit the features that are used in subsequent tools. In this example, you’ll use the tool to define the demographic criteria to be used in the next steps.
5)Double-click the tool to open it.
6)Set Input Features to Proximity Zone Demographics.
7)Change the Output Layer name to Good Zones (with a space).
When a tool creates a layer and not a feature class, spaces and special characters can be used in the name.
8)Add the clauses to select features in which all the following conditions are true (as you did in lesson 6):
•Pop Density is Greater Than or Equal to 8500
•And Median HH Income is Less Than or Equal to 50000
•And % Under 18 is Greater Than or Equal to 22
Make Feature Layer also gives you the opportunity to hide unnecessary fields, so you’ll go ahead and remove the extra fields that were added from the buffer steps in exercise 7b.
9)Hide all the fields, except for the following, by clicking to clear their Visible check boxes:
•OBJECTID
•Shape
•MEDHINC_CY
•POPDENSITY
•PCTUNDER18 (be careful not to check POPUNDER18)
These fields are the only ones you need for your analysis, so by hiding the others at this point, they’ll be excluded from future analysis in the model.
10)Compare to the figure, and click OK.
11)Use the Auto Layout button to lay out the model again.
The ModelBuilder ribbon has several navigation tools in the View and Mode groups for panning and zooming in and out of your model.
You can also use the scroll wheel as well as the horizontal and vertical scroll bars to navigate the model.
12)Save the model and your project.
Select parcels within good zones
The attribute query for desirable demographics significantly narrows down the “good zones” in which you can look for vacant parcels. You now have the ModelBuilder equivalent of a layer with a definition expression set, bringing you to the point in the analysis where you were at the end of exercise 6b. The next thing to do is make a spatial query for vacant parcels that lie within the good zones.
1)Search for the Make Feature Layer, and drag it to the model next to the VacantParcels element.
2)Use the mouse to draw a line from VacantParcels to Make Feature Layer (2) and set it as the Input Features parameter.
3)Open the Make Feature Layer (2) tool.
In lesson 6, you did a Select By Location query for vacant parcels in good zones, followed by an attribute query for parcels a quarter acre or larger. You’re going to now switch the order of these two query operations by adding the attribute expression to the Make Feature Layer tool, but it doesn’t affect the logic. It doesn’t matter whether you first select the vacant parcels in good zones and then select the quarter-acre ones (lesson 6) or first select all the quarter-acre vacant parcels and then select the ones in good zones (as you’ll do here).
4)Change the Output Layer name to Suitable Size Vacant Parcels.
5)Add a clause for the following:
Acres is Greater Than or Equal to 0.25.
6)Compare your tool to the figure, and click OK.
7)Search for the Select Layer By Location tool, and drag it to the model next to Suitable Size Vacant Parcels.
8)Open the Select Layer By Location tool, and use the figure to complete the parameters to select the vacant parcels that are completely within the Good Zones. Click OK.
9)Click the Auto Layout button.
10)Rename the last output data element Good Zone Parcel Layer.
Note that the last output that actually creates a feature class in the geodatabase is Proximity Zone Demographics. The subsequent outputs consist of two layers created by the Make Feature Layer tools and a selection on those layers.
11)Hover over the Proximity Zone Demographics element.
The ToolTip shows the path to the dataset on disk.
12)Hover over each of the downstream outputs in turn.
These ToolTips show only the name of the layer, because that’s all there is to see—no datasets have been created on disk. There are four output elements, but only two layers: Good Zones, created by Make Feature Layer, and Suitable Size Vacant Parcels, created by Make Feature Layer (2). Good Zone Parcel Layer is a spatial selection of Vacant Parcels. You renamed the output elements of the selection tools for clarity (hopefully), but you didn’t have to.
Copy features
Just as in lesson 6, you’ll use the Copy Features tool to save the selected Good Zone Parcels as a new feature class in the geodatabase.
1)Search for Copy Features in the Tools list, and drag the tool to the model.
2)Use the mouse to draw a line from Good Zone Parcel Layer to the Copy Features tool, and set it as the Input Features parameter.
3)Open the tool, and change the default Output Feature Class name to GoodZoneParcels.
4)Compare your dialog box to the figure, and click OK.
5)Click the Auto Layout button.
6)Save the model and your project.
This feature class contains your recommended sites, but you’ll add a little more information about the sites to be included in the final output.
Determine the distance of each site to the river
You know that each site is within a half mile of the river, but just as in lesson 6, you’ll use the Near tool to get a precise distance to help the decision-makers on the city council weigh their options.
1)Search for the Near tool, and drag it to the model close to GoodZoneParcels.
2)Open the Near tool, and use the drop-down menu to set Input Features to GoodZoneParcels.
3)Set the Near Features parameter to LARiver.
As a reminder, there is no output feature class when using the Near tool, because it simply adds fields to the input feature class.
4)Change the Method parameter to Geodesic.
5)Compare the dialog box to the figure, and click OK.
6)Click the Auto Layout button.
7)Rename the last output element Good Zone Parcels with River Distance.
Determine park access population
Park access is defined as the population within a quarter mile of the site. You made this calculation using the Spatial Join tool with a “within a distance” operator and a “merge rule” in lesson 6.
1)In the list of tools, search for Spatial Join, and drag the tool to the model next to Good Zone Parcels with River Distance.
2)Open the tool, and set Target Features to Good Zone Parcels with River Distance.
3)Set Join Features to BlockCentroids.
4)Change the Output Feature Class name to SitesAccess. This will be your final output of the model.
You’ll delete unnecessary fields from the output attribute table. Make sure to delete carefully so that your mouse clicks don’t get ahead of you.
5)In the list of output fields, click the first field in the list (it should be Shape_Length) to select it.
6)Click the Remove button to the right of the field name to remove the field from the list (and therefore from the output of the tool).
7)Go on to remove all the fields except ACRES, NEAR_DIST, and POP2010.
If you accidentally delete one of these fields, you can click the Reset button
in the upper-right corner of the table.
8)In the list of output fields, click NEAR_DIST and then the Properties tab (under the Reset button).
9)Change the Field Name to RiverDistance. Confirm that the alias changed to RiverDistance.
10)Click POP2010, and on the Properties tab, change the Field Name to AccessPopulation. Confirm that the alias changed to AccessPopulation.
11)With AccessPopulation still selected in the Output Fields list, click the Source tab (left of the Properties tab), and then click Sum in the Merge Rule drop-down menu.
The Match Option defines the spatial relationship to be evaluated. You must evaluate the block centroids within a quarter mile of the sites.
12)Change Match Option to Within a distance.
13)Set the search radius to 0.25 miles.
14)Compare your tool to the figure, and click OK.
This setup essentially means that the POP2010 values of all the BlockCentroids points within a quarter mile of each site will be summed and included in the output in the POP2010 field.
15)Rename the output element of the Spatial Join tool from SitesAccess to Sites With Access Population.
16)Click the Auto Layout button.
17)Save the model and your project.
Attach the demographic attributes
You’re nearly done with the model. Now you’ll overlay the sites with the block groups to get the demographic attributes you need. You already know that these sites meet the demographic criteria, but adding the individual numbers for each site will help decision-makers evaluate the sites at a glance.
1)In the list of tools, search for Identity, and drag the tool to the model next to Sites With Access Population.
2)Use the mouse to draw a line from Sites With Access Population to connect it to the tool as the Input Features parameter.
3)Use the mouse to draw a line from the Good Zones layer to connect it to the tool as the Identity Features parameter. The Good Zones layer is a great input, because it already has all the unnecessary attributes hidden for you. This feature will save you some cleanup steps.
4)Open the new Identity tool, and change the Output Feature Class name to RecommendedSites.
5)Change the Attributes To Join to All attributes except feature IDs.
6)Click to clear the Keep relationships check box.
7)Compare your tool to the figure, and click OK.
8)Rename the RecommendedSites element at the end of the model to Output Recommended Sites.
9)Click the Auto Layout button.
Run the model
You’re ready to run the model.
1)On the ModelBuilder ribbon, click the Run button.
2)When the model is finished running, close the message box. All the elements should now be displayed with gray drop shadows.
If the model did not finish running successfully for any reason, look for the first tool without a drop shadow—this is your problem area to fix.
View the results
1)Open the Lesson7 map by clicking the tab above the model (or from the Catalog pane if it’s not open as a tab).
2)In the Catalog pane, expand the ModelOutputs geodatabase, and drag RecommendedSites to the map. Just as in lesson 6, the sites will be difficult to see at this scale.
If you don’t see all the outputs, refresh the geodatabase by right-clicking it and clicking Refresh.
3)Open the RecommendedSites attribute table.
You should have the same six sites with the same Acres, river distance, and access populations that you got in lesson 6. You also ended up with two unnecessary fields as a result of the spatial join, but you’ll leave those for now.
4)Save the project.
5)If you are continuing to the next exercise, leave ArcGIS Pro open; otherwise, close ArcGIS Pro.
Exercise 7d: Run the model as a tool
In this exercise, you’ll set up the model as a geoprocessing tool. This is an efficient way to run a model, and it’s a good way to share the model with people who may want to use it but are not so interested in the details of its construction. When you run a model as a tool, it has a dialog box interface like any other geoprocessing tool: the user sets parameters and clicks Run. Behind the scenes, of course, the model is a long chain of tools, each of which has its own required and optional parameters. If all these parameters had to be set by the user in the model’s dialog box, it would be a long process.
Fortunately, that’s not how it works. When you set up the model to run as a tool, you specify which parameters from which tools inside the model will be displayed in the model dialog box. Only these parameters are filled out by the user (you can supply default values). All others are preset by you, and the user running the tool never sees them. In other words, you decide how flexible to make the tool.
The ability to test sensitivity to changes in variables and to explore alternative outcomes are key reasons for building models in the first place. Accordingly, when you set up the model to run as a tool, you should think about which factors the user is most likely to want to experiment with.
Open the model
In previous exercises, you’ve edited the model by right-clicking it. To run the model as a geoprocessing tool, you open it.
1)If necessary, start ArcGIS Pro, and open the LARiverParkSite project.
2)In the Catalog pane, expand Toolboxes if necessary, and double-click Park Suitability Analysis.
The model opens as a geoprocessing tool similar to all the other tools you’ve been using in this book. It’s just an empty, gray dialog box with the message, “No Parameters.” That’s because you haven’t configured which parameters you want to show here yet. The Run button is displayed, however, and you can run it directly from here; it will use all the model parameters you configured in the previous exercises.
3)Close the Geoprocessing pane.
4)Return to the Park Suitability Analysis window from the previous exercise. If it was closed, open the model in the Catalog pane by right-clicking the model and clicking Edit.
5)In the Model window, zoom in on the left side of the model and set your view scale to a comfortable level.
Make a tool parameter for buffer size
Users of the model tool will probably want to experiment with the buffer sizes for maximum distance from the river (half mile) and minimum distance from existing parks (quarter mile). To display these distances as parameters when you run the model as a tool, you must first define them as variables. This configuration allows their values to be changed any time the model is run. Then you flag the variables as “parameters” (parameters you want to include in the model’s tool dialog box).
1)In the Model window, right-click the Buffer tool connected to the LARiver input, and click Create Variable > From Parameter > Distance [value or field].
This setting says that you want the Distance parameter in the Buffer tool to be a variable in ModelBuilder. A small, light-blue ellipse, called a value variable, is added to the Model window.
2)Move the variable a bit, so it’s not overlapping any other elements.
3)Double-click the variable to open its dialog box.
Within the Model window, the Distance parameter is now detached from the Buffer tool and can only be set here. You’ll accept the current value of a half mile that you set earlier, in exercise 7b, as the default for the model tool.
4)Close the Distance dialog box by clicking OK or clicking the X in the upper-right corner.
5)Right-click the value variable, and click Parameter.
The letter P (for parameter) appears above the variable.
The variable name (in the oval) is important for tool parameters. This name will appear as the label for the parameter on the tool. You don’t really want the label to ask for “Distance [value or field].” A more descriptive name would be “Distance to LA River.”
6)Rename the Distance [value or field] variable Distance to LA River.
You’ll make a parameter for the Parks buffer distance in the same way.
7)Right-click the Buffer (2) tool connected to the Parks input, and click Create Variable > From Parameter > Distance [value or field].
8)Move it so it doesn’t overlap other elements.
9)Right-click the variable, and click Parameter.
10)Rename the variable Distance from Parks.
11)Save the model and your project.
12)In the Catalog pane, in the project toolbox, double-click the Park Suitability Analysis model again, and look at the resulting tool dialog box.
Note that the two buffer distance parameters have been added to the dialog box, along with the variable names and default values. These distances can now be changed and the model run, but you’ll wait and create a few more parameters first.
13)Close the Geoprocessing pane.
Make parameters for demographics and park size
You’ll make tool parameters from the query expressions for demographics and park size so you can experiment with these parameters, too.
1)Right-click the Make Feature Layer tool that comes from Proximity Zone Demographics, and click Create Variable > From Parameter > Expression.
A value variable with the name Expression is added to the Model window.
2)Move the new variable to a good spot.
3)Rename the variable Demographic Criteria.
4)Flag this variable as a parameter.
5)Right-click the Make Feature Layer (2) tool connected to the Vacant Parcels input, and click Create Variable > From Parameter > Expression.
6)Move the new variable to a good spot.
7)Hover over the element to see its expression (ACRES >= 0.25). This tip is displayed as a SQL statement (which is how the clauses you created are ultimately evaluated by ArcGIS Pro).
8)Rename the variable Park Size in Acres.
9)Flag the variable as a model parameter.
10)Scroll to the right, if necessary, to right-click the Spatial Join tool connected to the BlockCentroids input, and click Create Variable > From Parameter > Search Radius.
11)Move the new variable to a good spot.
12)Rename the variable Park Access Distance.
13)Flag the variable as a parameter.
14)Use the Auto Layout button to clean up the model layout.
15)Click the Validate Entire Model button .
16)Save the model and your project.
At this point, you are done creating the model and can run it as a tool. When models are configured properly with parameters, they run just like any of the other tools in the toolbox (such as Buffer, Clip, Spatial Join, and so on). The user of the tool simply provides a few parameters to run it and never has to open up the model or even really understand how it works. You’ve now configured the model with enough parameters to run it quickly and easily as a tool. You will also add a few more parameters to give users even more control over how to run the analysis.
Run the tool
Now you’ll rerun the model as a tool.
1)Switch to the Lesson7 map tab (or open the Lesson7 map, if necessary) so that it is displayed.
2)In the Catalog pane, double-click the Park Suitability Analysis tool in your project toolbox.
The tool displays the parameters you’ve specified.
3)Click the Run button to run the tool with the default parameters that you set in the model.
A progress bar and status messages are displayed at the bottom of the Geoprocessing pane.
4)When the tool is finished running, expand and refresh the ModelOutputs geodatabase.
Note that the only feature class in the geodatabase now is RecommendedSites. This is because ArcGIS Pro assumes that the only outputs to be saved are either
•the very last output in a chain or
•outputs flagged as parameters.
All the other datasets created during the execution of the tool are considered “intermediate” and are deleted after the tool runs successfully. Therefore, any output datasets created by your model that might be useful should be flagged as a parameter.
In your model’s current state, you probably want to keep the LARiverBuffer feature class, so you’ll make that a parameter in a later step in this exercise.
5)Open the Park Suitability Analysis tool, and double the acceptable distance to the river by changing the Distance to LA River parameter to 1.
To open the tool, as opposed to the model of the same name, double-click the tool in the Catalog pane.
6)Run the tool again.
7)When the tool is finished running, remove the RecommendedSites layer from the Lesson7 map, and add it again from the ModelOutputs geodatabase.
8)Open the RecommendedSites attribute table.
By doubling the distance from the river that you consider acceptable for a new park, you now have 27 recommended parks instead of your original six. Now imagine making this same minor modification to the step-by-step analysis you did in lesson 6—this relatively minor change would have taken a long time to do and would leave several opportunities for other mistakes to creep up in the process.
Running the tool versus running the model
Running a model (from the ModelBuilder ribbon) runs all the processes using the default values. Running the tool (from the Catalog pane) runs things using the values you enter into the parameter boxes. Most models are ultimately meant to be run as tools by users, who will probably never actually open the model to see how it works.
Make tool parameters for the outputs
Flagging the outputs of the model as tool parameters will allow you to keep the outputs after the process tool runs and add the results as layers to your map. More importantly, it will give you control over where to save your outputs and whether they should overwrite each other. As you experiment with different values in successive runs of the model, you may want to save your results with different names so you can compare them.
1)Switch to the model view of Park Suitability Analysis (go to the tab if it is still open, or right-click the model in the Catalog pane, and click Edit).
2)In the Model window, right-click the LARiverBuffer output data element, and click Parameter.
You don’t have to create a variable first as you did with the other parameters because data elements are variables by definition.
Because you’re now using this element as a parameter, you can give it a cleaner label so it looks more polished in the tool dialog box.
3)Rename LARiverBuffer as Output River Buffer.
4)Scroll to the far right of the model, and set Output Recommended Sites as a parameter.
5)Validate the model, and then save the model and your project.
6)Close the model view by closing the Park Suitability Analysis tab.
Run the tool using different values
Now you’ll run the model using some different parameter values.
1)Open the Lesson7 map, if it’s not open already.
2)In the Catalog pane, double-click the Park Suitability Analysis tool in your project toolbox. The tool appears with all the parameters you set in the model.
3)Run the tool with all the default parameter values. Note that the output data that you configured as parameters is now being added to the map as layers.
Now you’ll run the tool again using different values and save the resulting feature classes with different names.
4)Change the Distance to LA River value to 1 (miles).
5)Edit the Park Size in Acres clause to Acres is Greater Than or Equal to 0.5.
6)Append the text _OneMile, beginning with an underscore (for example, LARiverBuffer_OneMile), to the end of the two output feature class names.
7)Compare your tool to the figure, and click Run.
8)Close the Geoprocessing pane when the tool is finished running.
The two new layers are added to the Lesson7 map. You should now see the one mile and larger park results (_OneMile) displayed on top of the original results you created.
9)Turn the _OneMile results on and off to compare with the original results. There are 11 sites that match the new criteria. (Potential park sites must be larger but can be farther away from the river.)
Open the attribute table of RecommendedSites_OneMile to see the 11 new sites.
10)In the Catalog pane, expand ModelOutputs.
The geodatabase should contain four feature classes: two from this run of the model and two from the previous run.
11)Experiment with your tool by adjusting the other parameter values.
12)Close the Lesson7 map and any open tables or tools.
13)Save and close your project.
You’ve now seen two ways to carry out an analysis project: as a series of stand-alone geoprocessing operations and as a model that can also be used as a tool. Models offer a lot of advantages, but it’s an open question as to how fully developed the analysis should be before you turn it into a model.
Our recommendation is to plan the analysis in a traditional way: sketching the workflow on paper or a whiteboard, experimenting with geoprocessing tools, and discussing the results with colleagues. Wait until you have a firm plan before you take the analysis into ModelBuilder. (And remember that even your “firm plan” will probably change.) If you start with ModelBuilder as your whiteboard, you may find that the model gets too messy in the early planning stages and needs constant corrections. Of course, the more you know about analysis, geoprocessing tools, and ModelBuilder, the sooner you can get your model in good working order. Once that’s done, it’s relatively easy to add further complexity.
Now that you’ve run the analysis and identified some suitable park sites, you’ll need to communicate your results with stakeholders and decision-makers through map products. In lesson 8, you’ll create a printable map layout with essential cartographic elements such as a title, scale bar, north arrow, and legend.