Creating models with interactive input (ModelBuilder 10.0-10.2)


The ModelBuilder tool has been available in ArcGIS for Desktop since 2004 and it quickly gained a reputation of an easy-to-use application. It which can help the user to execute an entire geoprocessing workflow by adding and connecting tools and input/output datasets together in a graphical environment. Models created in the ModelBuilder are executable workflows that string together sequences of geoprocessing tools, feeding the output of one tool into another tool as input.

Such a workflow can be executed as a tool (if you right-click on it in the catalog window in ArcMap), or it can be exported to a python script and be incorporated into a larger script later on. And of course, you can trigger the execution of the model from within the ModelBuilder Window.

A model can have parameters – the elements that a user marks as “parameters” – so that they appear in the tools dialog if a model is executed as a geoprocessing tool using the tool’s dialog. You can find some information to get started with the ModelBuilder here: >>

Today I will show you one of the ways to turn your geoprocessing models into interactive geoprocessing tools by using the Feature Sets.

Imagine that you need to run a model using just a small piece of the entire dataset and avoid using the CLIP tool, because it will duplicate the data. In another scenario, you may need to select an area on the map and apply your geoprocessing model to the features that are completely contained by this selected area only. Another possible situation: you need to use a model containing a tool that requires a point input, like the Viewshed Tool, which requires the observer’s location to be specified. Well, let’s make these models a bit more interactive by using Feature Sets in the ModelBuilder.

I will create a simple model that uses the Viewshed tool mentioned above. This tool is included in the 3D Analyst and Spatial Analyst toolboxes and it is used to determine the raster surface locations visible to a set of observer features. All you need to run this tool is a DEM (DIGITAL ELEVATION MODEL), observer features – points with known X,Y,Z locations and a license for either 3D analyst or Spatial Analyst.

Step 1. Open the Model Builder

01

Drag and drop the DEM and the Viewshed (Spatial Analyst) tool to the Model.

02

Connect the DEM to the tool as “input raster”

Step 2. Create a layer file.

Add a random point feature class to ArcMap, set the symbology to whatever you like (I used simple marker symbol, size = 18) and right-click on the layer in the table of contents to save it as Layer (*.LYR) file.

03

Don’t worry about coordinate systems or anything else – all only need to use it as a dummy layer to create a layer file.

I called my layer file symbology.LYR

04

Remove the point layer from ArcMap, you won’t use in this workflow.

Step 3. Add a new “Feature Set” variable

In the ModelBuilder navigate to Insert > Create Variable

05

Set the type to Feature Set:

06

Connect the new variable to the Viewshed Tool as “Input point or polyline observer features”

07

Assign the symbology to the new variable. Right-click on the Feature Set and navigate to Properties > Data Types.

Click Browse next to Import Schema and symbology and navigate to the layer file that you saved in the previous step.

08

Note: just keep in mind that if your DEM raster uses a Geographic Coordinate system you will need to apply the Z-factor to re-calculate the units of the coordinate system to metres.

The model is now ready to run even despite one of the parameters hasn’t been specified. It’s an optional output dataset produced by the Viewshed Tool and we won’t use it in this example.

09

Step 4. Set the model parameters.

We will run this model as a geoprocessing tool, using a standard tool’s dialog with parameters. And to make an element from your model appearing in the tool’s dialog, you need to mark it as “model parameter”.

Right-click on the input variables (the blue ovals) and choose “model parameter”.

10

In the end the model will look like the following one:

11

Save the model in a custom toolbox.

12

Close the ModelBuilder.

Step 5. Locate the model in the Catalog Window and double-left click on it to open the tool’s dialog.

The tool’s dialog will contain a feature template, just like the one you can use in Editing:

13

Click on the template and then click on the map to select the observer’s location (or a few locations). Run OK to run the Tool and execute the model.

Analyse the result in ArcMap:

14

You can also overlay the resulting visibility raster over a DEM in ArcScene:

15

This was just one of the many examples of how an interactive input can be implemented to make your ModelBuilder model dynamic, interactive and fully customizable. You can use feature sets to select elements, digitise the areas of interest, pinpointing locations and then process this information in the model.

Additional information about feature sets and record sets is available in the online help: >>

If you are keen to learn more about building geoprocessing models in the ModelBuilder and would like to discover the full potential of this visual geoprocessing environment, come to our training course Geoprocessing Workflows. See you there!

3 thoughts on “Creating models with interactive input (ModelBuilder 10.0-10.2)

  1. Somil Miglani

    Hi, I was wondering if we had to publish this model as a service which derives inputs from a Javascript client using esri maps, how would that be made possible? I wish the user to input a 2D point from a map hosted on a client. This point would then be used to set the observer’s position. The DEM would be stored on my server as a fixed parameter. Thanks in advance.

    Reply
    1. Ivan E. Post author

      Thanks a lot for your question. You can publish the models created in the MB as geoprocessing services via the Results Window in ArcMap. The process can be slightly different depending on the tools and components referenced by the model. But you can get a general overview of the process in the online help: http://resources.arcgis.com/en/help/main/10.1/index.html#//005700000042000000

      Let us know if you have any problems in implementing this. Thank you!

      Reply

Got something to say?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s