To successfully perform a network analysis, the analysis inputs must be located on the network being used for the analysis. 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 their network locations.
Use the Calculate Locations tool to precalculate network locations
Use the Calculate Locations tool to precalculate network locations. This tool calculates the network locations for an input feature class and stores the information in network location fields, which are added to the feature class. These fields can be used when the feature class is used as input for a network analysis.
The Calculate Locations tool cannot use a network analysis service URL as the input network. It is not possible to precalculate network locations for a service directly.
You cannot precalculate and use network locations for the ArcGIS Online service because the network data used by the service is updated frequently and is not accessible to customers. However, you can precalculate and use network locations for an analysis using the ArcGIS Enterprise routing service if you have access to the network dataset that was used when the service was published. You can use this network dataset on your local machine as input to the Calculate Locations tool to precalculate the network locations. The network location fields calculated by the tool can be used in analyses referencing the service.
Validity of precalculated network location fields
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 and rebuild the network dataset, recalculate any stored location fields in case the edits affect how the inputs locate.
Use precalculated network locations in an analysis
Precalculated network location fields are transferred to the input analysis sublayer or class through field mapping. The workflow depends on whether you are using a network analysis layer or the Network Analyst Python module and is described in the subsections below.
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.
Use precalculated network locations for layer-based network analysis workflows
When performing analysis using a network analysis layer, you can map precalculated location fields when you add inputs to the analysis layer using the Add Locations tool. To do this, use the Field Mappings parameter to map the network location fields from the input features to the network location properties. If you are using the tool dialog box, set the Field Mappings parameter to Use Network Location Fields to enable the mapping.
Use precalculated network locations for Python-based workflows using the Network Analyst module
When performing analysis in Python using the Network Analyst module, network location fields can be used when adding inputs using the load or insertCursor method. With the insertCursor method, you can specify the network location fields in the same way as any other field. For workflows using the load method, you can map the network location fields from the input to the fields in the input class using the fieldMappings method, setting the use_location_fields parameter to True. Once field mappings with the network location fields have been created, they can be used in the load method's field_mappings parameter.
These procedures are described in more detail, including code samples, in Set analysis inputs.
Precalculated network locations and automatic relocating at solve time
By default, existing network location fields are checked when an analysis is solved to ensure that they are valid and reachable. Individual inputs may have their network location fields automatically recalculated at solve time under the following circumstances:
- The input does not have network location fields, or the location fields are invalid or incomplete.
- The input's Status field indicates that it is not located, not reached, or not located on the closest possible network location.
- The input is located on a network element that is restricted by the travel mode being used for the analysis.
- The input is obstructed by a barrier.
Additionally, for a network analysis layer, all inputs will be automatically relocated at solve time if the network dataset has been rebuilt or the locate settings have been changed on the layer's property page since the last time the network analysis layer was solved. In this case, all precalculated network locations will be updated and overwritten.
In many cases, this automatic relocating is the desired behavior, particularly in the presence of barriers, which are not used when precalculating network locations. In this case, it is important that the network analysis layer or Python solver object be configured with the same locate settings that were used when precalculating the network locations. Inputs affected by barriers will be relocated to avoid the barriers, and the location fields of other inputs relocated for different reasons will not change because the same locate settings are applied.
Although the automatic relocation behavior is valuable in some cases, there are other circumstances when you may want to turn this option off. In particular, if you are not using barriers in the analysis, this behavior has minimal value. If the analysis is configured with the same locate settings you used when precalculating the network locations, the automatic relocating behavior finds the same network locations again. You may also experience small performance improvements by skipping the automatic relocation step.
When performing network analysis using layer-based workflows, you can adjust this setting using the Allow automatic relocating at solve time parameter in the Add Locations tool or using the network analysis layer's properties page. When performing analysis in Python using the Network Analyst module, you can adjust this setting using the allowAutoRelocate property.
Regardless of the setting's value, any input with no network location fields or incomplete location fields will be located at solve time using the locate settings configured for the analysis. Similarly, if the network dataset is rebuilt or the other locate settings are changed, existing location fields are assumed to be invalid, and all locations are recalculated at solve time regardless of the setting's value.