Sunday 15 June 2014

Building spatial algorithms with ModelBuilder of ArcGIS



ModelBuilder of ArcGIS is the most useful tool (or set of tools) I have ever used as a GIS programmer and administrator. The main reason of course is the (very) large set of tools that comes with it. We may not overlook the simplicity in the designing of custom models; the users draw graphically a chart flow of the procedure they want to run and they run it. Moreover, if you get familiar with ModelBuilder you end up building models that you use everyday automating large parts of your daily routine work.
Most people use ModelBuilder as an application for building procedures that simply combine tools from the ArcGIS Toolkit mainly for the manipulation of spatial datasets. This is also how most tutorials describe the use of ModelBuilder, but this alone is not very interesting. Let us see through examples how a user may use ModelBuilder in order to implement spatial algorithms. A theoretical and application-independent justification of the following examples may be found in my paper here. The paper is too technical and theoretical and some people have difficulties reading it so let us see some examples of spatial algorithms implementations in ModelBuilder along with a graphical presentation of each one.
For the next examples we call N a dataset of linear features (arcs) that represent some directed network. The features are categorized in 2 or more categories and the categorization is stored in the attributed of each arcs. N is stored in a geodatabase with spatial indexes but without built topology or any network dataset relationships. One advantage of the next examples is that the user is not require to build topology or other relationships which makes the procedure more efficient.

Problem I: Locate the nodes in N with degree equal to one.
It is a simple problem; in each nodes of degree one (also called free node) there is only one arc attached. These nodes are the ends of dead-end streets in road networks or the terminals in telecommunication networks.

Algorithm I:
1. Create point feature class Point_1 with the endpoints of the arcs in N. Use FeatureVerticesToPoints with the option BOTH_ENDS.
2. Execute Spatial Join, set Point_1 as Join Feature and Target Featureas well. Output the result in class Point_2.
3. Select features from Point_2 where field Join_Count = 1. Output the result in class RESULT; this is the output of the algorithm.



The model runs fast as it performs spatial join among point features and it avoids computing intersections among arcs which is more complex. I have tested it in ArcGIS 10 in a network of 1,000,000 arcs. It ran in less than 5 minutes in a computer of medium capabilities.


Problem II: Locate in N the intersections of arcs that belong in categories 1 and 2.
This is a little more interesting. It is useful when you need to check the connectivity of the network as well as illegal connections. In case category 1 regards highway roads and category 2 unpaved roads, it is critical to know if there are intersections among the features of these two categories in your dataset

Algorithm II:
1. Create classes Cat_1 and Cat_2 using Select tool with the features of categories 1 and 2.
2. Create point feature classes Point_1 and Point_2 with the endpoints of the arcs of the two categories as in Algorithm I.
3. Execute Spatial Join, set Point_1 as Join feature class and Point_2 as Target. Output the result in class JOIN_RESULT.
4. Select the features from JOIN_RESULT where Join_Count > 0. Output the result in class RESULT; this is the output of the algorithm.



Problem III: Locate the points of no flow in N.
Locate the nodes in N which stand as barriers for network flow. In these nodes, network traffic is either only directed to them or only directed form them. See an instance in the following image.



Algorithm III:
1. Create point feature class Point_1 with the starting endpoints of the arcs. Use FeatureVerticesToPoints with the option END.
2. Create point feature class Point_2 with the ending endpoints of the arcs. Use FeatureVerticesToPoints with the option START.
3. Execute Spatial Join, set Point_1 as Join feature class and Point_2 as Target. Output the result in class JOIN_RESULT.
4. Select the features from JOIN_RESULT where Join_Count = 0. Output the result in class RESULT; this is the output of the algorithm.



The main idea in Algorithm 3 is that in nodes with normal flow, there is at least an ending point of an arc that leads the traffic to the node and at least a starting point of an arc that takes the traffic from it.



http://wmsviewer-rodis.rhcloud.com/