Skip To Content



Generates turn-by-turn directions from a network analysis layer with routes. The directions can be written to a file in text, XML, or HTML format. If you provide an appropriate stylesheet, the directions can be written to any other file format.


  • The tool solves the network analysis layer if it does not already have a valid result, so it is not required to solve the network analysis layer before generating directions.


Directions_na (in_network_analysis_layer, file_type, out_directions_file, report_units, {report_time}, {time_attribute}, {language}, {style_name}, {stylesheet})
ParameterExplanationData Type

Network analysis layer for which directions will be generated. Directions can be generated only for route, closest facility, and vehicle routing problem network analysis layers.

Network Analyst Layer

The format of the output directions file. This parameter is ignored if the stylesheet parameter has a value.

  • XMLThe output directions file will be generated as an XML file. Apart from direction strings and the length and time information for the routes, the file will also contain information about the maneuver type and the turn angle for each direction.
  • TEXTThe output directions file will be generated as a simple TXT file containing the direction strings, the length and, optionally, the time information for the routes.
  • HTMLThe output directions file will be generated as an HTML file containing the direction strings, the length and, optionally, the time information for the routes.

If you provide a stylesheet in the stylesheet parameter, make sure the file suffix for out_directions_file matches the file type your stylesheet produces.


Specifies the linear units in which the length information will be reported in the directions file. For example, even though your impedance was in meters, you can show directions in miles.

  • FeetFeet
  • YardsYards
  • MilesMiles
  • MetersMeters
  • KilometersKilometers
  • NauticalMilesNautical miles
  • NO_REPORT_TIMEDo not report travel times in the directions file.
  • REPORT_TIMEReport travel times in the directions file. This is the default.

The time-based cost attribute to provide travel times in the directions. The cost attribute must exist on the network dataset used by the input network analysis layer.


Choose a language in which to generate driving directions. The languages that are shown in the drop-down list depend on which ArcGIS language packs are installed on your computer.

Note that if you are going to publish this tool as part of a service on a separate server, the ArcGIS language pack that corresponds with the language you choose must be installed on that server for the tool to function properly. Also, if a language pack isn't installed on your computer, the language won't appear in the drop-down list; however, you can type a language code instead of choosing one.


Choose the name of the formatting style for the directions.

  • NA DesktopPrintable turn-by-turn directions
  • NA NavigationTurn-by-turn directions designed for an in-vehicle navigation device
  • NA CampusTurn-by-turn walking directions, which are designed for pedestrian routes

The stylesheet for generating a formatted output file type (such as a PDF, Word, or HTML file). The suffix of the file in the output directions file parameter should match the file type that the stylesheet generates. The Directions tool overrides the output file type parameter if this parameter contains a value.


If you want a head start on creating your own text and HTML stylesheets, copy and edit the stylesheets Network Analyst uses. You can find them in the following directory: <ArcGIS installation directory>\ArcGIS\ArcGIS Pro\Resources\NetworkAnalyst\Directions\Styles. The stylesheet is Dir2PHTML.xsl, and the text stylesheet is Dir2PlainText.xsl.


Code sample

Directions example 1 (Python window)

Execute the Directions tool with all the parameters."Route", "TEXT", "C:/Data/Route_Directions.txt", "Miles",
                    "REPORT_TIME", "Minutes")
Directions example 2 (workflow)

The following stand-alone Python script demonstrates how the Directions tool can be used to generate driving directions in a HTML file for a route.

# Name:
# Description: Generate driving directions in an html file for a route that
#              visits the store locations in the best sequence in order to
#              minimize the total travel time
# Requirements: Network Analyst Extension

#Import system modules
import arcpy
from arcpy import env
import os

    #Check out Network Analyst license if available. Fail if the Network Analyst license is not available.
    if arcpy.CheckExtension("network") == "Available":
        raise arcpy.ExecuteError("Network Analyst Extension license is not available.")
    #Set environment settings
    output_dir = "C:/Data"
    #The NA layer's data will be saved to the workspace specified here
    env.workspace = os.path.join(output_dir, "Output.gdb")
    env.overwriteOutput = True

    #Set inputs and outputs
    input_gdb = "C:/Data/SanFrancisco.gdb"
    network = os.path.join(input_gdb, "Transportation", "Streets_ND")
    layer_name = "StoreRoute"
    travel_mode = "Driving Time"
    start_location = os.path.join(input_gdb, "Analysis", "DistributionCenter")
    store_locations = os.path.join(input_gdb, "Analysis", "Stores")
    output_directions = os.path.join(output_dir,
                                                layer_name + "_Directions.html")
    output_layer_file = os.path.join(output_dir, layer_name + ".lyrx")

    #Create a new route layer. The route starts at the distribution center and
    #visits the stores in the best order to yield the shortest travel time.
    result_object =, layer_name,
                                        travel_mode, "PRESERVE_FIRST",
                                        time_of_day="8:00 AM")

    #Get the layer object from the result object. The route layer can
    #now be referenced using the layer object.
    layer_object = result_object.getOutput(0)

    #Get the names of all the sublayers within the route layer.
    sublayer_names =
    #Stores the layer names that we will use later
    stops_layer_name = sublayer_names["Stops"]

    #Load the distribution center as the start location using default field
    #mappings and search tolerance, stops_layer_name, start_location, "",

    #Load the store locations as stops. Make sure the store locations are
    #appended to the Stops sublayer so the distribution center you just loaded
    #isn't overwritten. Map the ServiceTime field from the input data to the
    #Attr_[impedance] property in the Stops sublayer so that the time it takes to
    #service each store is included in the total travel time for the route.
    #Figure out what the impedance attrbute is
    solver_props =
    impedance = solver_props.impedance
    #Handle field mappings
    field_mappings =,
    field_mappings["Name"].mappedFieldName = "Name"
    field_mappings["Attr_" + impedance].mappedFieldName = "ServiceTime", stops_layer_name, store_locations,
                          field_mappings, "", append="APPEND",
                          exclude_restricted_elements = "EXCLUDE")

    #Generate driving directions in an HTML file, "HTML", output_directions, "Miles",
                        "REPORT_TIME", impedance)

    #Save the solved na layer as a layer file on disk

    print("Script completed successfully")

except Exception as e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print("An error occurred on line %i" % tb.tb_lineno)


Licensing information

  • ArcGIS Desktop Basic: Requires Network Analyst
  • ArcGIS Desktop Standard: Requires Network Analyst
  • ArcGIS Desktop Advanced: Requires Network Analyst

Related topics