I am running both Service Area analysis and Closest Facility analysis using the same network dataset, StreetMap Premium 2017R3. The service area lines exactly line up with the underlying street network, but the closest facility routes do not - they appear to be more generalized. I need these to line up as I'm trying to combine these outputs into a single linear feature. I'm running these using a geoprocessing tool in Python 3.x so it should be using my install of ArcGIS Pro 2.1.2.
Code to create routes in the closest facility analysis:
# create layer result_object_cf = arcpy.na.MakeClosestFacilityAnalysisLayer(pathtoroadnetwork, nameofnalayer, line_shape="ALONG_NETWORK") #Get the layer object from the result object. The closest facility layer can #now be referenced using the layer object. layer_object_cf = result_object_cf.getOutput(0) # load locations arcpy.na.AddLocations(layer_object_cf, facilities_layer_name_cf, facilities_cf, "", "", append="CLEAR") arcpy.na.AddLocations(layer_object_cf, incidents_layer_name_cf, incidents_cf, field_mappings_cf, "", append="CLEAR") # solve arcpy.na.Solve(layer_object_cf) print(arcpy.GetMessages()) # export output routes_layer_name_cf = sublayer_names_cf["CFRoutes"] out_cfroutes = "name_of_output_routes" arcpy.management.CopyFeatures(routes_layer_name_cf, out_cfroutes)
I receive no errors during this processing.
According to the documentation for Closest Facility, the setting I'm using (
line_shape="ALONG_NETWORK") should produce lines that match the underlying network.
No matter which output shape type is chosen, the best route is always determined by the network impedance, never Euclidean distance. This means only the route shapes are different, not the underlying traversal of the network.
ALONG_NETWORK —The output routes will have the exact shape of the underlying network sources. Furthermore, the output includes route measurements for linear referencing. The measurements increase from the first stop and record the cumulative impedance to reach a given position.
An example of the issue is found below. The underlying thin line is the Routing_ND, the orange line is from the service area, and the magenta line is from the closest facility routes.
I've tried recreating the dataset, and have also tried copying the traversed edges instead of just the output lines.
traversedEdges = arcpy.na.CopyTraversedSourceFeatures(layer_object_cf, "in_memory", "TraversedEdges", "TraversedJunctions", "TraversedTurns").getOutput(0) outEdges = "nameofedgeoutput" arcpy.management.CopyFeatures(traversedEdges, outEdges)
It looks like I may be able to force these closer to each other using the Integrate tool (possibly not, due to export restrictions on the roads) but ideally I want to follow the actual road network, not arbitrarily move both the accurate (service area lines) and inaccurate (closest facility routes) closer to each other. My next thoughts are to 1) try to extract out the paired start and closest facility location and use the Route Analysis Layer or 2) use the ArcGIS Desktop 10.5.1 version of this tool, which has a parameter of output_path_shape instead of line_shape, and try output_path_shape ="TRUE_LINES_WITH_MEASURES".
Do you have any other suggestions or something I might have overlooked?