When you perform a network analysis, the inputs to your analysis rarely fall exactly on top of the edges or junctions of the network data source you are using. For example, you may be using a network dataset constructed from street centerlines, but the points you want to analyze are the centroids of parcels in your city. These parcel centroids do not fall on top of the street centerlines; rather, they are offset some distance from the streets. To successfully perform a network analysis, Network Analyst must determine the location on the network dataset where each analysis input lies. This network location, rather than the input's original location, is used in the analysis. For example, if you calculate a route between two parcels in your city, the start and end points of the route are not the parcel centroids but rather the locations where the parcel centroids snap to the street centerlines.
The image above illustrates where a route stop is located on the network. The purple circle indicates the geographic location of the stop. However, the route line begins at the closest point along the street network, which is the point's network location.
How locating works
Network locations are calculated based on several factors, including the geographic locations of the inputs, the settings of the network analysis for which the inputs will be used, and user-specified location settings in the tool or function being used to locate the inputs. The procedure works as follows for an input point:
- Network Analyst finds the closest point of the closest network edge to the original point location.
- Network Analyst considers the network analysis settings and the user's location settings to determine if this edge is valid for locating analysis inputs. If the edge is considered invalid for locating, the edge is skipped, and the next-closest edge is considered. The following are a few reasons an edge may be considered invalid for locating:
- The edge is restricted by the selected travel mode. For example, if the current travel mode restricts all limited-access highways, and the closest network edge is a limited-access highway, points for this analysis cannot be located on this edge.
- The edge, or the closest part of the edge, is restricted by a barrier.
- The edge is restricted by the location settings you specified. For example, you can use a search query to prevent locating inputs on network edges with a particular road class.
- The process repeats, each time examining the next-closest network edge, until a valid network location is found for the input point. If no valid location is found within the specified search tolerance distance, the point remains unlocated and cannot be used in the analysis.
When locating point barriers, the travel mode and other barriers are ignored. Only the geometry and the user-specified location settings are considered.
Lines and polygons can also be used as network analysis inputs but only as line and polygon barriers. These barriers locate on all network edges or junctions they overlap, subject to the user-specified location settings.
Network location fields
Once an input has been located on the network, its network location is defined using network location fields.
Network location fields for points
For point inputs, the network location fields contain the ID of the network edge or junction where the point is located. If the point is located on an edge, the location fields also contain the position along that edge and the side of the edge where the point falls. The network location fields for point inputs are as follows:
|Field name||Description||Data Type|
The numeric identifier of the network dataset source feature class on which the input point is located.
The ObjectID of the feature in the source on which the input point is located.
The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.
The side of the edge in relation to the digitized direction of the line feature. This field is limited to a domain of two values: Right Side (1) and Left Side (2).
The x-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.
The y-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.
The z-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset. The SnapZ field is 0 if the network is two dimensional.
The distance in meters between the point's geographic location and the position where it was located on the network.
Network location fields for lines and polygons
Lines and polygons can be used as barriers in a network analysis. The network location of a line or polygon input is defined by a single BLOB field: Locations.
|Field name||Description||Data Type|
The information in this field defines which network edges and junctions are covered by the line or polygon and the portion of each edge element that is covered. You cannot directly read or edit the information contained in this field, but Network Analyst interprets it when solving an analysis.
How and when network locations are calculated in a network analysis
How and when inputs are located on the network differs depending on how you are running your network analysis.
Layer-based network analysis workflows
When performing analysis using a network analysis layer, inputs are added to the network analysis layer using the Add Locations tool. If your analysis layer references a local network dataset, the network locations of the inputs are calculated when you run the Add Locations tool, and you can view the populated network location fields in the attribute table of the sublayer where you added the inputs. By default, the locations of points added to a network analysis layer display at their original locations even though the network locations have been calculated and are used in the analysis. You can display the points at their network locations instead by turning on the Snap to Network option in the Add Locations tool.
The Add Locations tool contains several settings for controlling the locating behavior. For example, you can set the search tolerance distance, indicate which network sources should and shouldn't be used for locating, or set a search query to restrict network source features matching certain characteristics. You can read more about these options in the tool documentation.
Additionally, the network analysis layer's travel mode and existing barriers are considered when locating inputs. Inputs are not located on edges and junctions that are restricted by the travel mode or by existing barriers. Consequently, it is recommended that you set the travel mode and load barriers before loading other analysis inputs. However, if you change the travel mode after adding locations or you add or remove barriers, the network locations of affected points are automatically recalculated at solve time to ensure that they remain valid.
If your analysis layer references a portal service, the location fields are not calculated until you solve the analysis. The Add Locations tool adds the inputs to your analysis layer without calculating location fields. At solve time, the inputs are sent to the service along with the analysis settings. The service calculates the location fields, performs the analysis, and returns the result. Once the layer has been solved, you can see the now-populated location fields in the attribute tables of the input sublayers.
You can also use the editing tools to manually create network analysis inputs. The network locations for these input features are calculated automatically when you solve the analysis layer.
Workflows using the Ready-to-Use tools
When performing analysis using the ArcGIS Online routing services via the Ready-to-Use tools, network locations are calculated by the service when you run the tool. You can see the network locations that were used in the attribute tables of input features that are returned by the service. No specific location settings are available with the Ready-to-Use tools, but the travel mode settings and barriers are considered when locating inputs. Inputs are not located on edges and junctions that are restricted by the travel mode or the specified restrictions and impedance attribute or covered by barriers.
Python-based workflows using the Network Analyst module
When performing analysis in Python using the Network Analyst module, arcpy.nax, inputs are added to the analysis using the load method or the insertCursor method on the network analysis solver object. The network locations are not calculated until the analysis is solved using the solve method. Once the analysis has been solved, the now-populated location fields appear in the outputs accessible via the solver's result object.
Each network analysis object contains some properties that control locating behavior. For example, you can set the search tolerance distance using the searchTolerance and searchToleranceUnits properties or set a search query using the searchQuery property to restrict network source features matching certain characteristics. Additionally, the analysis object's travel mode and barriers are considered when locating inputs. Inputs are not located on edges and junctions that are restricted by the travel mode or by any barriers you included in the analysis.
Precalculating network location fields
Calculating network locations for a large number of inputs can be a time consuming process. If you plan to use the same input data for multiple analyses using the same network dataset and analysis settings, you can save processing time by precalculating your network location fields. You can use the Calculate Locations tool, which adds network location fields to a feature class based on a particular network dataset, travel mode, and tool settings.
When performing analysis using a network analysis layer, your precalculated location fields can be used when you add your inputs to the analysis layer through the Add Locations tool. To do this, use the Field Mappings option to map the network location fields from your input features to the network location properties. If you are using the tool dialog box, set the field mappings combo box to Use Network Location Fields to enable this mapping.
When performing analysis in Python using the Network Analyst module, the network location fields can be mapped from your input into the fields in the input class using the field_mappings parameter of the load method if you set the use_location_fields parameter to True.
When mapping network location fields for an analysis, only map the SourceID, SourceOID, PosAlong, and SideOfEdge fields. The SnapX, SnapY, SnapZ, and DistanceToNetworkInMeters fields are informational and are not required to specify the locations for an analysis.
You cannot use precalculated network locations when using the Ready-to-Use tools from ArcGIS Online or when using a network analysis layer that references ArcGIS Online as its network data source. However, if your network analysis layer references your enterprise portal as its network data source, you can precalculate locations fields using the same network dataset you used when publishing the ArcGIS Enterprise routing services, and the services will use the location fields when solving the analysis.
Precalculated location fields are only valid for the network dataset and travel mode for which they were calculated. If you plan to use these points with a different network or travel mode, recalculate the location fields. Additionally, if you edit the network dataset, recalculate any stored location fields in case the edits affect how the inputs locate.
Sometimes Network Analyst cannot locate an input on the network. This most commonly occurs when no valid network edges or junctions can be found within the specified search tolerance distance. These unlocated inputs cannot be used in the network analysis.
When a point is unlocated, the network location fields are not populated. Additionally, the Status field has a value of 1(Not Located). You can use the Status field to query your table to find all unlocated inputs. Review the geographic locations of these unlocated points to determine whether they are safe to ignore or if they need to be edited.
When you solve a network analysis layer, unlocated inputs are ignored by default. If you instead want the solve to fail if any inputs are unlocated, uncheck the Ignore Invalid Locations option on the Solve tool. For Python-based workflows, use the network analysis solver object's ignoreInvalidLocations property to indicate whether unlocated points should be ignored. When performing analysis using the Ready-to-Use tools, unlocated inputs are always ignored.
Use a vehicle's bearing to more accurately calculate network locations
The direction in which a vehicle is moving, or its bearing, can be used to more accurately determine its location on a network.