Skip To Content ArcGIS for Developers Sign In Dashboard

Origin Destination Cost Matrix service with asynchronous execution

Description

The Origin Destination Cost Matrix service helps you to create an origin-destination (OD) cost matrix from multiple origins to multiple destinations. An OD cost matrix is a table that contains the cost, such as the travel time or travel distance, from each origin to each destination. Additionally, it ranks the destinations that each origin connects to in ascending order based on the minimum cost required to travel from that origin to each destination. When generating an OD cost matrix, you can optionally specify the maximum number of destinations to find for each origin and the maximum time or distance to travel when searching for destinations.

The results from the OD cost matrix service often become input for other spatial analyses where the cost to travel on the street network is more appropriate than straight-line cost. For example, predicting the movement of people in a city is better modeled with costs based on street networks, since people tend to travel on roads and pedestrian paths.

The best path on the street network is discovered for each origin-destination pair, and the cost is stored as part of the attributes of the output lines, which can have no shapes (default) or a straight line shape. Even though the lines are straight for performance reasons, they always store the travel time or travel distance based on the street network, not straight-line distance.

Tip:

The closest facility and OD cost matrix services perform very similar analyses; the main difference, however, is in the output and the computation speed. OD cost matrix service generates results more quickly but cannot return the true shapes of routes or their driving directions. It is designed to quickly solve large M x N problems and, as a result, does not internally contain the information required to generate route shapes and driving directions. Alternatively, the closest facility service returns routes and directions but performs the analysis more slowly than the OD cost matrix service. If you need driving directions or true shapes of routes, use the closest facility service; otherwise, use the OD cost matrix service to reduce the computation time.

Request parameters

ParameterDescription
origins

(Required)

Specify locations that function as starting points in generating the paths to destinations.

Syntax:

destinations

(Required)

Specify locations that function as ending points in generating the paths from origins.

Syntax:

token

(Required)

Provides the identity of a user who has the permissions to access the service.

f

(Required)

Specify the response format. The default value is html.

Values: html | json| pjson

travel_mode

(Optional)

Choose the mode of transportation for the analysis.

Value: JSON object

time_units

(Optional)

Specify the units that should be used to measure and report the total travel time between each origin-destination pair. The default value is Minutes.

Values: Minutes | Seconds | Hours | Days

distance_units

(Optional)

Specify the units that should be used to measure and report the total travel distance between each origin-destination pair. The default value is Kilometers.

Values: Kilometers | Meters | Feet | Yards | Miles | NauticalMiles

analysis_region

(Optional)

Specify the region in which to perform the analysis.

number_of_destinations_to_find

(Optional)

Specify the maximum number of destinations to find per origin. The default for this parameter is to be undefined. To learn more about the accepted values for this parameter, see the number_of_destinations_to_find section below.

cutoff

(Optional)

Specify the travel time or travel distance value at which to stop searching for destinations from a given origin. Any destination beyond the cutoff value will not be considered. The default for this parameter is to be undefined. To learn more about the accepted values for this parameter, see the cutoff section below.

time_of_day

(Optional)

Specify whether travel times should consider traffic conditions. To learn about the accepted values for this parameter, see the time_of_day section below.

time_zone_for_time_of_day

(Optional)

Specify the time zone or zones of the time_of_day parameter. The default value is Geographically Local.

Values: Geographically Local | UTC

point_barriers

(Optional)

Specify one or more points that act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets. To learn about the accepted values for this parameter, see the point_barriers section below.

Syntax:

line_barriers

(Optional)

Specify one or more lines that prohibit travel anywhere the lines intersect the streets. To learn about the accepted values for this parameter, see the line_barriers section below.

Syntax:

polygon_barriers

(Optional)

Specify polygons that either prohibit travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons. To learn about the accepted values for this parameter, see the polygon_barriers section below.

Syntax:

uturn_at_junctions

(Optional)

Restrict or allow the analysis to make U-turns at junctions. The default value is Allowed only at Intersections and Dead Ends.

Values: Allowed only at Intersections and Dead Ends | Allowed | Allowed only at Dead Ends | Not Allowed

use_hierarchy

(Optional)

Specify whether hierarchy should be used when finding the shortest paths. The default value is true.

Values: true | false

restrictions

(Optional)

Specify which restrictions should be honored by the service. The default value is demonstrated in the example below. To learn about all the accepted values for this parameter, see the restrictions section below.

restrictions=Avoid Carpool Roads, Avoid Express Lanes, Avoid Gates, Avoid Private Roads, Avoid Unpaved Roads, Driving a Truck, Use Preffered Truck Routes, Roads Under Construction Prohibited, Through Traffic Prohibited
attribute_parameter_values

(Optional)

Specify additional values required by an attribute or restriction, such as to specify whether the restriction prohibits, avoids, or prefers travel on restricted roads. To learn about the accepted values for this parameter, see the attribute_parameter_values sectio below.

impedance

(Optional)

Specify the impedance.

Values: TravelTime | Minutes | TruckTravelTime | TruckMinutes | WalkTime | Miles | Kilometers | TimeAt1KPH

origin_destination_line_shape

(Optional)

Specify the shape of line feature connecting each origin-destination pair in the output matrix. The default value is None.

Values: None | Straight Line

save_output_network_analysis_layer

(Optional)

Specify whether the service should save the analysis settings as a network analysis layer file. The default value is false.

Values: true | false

overrides

(Optional)

Specify additional settings that can influence the behavior of the solver.

time_impedance

(Optional)

Specify the time-based impedance.

distance_impedance

(Optional)

Specify the distance-based impedance.

output_format

(Optional)

Specify the format in which the output features are created. The default value is Feature Set.

Values: Feature Set | JSON File | GeoJSON File | CSV File

env:outSR

(Optional)

Specify the spatial reference of the geometries, such as the output origins or the output destinations returned by the service.

Required parameters

origins

Use this parameter to specify locations that function as starting points in generating the paths to destinations.

The origins parameter can be specified using a JSON structure that represents a set of point features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • spatialReference: Specifies the spatial reference for the input point geometries. This property is not required if the coordinates are in the same spatial reference as your network dataset. If the coordinates are in a different spatial reference, you need to specify the spatial reference's well-known ID (WKID). Depending on whether your input points are specified with a geographic or projected coordinate system, you can find the appropriate WKID in either the geographic coordinate system or a projected coordinate system reference topic.

  • fields: Lists the fields that are part of the input features representing origins. This property is optional if you are using the default fields only. However, it is required if your origins include custom fields.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents an origin and contains the following properties:

  • geometry: Specifies the origin's geometry as a point containing x and y properties.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for origins

When specifying the origins, you can set properties for each one, such as its name or the number of destinations to find from the origin, by using attributes. The origins can be specified with the following attributes

  • Name

    The name of the origin. The name can be a unique identifier for the origin. The name is included in the output lines (as the OriginName field) and in the output origins (as the Namefield) and can be used to join additional information from the tool outputs to the attributes of your origins.

    If the name is not specified, a unique name prefixed with Location is automatically generated in the output origins. An automatically generated origin name is not included in the output lines.

  • TargetDestinationCount

    The maximum number of destinations that must be found for the origin.

    If a value is not specified, the value from the Number of Destinations to Find parameter is used.

    This field allows you to specify a different number of destinations to find for each origin. For example, using this field you can find three closest destinations from one origin and two closest destinations from another origin.

  • Cutoff

    The impedance value at which to stop searching for destinations from a given origin. This attribute allows you to specify a different cutoff value for each destination. For example, using this attribute you can specify to search for destinations within five minutes of travel time from one origin and to search for destinations within eight minutes of travel time from another origin.

    The value needs to be in the units specified by the Time Units parameter if the impedance attribute in your travel mode is time based or in the units specified by the Distance Units parameter if the impedance attribute in your travel mode is distance based. If a value is not specified, the value from the Cutoff parameter is used.

  • CurbApproach

    Specifies the direction a vehicle may depart from the origin. One of the integers listed in the Coded value column in the following table must be specified as a value of this attribute. The values in the Setting column are the descriptive names for CurbApproach attribute values that you may have seen when using the ArcGIS Network Analyst extension software.

    SettingCoded valueDescription

    Either side of vehicle

    0

    The vehicle can depart the origin in either direction, so a U-turn is allowed at the origin. This setting can be chosen if it is possible and practical for your vehicle to turn around at the origin. This decision may depend on the width of the road and the amount of traffic or whether the origin has a parking lot where vehicles can enter and turn around.

    Right side of vehicle
    Departing the origin so that it is on the right side of the vehicle is allowed.
    Left side of vehicle
    Departing the origin so that it is on the left side of the vehicle is allowed.

    Right side of vehicle

    1

    When the vehicle departs the origin, the origin must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must depart from the bus stop on the right side.

    Right side of vehicle
    Departing the origin so that it is on the right side of the vehicle is allowed.

    Left side of vehicle

    2

    When the vehicle departs the origin, the origin must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must depart from the bus stop on the left side.

    Left side of vehicle
    Departing the origin so that it is on the left side of the vehicle is allowed.

    The CurbApproach attribute is designed to work with both types of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider an incident on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach an incident from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, if you want to arrive at an incident and not have a lane of traffic between the vehicle and the incident, you would choose 1 (Right side of vehicle) in the United States but 2 (Left side of vehicle) in the United Kingdom.

    Right side of vehicle with right-hand traffic
    With right-hand traffic, the curb approach that leaves the vehicle closest to the origin is Right side of vehicle.
    Left side of vehicle with left-hand traffic
    With left-hand traffic, the curb approach that leaves the vehicle closest to the origin is Left side of vehicle.
  • Bearing

    The direction in which a point is moving. The units are degrees and are measured clockwise from true north. This field is used in conjunction with the BearingTol field.

    Bearing data is usually sent automatically from a mobile device equipped with a GPS receiver. Try to include bearing data if you are loading an input location that is moving, such as a pedestrian or a vehicle.

    Using this field tends to prevent adding locations to the wrong edges, which can occur when a vehicle is near an intersection or an overpass for example. Bearing also helps the tool determine on which side of the street the point is.

  • BearingTol

    The bearing tolerance value creates a range of acceptable bearing values when locating moving points on an edge using the Bearing field. If the value from the Bearing field is within the range of acceptable values that are generated from the bearing tolerance on an edge, the point can be added as a network location there; otherwise, the closest point on the next-nearest edge is evaluated.

    The units are in degrees, and the default value is 30. Values must be greater than 0 and less than 180. A value of 30 means that when ArcGIS Network Analyst extension attempts to add a network location on an edge, a range of acceptable bearing values is generated 15 degrees to either side of the edge (left and right) and in both digitized directions of the edge.

  • NavLatency

    This field is only used in the solve process if Bearing and BearingTol also have values; however, entering a NavLatency value is optional, even when values are present in Bearing and BearingTol. NavLatency indicates how much time is expected to elapse from the moment GPS information is sent from a moving vehicle to a server and the moment the processed route is received by the vehicle's navigation device.

    The time units of NavLatency are the same as the units specified by the timeUnits property of the analysis object.

Syntax examples for origins

Syntax for specifying origins using a JSON structure for features

{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "x": <x1>,
        "y": <y1>
      },
      "attributes": {
        "<field1>": <value1_1>,
        "<field2>": <value1_2>
      }
    },
    {
      "geometry": {
        "x": <x2>,
        "y": <y2>
      },
      "attributes": {
        "<field1>": <value2_1>,
        "<field2>": <value2_2>
      }
    }
  ]
}

Syntax for specifying origins using a URL returning a JSON response

{
  "url": "<url>"
}

Examples for origins

Example one: Specifying origins in the same spatial reference as the network dataset, WGS84, using JSON structure

The origin geometries are in the same spatial reference as the network dataset, WGS84. Hence, the spatialReference property is not specified. The example also shows how to specify some attributes for the origins.

{
  "features": [
    {
      "geometry": {
        "y": 51.5254,
        "x": -0.1891
      },
      "attributes": {
        "Name": "Origin 1",
        "TargetDestinationCount": 50, 
        "Cutoff": 120,
        "CurbApproach": 0
      }
    },
    {
      "geometry": {
        "y": 51.5353,
        "x": -0.1744
      },
      "attributes": {
        "Name": "Origin 2",
        "TargetDestinationCount": 40,
        "Cutoff": 90,
        "CurbApproach": 0
      }
    }
  ]
}

Example two: Specifying origins in the Web Mercator spatial reference using a JSON structure

The origin geometries are in the Web Mercator spatial reference and not in the spatial reference as the network dataset. Hence, the spatialReference property is required.

{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "y": -5192521.476,
        "x": -2698533.989
      },
      "attributes": {
        "Name": "Origin 1"
      }
    },
    {
      "geometry": {
        "y": -5191915.261,
        "x": -2697821.094
      },
      "attributes": {
        "Name": "Origin 2"
      }
    }
  ]
}

Example three: Specifying origins using URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
  "url": "https://machine.domain.com/webadaptor/rest/services/NetworkAnalysis/SanDiego/MapServer/21/query?where=1%3D1&outFields=Name&f=json"
}

destinations

Use this parameter to specify locations that function as ending points in generating the paths from origins.

The destinations parameter can be specified using a JSON structure that represents a set of point features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • spatialReference: Specifies the spatial reference for the input point geometries. This property is not required if the coordinates are in the same spatial reference as your network dataset. If the coordinates are in a different spatial reference, you need to specify the spatial reference's well-known ID (WKID). Depending on whether your input points are specified with a geographic or projected coordinate system, you can find the appropriate WKID in either the geographic coordinate system or a projected coordinate system reference topic.

  • fields: Lists the fields that are part of the input features representing destinations. This property is optional if you are using the default fields only. However, it is required if your destinations include custom fields.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a destination and contains the following properties:

  • geometry: Specifies the destination's geometry as a point containing x and y properties.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for destinations

When specifying the destinations, you can set properties for each one, such as its name, by using attributes. The destinations can be specified with the following attributes:

  • Name

    The name of the destination. The name can be a unique identifier for the destination. The name is included in the output lines (as the DestinationName field) and in the output destinations (as the Name field) and can be used to join additional information from the tool outputs to the attributes of your destinations.

    If the name is not specified, a unique name prefixed with Location is automatically generated in the output destinations. An automatically generated destination name is not included in the output lines.

  • CurbApproach

    Specifies the direction a vehicle may arrive at the destination. One of the integers listed in the Coded value column in the following table must be specified as a value of this attribute. The values in the Setting column are the descriptive names for CurbApproach attribute values that you may have seen when using ArcGIS Network Analyst extension software.

    SettingCoded valueDescription

    Either side of vehicle

    0

    The vehicle can arrive at the destination from either direction. This setting can be chosen if it is possible and practical for your vehicle to turn around at the destination. This decision may depend on the width of the road and the amount of traffic or whether the destination has a parking lot where vehicles can enter and turn around.

    Right side of vehicle
    Approaching the destination so that it is on the right side of the vehicle is allowed.
    Left side of vehicle
    Approaching the destination so that it is on the left side of the vehicle is allowed.

    Right side of vehicle

    1

    When the vehicle arrives at the destination, the destination must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive at the bus stop on the right side.

    Right side of vehicle
    Approaching the destination so that it is on the right side of the vehicle is allowed.

    Left side of vehicle

    2

    When the vehicle arrives at the destination, the destination must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive at the bus stop on the left side.

    Left side of vehicle
    Approaching the destination so that it is on the right side of the vehicle is allowed.

    The CurbApproach attribute is designed to work with both types of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider an incident on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach an incident from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, if you want to arrive at an incident and not have a lane of traffic between the vehicle and the incident, you would choose 1 (Right side of vehicle) in the United States but 2 (Left side of vehicle) in the United Kingdom.

    Right side of vehicle with right-hand traffic
    With right-hand traffic, the curb approach that leaves the vehicle closest to the destination is Right side of vehicle.
    Left side of vehicle with left-hand traffic
    With left-hand traffic, the curb approach that leaves the vehicle closest to the destination is Left side of vehicle.
  • Bearing

    The direction in which a point is moving. The units are degrees and are measured clockwise from true north. This field is used in conjunction with the BearingTol field.

    Bearing data is usually sent automatically from a mobile device equipped with a GPS receiver. Try to include bearing data if you are loading an input location that is moving, such as a pedestrian or a vehicle.

    Using this field tends to prevent adding locations to the wrong edges, which can occur when a vehicle is near an intersection or an overpass for example. Bearing also helps the tool determine on which side of the street the point is.

  • BearingTol

    The bearing tolerance value creates a range of acceptable bearing values when locating moving points on an edge using the Bearing field. If the value from the Bearing field is within the range of acceptable values that are generated from the bearing tolerance on an edge, the point can be added as a network location there; otherwise, the closest point on the next-nearest edge is evaluated.

    The units are in degrees, and the default value is 30. Values must be greater than 0 and less than 180. A value of 30 means that when ArcGIS Network Analyst extension attempts to add a network location on an edge, a range of acceptable bearing values is generated 15 degrees to either side of the edge (left and right) and in both digitized directions of the edge.

  • NavLatency

    This field is only used in the solve process if Bearing and BearingTol also have values; however, entering a NavLatency value is optional, even when values are present in Bearing and BearingTol. NavLatency indicates how much time is expected to elapse from the moment GPS information is sent from a moving vehicle to a server and the moment the processed route is received by the vehicle's navigation device.

    The time units of NavLatency are the same as the units specified by the timeUnits property of the analysis object.

Syntax examples for destinations

Syntax for specifying destinations using a JSON structure for features

{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "x": <x1>,
        "y": <y1>
      },
      "attributes": {
        "<field1>": <value1_1>,
        "<field2>": <value1_2>
      }
    },
    {
      "geometry": {
        "x": <x2>,
        "y": <y2>
      },
      "attributes": {
        "<field1>": <value2_1>,
        "<field2>": <value2_2>
      }
    }
  ] 
}

Syntax for specifying destinations using a URL returning a JSON response

{
  "url": "<url>"
}

Examples for destinations

Example one: Specifying destinations in the same spatial reference as the network dataset, using JSON structure

The destination geometries are in the same spatial reference as the network dataset. Hence, the spatialReference property is not specified. The example also shows how to specify some attributes for the destinations.

{
  "features": [
    {
      "geometry": {
        "y": 51.5354,
        "x": -0.1991
      },
      "attributes": {
        "Name": "Destination 1",
        "CurbApproach": 0
      }
    },
    {
      "geometry": {
        "y": 51.5458,
        "x": -0.1844
      },
      "attributes": {
        "Name": "Destination 2",
        "CurbApproach": 0
      }
    }
  ]
}

Example two: Specifying destinations in the Web Mercator spatial reference using a JSON structure

The destination geometries are in the Web Mercator spatial reference and not in the spatial reference of the network dataset. Hence, the spatialReference property is required.

{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "y": -5182521.476,
        "x": -2688533.989
      },
      "attributes": {
        "Name": "Destination 1"
      }
    },
    {
      "geometry": {
        "y": -5201915.261,
        "x": -2717821.094
      },
      "attributes": {
        "Name": "Destination 2"
      }
    }
  ]
}

Example three: Specifying origins using a URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
  "url": "https://machine.domain.com/webadaptor/rest/services/NetworkAnalysis/SanDiego/MapServer/21/query?where=1%3D1&outFields=Name&f=json"
}

token

Use this parameter to specify a token that provides the identity of a user that has the permissions to access the service. The accessing services page provides more information on how such an access token can be obtained.

Example (replace <yourToken> with a valid token):
token=<yourToken>

f

Use this parameter to specify the response format. The parameter can have json or pjson as arguments, for example, f=json. The pjson value is used for printing the JSON response in a pretty format.

Optional parameters

travel_mode

Choose the mode of transportation for the analysis.

Travel modes are managed in ArcGIS Online and ArcGIS Enterprise and can be configured by the administrator of your organization to better reflect your organization's workflows. You need to specify the JSON object containing the settings for a travel mode supported by your organization. To get a list of supported travel modes, execute the GetTravelModes tool from the Utilities service.

The value for the travel_mode parameter should be a JSON object representing travel mode settings. When you use the GetTravelModes tool from the Utilities service, you get a string representing the travel mode JSON. You need to convert this string to a valid JSON object using your API and then pass the JSON object as the value for the travel_mode parameter.

For example, below is a string representing the Walking Time travel mode as returned by the GetTravelModes tool.

"{\"attributeParameterValues\": [{\"parameterName\": \"Restriction Usage\", \"attributeName\": \"Walking\", \"value\": \"PROHIBITED\"}, {\"parameterName\": \"Restriction Usage\", \"attributeName\": \"Preferred for Pedestrians\", \"value\": \"PREFER_LOW\"}, {\"parameterName\": \"Walking Speed (km/h)\", \"attributeName\": \"WalkTime\", \"value\": 5}], \"description\": \"Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel time. The walking speed is set to 5 kilometers per hour.\", \"impedanceAttributeName\": \"WalkTime\", \"simplificationToleranceUnits\": \"esriMeters\", \"uturnAtJunctions\": \"esriNFSBAllowBacktrack\", \"restrictionAttributeNames\": [\"Preferred for Pedestrians\", \"Walking\"], \"useHierarchy\": false, \"simplificationTolerance\": 2, \"timeAttributeName\": \"WalkTime\", \"distanceAttributeName\": \"Miles\", \"type\": \"WALK\", \"id\": \"caFAgoThrvUpkFBW\", \"name\": \"Walking Time\"}"

The above value should be converted to a valid JSON object and passed as the value for the travel_mode parameter.

travel_mode={"attributeParameterValues":[{"parameterName": "Restriction Usage","attributeName": "Walking","value": "PROHIBITED"},{"parameterName": "Restriction Usage","attributeName": "Preferred for Pedestrians","value": "PREFER_LOW"},{"parameterName": "Walking Speed (km/h)","attributeName": "WalkTime","value": 5}],"description": "Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel time. The walking speed is set to 5 kilometers per hour.","impedanceAttributeName": "WalkTime","simplificationToleranceUnits": "esriMeters","uturnAtJunctions": "esriNFSBAllowBacktrack","restrictionAttributeNames": ["Preferred for Pedestrians","Walking"],"useHierarchy": false,"simplificationTolerance": 2,"timeAttributeName": "WalkTime","distanceAttributeName": "Miles","type": "WALK","id": "caFAgoThrvUpkFBW","name": "Walking Time"}

The default value,Custom, allows you to configure your own travel mode. When you pass in Custom, you can set values for the following parameters: impedance, time_impedance, distance_impedance, uturn_at_junctions, use_hierarchy, route_line_simplification_tolerance, restrictions, and attribute_parameter_values. You may want to choose Custom and set the custom travel mode parameters listed above, for example, to model a pedestrian with a fast walking speed or a truck with a given height, weight, and cargo of certain hazardous materials. You may choose to do this to try out different settings to get the desired analysis results. Once you have identified the analysis settings, you should work with your organization's administrator and save these settings as part of a new or existing travel mode so that everyone in your organization can rerun the analysis with the same settings.

The default values of the custom travel mode parameters model traveling by car. If you specify the travel mode as Custom or do not provide a value for the travel_mode parameter, the analysis will be similar to using the default Driving Time travel mode.

Caution:

When the travel_mode parameter is not set to Custom, this means you are choosing a travel mode configured by your organization, and the service automatically overrides the values of other parameters with values that model the chosen travel mode. The following parameters are overridden: impedance, time_impedance, distance_impedance, uturn_at_junctions, use_hierarchy, route_line_simplification_tolerance, restrictions, and attribute_parameter_values.

time_units

Specify the units that should be used to measure and report the total travel time between each origin-destination pair.

The choices are as follows:

  • Seconds
  • Minutes (default)
  • Hours
  • Days

distance_units

Specify the units that should be used to measure and report the total travel distance between each origin-destination pair.

The choices are as follows:

  • Meters
  • Kilometers (default)
  • Feet
  • Yards
  • Miles
  • NauticalMiles

analysis_region

Specify the region in which to perform the analysis.

number_of_destinations_to_find

Specify the maximum number of destinations to find per origin. If a value for this parameter is not specified (which is the default), the output matrix includes travel costs from each origin to every destination. Individual origins can have their own values (specified as the TargetDestinationCount field) that override the number_of_destinations_to_find parameter value.

cutoff

Specify the travel time or travel distance value at which to stop searching for destinations from a given origin. Any destination beyond the cutoff value will not be considered. Individual origins can have their own values (specified as the Cutoff field) that override the cutoff parameter value.

The value must be in the units specified by the time_units parameter if the impedance attribute of your travel mode is time based or in the units specified by the distance_units parameter if the impedance attribute of your travel mode is distance based. If a value is not specified (which is the default), the tool will not enforce any travel time or travel distance limit when searching for destinations.

time_of_day

Specify whether travel times should consider traffic conditions. To use traffic in the analysis, choose a travel mode, such as Driving Time or Rural Driving Time, that supports time-based impedance attributes and assigns a value to time_of_day. The time_of_day value represents the time at which travel begins from the origins.

The time is specified as Unix time (milliseconds since midnight, January 1, 1970).

The time_zone_for_time_of_day parameter specifies whether time_of_day is in UTC or the time zone in which the stop is located.

If the network dataset used for publishing the service supports typical traffic, in other words, travel speeds that are made up of historical averages, specifying a time of day results in more accurate routes and estimations of travel times because the travel times account for the traffic conditions that are applicable for that date and time.

time_zone_for_time_of_day

Specify the time zone or zones of the time_of_day parameter. There are two options: Geographically Local (default) and UTC.

Geographically Local

The Geographically Local value indicates for the service to use the time zone in which the input origins are geographically located when applying the time_of_day value.

UTC

The timeOfDay value refers to UTC. The UTC value indicates for the service to use UTC as the time zone when applying the time_of_day value.

Note:

This parameter is ignored when travel_mode is distance based or the impedance parameter is set to Travel Distance if you're using a custom travel mode.

point_barriers

Use this parameter to specify one or more points that act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets. For example, a point barrier can be used to represent a fallen tree along a street or a time delay spent at a railroad crossing.

The point_barriers parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url—Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either the features or url property must be specified.
  • spatialReference—Specifies the spatial reference for the geometries of point barriers. This property is not required if the coordinate values are in the same spatial reference as your network dataset. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See geographic coordinate systems and projected coordinate systems to look up WKID values.
  • features—Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a point barrier and contains the following properties:

  • geometry—Specifies the barrier's geometry as a point containing x and y properties.
  • attributes—Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for point_barriers

When specifying point barriers, you can set properties for each, such as its name or barrier type, using the following attributes:

  • Name

    The name of the barrier.

  • BarrierType

    Specifies whether the point barrier restricts travel completely or adds time or distance when it is crossed. The value for this attribute is specified as one of the following integers (use the numeric code, not the name in parentheses):

    • 0 (Restriction)—Prohibits travel through the barrier. The barrier is referred to as a restriction point barrier since it acts as a restriction.
      Two maps demonstrate how a restriction point barrier affects finding the best route.
      The map on the left shows the shortest path between two stops without any restriction point barriers. The map on the right has a road that is blocked by a fallen tree, so the shortest path between the same points is longer.
    • 2 (Added Cost)—Traveling through the barrier increases the travel time or distance by the amount specified in the Additional_Time, Additional_Distance, or Additional_Cost field. This barrier type is referred to as an added-cost point barrier.
      Two maps demonstrate how added cost barriers affect finding the best route.
      The map on the left shows the shortest path between two stops without any added-cost point barrier. For the map on the right, the travel time from stop one to stop two would be the same whether going around the north end of the block or the south end; however, since crossing railroad tracks incurs a time penalty (modeled with added-cost point barriers), the route with only one railroad crossing is chosen. The cost of crossing the barrier is added to the accumulated travel time of the resulting route.
  • Additional_Time

    The added travel time when the barrier is traversed. This field is applicable only for added-cost barriers and only if the travel mode used for the analysis uses an impedance attribute that is time based.

    This field value must be greater than or equal to zero, and its units are the same as those specified in the Measurement Units parameter.

  • Additional_Distance

    The added distance when the barrier is traversed. This field is applicable only for added-cost barriers and only if the travel mode used for the analysis uses an impedance attribute that is distance based.

    The field value must be greater than or equal to zero, and its units are the same as those specified in the Measurement Units parameter.

  • Additional_Cost

    The added cost when the barrier is traversed. This field is applicable only for added-cost barriers and only if the travel mode used for the analysis uses an impedance attribute that is neither time based nor distance based.

  • FullEdge

    Specifies how the restriction point barriers are applied to the edge elements during the analysis. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):

    • 0 (False)—Permits travel on the edge up to the barrier but not through it. This is the default value.
    • 1 (True)—Restricts travel anywhere on the associated edge.

  • CurbApproach

    Specifies the direction of traffic that is affected by the barrier. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):

    • 0 (Either side of vehicle)—The barrier affects travel over the edge in both directions.
    • 1 (Right side of vehicle)—Vehicles are only affected if the barrier is on their right side during the approach. Vehicles that traverse the same edge but approach the barrier on their left side are not affected by the barrier.
    • 2 (Left side of vehicle)—Vehicles are only affected if the barrier is on their left side during the approach. Vehicles that traverse the same edge but approach the barrier on their right side are not affected by the barrier.

    Because junctions are points and don't have a side, barriers on junctions affect all vehicles regardless of the curb approach.

    The CurbApproach attribute is designed to work with both types of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider a facility on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach a facility from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, if you want to arrive at a facility and not have a lane of traffic between the vehicle and the facility, you would choose 1 (Right side of vehicle) in the United States and 2 (Left side of vehicle) in the United Kingdom.

  • Bearing

    The direction in which a point is moving. The units are degrees and are measured clockwise from true north. This field is used in conjunction with the BearingTol field.

    Bearing data is usually sent automatically from a mobile device equipped with a GPS receiver. Try to include bearing data if you are loading an input location that is moving, such as a pedestrian or a vehicle.

    Using this field tends to prevent adding locations to the wrong edges, which can occur when a vehicle is near an intersection or an overpass for example. Bearing also helps the tool determine on which side of the street the point is.

  • BearingTol

    The bearing tolerance value creates a range of acceptable bearing values when locating moving points on an edge using the Bearing field. If the value from the Bearing field is within the range of acceptable values that are generated from the bearing tolerance on an edge, the point can be added as a network location there; otherwise, the closest point on the next-nearest edge is evaluated.

    The units are in degrees, and the default value is 30. Values must be greater than 0 and less than 180. A value of 30 means that when ArcGIS Network Analyst extension attempts to add a network location on an edge, a range of acceptable bearing values is generated 15 degrees to either side of the edge (left and right) and in both digitized directions of the edge.

  • NavLatency

    This field is only used in the solve process if Bearing and BearingTol also have values; however, entering a NavLatency value is optional, even when values are present in Bearing and BearingTol. NavLatency indicates how much time is expected to elapse from the moment GPS information is sent from a moving vehicle to a server and the moment the processed route is received by the vehicle's navigation device.

    The time units of NavLatency are the same as the units specified by the timeUnits property of the analysis object.

Syntax examples for point_barriers

Syntax for specifying point_barriers using a JSON structure for features

{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "x": <x1>,
        "y": <y1>
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "x": <x2>,
        "y": <y2>
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ] 
}

Syntax for specifying point_barriers using a URL returning a JSON response

{
  "url": "<url>"
}

Examples for point_barriers

Example one: Specifying an added-cost point barrier in the same spatial reference as the network dataset, using JSON structure

This example shows how to use an added-cost point barrier to model a 5-minute delay at a railroad crossing. The BarrierType attribute is used to specify the point barrier is of type added cost and the Additional_Time attribute is used to specify the added delay in minutes. The barrier geometries are in the same spatial reference as the network dataset. Hence, the spatialReference property is not specified.

{
  "features": [
    {
      "geometry": {
        "x": 37.541479,
        "y": -122.053461
      },
      "attributes": {
        "Name": "Haley St railroad crossing",
        "BarrrierType": 2,
        "Additional_Time": 5
      }
    }
  ]
}

Example two: Specifying restriction point barriers in the Web Mercator spatial reference using a JSON structure

This example shows how to use a restriction point barrier to model a road that is blocked by a fallen tree. The barrier's geometry is in the Web Mercator spatial reference and not in the same spatial reference as the network dataset. Hence, the spatialReference property is required.

{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "y": -13635398.9398,
        "x": 4544699.034400001
      },
      "attributes": {
        "Name": "Fallen tree at 123 Main St", 
        "BarrierType": 0
      }
    }
  ]
}

Example three: Specifying point barriers using a URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
  "url": "https://machine.domain.com/webadaptor/rest/services/NetworkAnalysis/SanDiego/MapServer/21/query?where=1%3D1&outFields=Name&f=json"
}

line_barriers

Use this parameter to specify one or more lines that prohibit travel anywhere the lines intersect the streets. For example, a parade or protest that blocks traffic across several street segments can be modeled with a line barrier. A line barrier can also quickly fence off several roads from being traversed, thereby channeling possible routes away from undesirable parts of the street network.

Two maps demonstrate how a line barrier affects finding a route between two stops.
The map on the left displays the shortest path between two stops. The map on the right shows the shortest path when several streets are blocked by a line barrier.

The line_barriers parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url—Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either the features or url property must be specified.
  • spatialReference—Specifies the spatial reference for the geometries of the barriers. This property is not required if the coordinate values are in the same spatial reference as your network dataset. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See geographic coordinate systems and projected coordinate systems to look up WKID values.
  • features—Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a line barrier and contains the following properties:

  • geometry—Specifies the barrier's geometry. The structure is based on an ArcGIS REST polyline object. A polyline contains an array of paths. Each path is represented as an array of points, and each point in the path is represented as an array of numbers containing x- and y-coordinate values at index 0 and 1, respectively.
  • attributes—Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for line_barriers

When specifying the line barriers, you can set name and barrier type properties for each using the following attributes:

  • Name

    The name of the barrier.

Syntax examples for line_barriers

Syntax for specifying line barriers using a JSON structure for features

{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "paths": [
          [
            [
              <x11>,
              <y11>
            ],
            [
              <x12>,
              <y12>
            ]
          ],
          [
            [
              <x21>,
              <y21>
            ],
            [
              <x22>,
              <y22>
            ]
          ]
        ]
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
		  {
      "geometry": {
        "paths": [
          [
            [
              <x11>,
              <y11>
            ],
            [
              <x12>,
              <y12>
            ]
          ],
          [
            [
              <x21>,
              <y21>
            ],
            [
              <x22>,
              <y22>
            ]
          ]
        ]
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ] 
}

Syntax for specifying line barriers using a URL returning a JSON response

{
  "url": "<url>"
}

Examples for line_barriers

Example one: Specifying line barriers using a JSON structure in the Web Mercator spatial reference

The example shows how to add two lines as line barriers to restrict travel on the streets intersected by the lines. Barrier 1 is a single-part line feature made up of two points. Barrier 2 is a two-part line feature whose first part is made up of three points and whose second part is made up of two points. The barrier geometries are in the Web Mercator spatial reference and not in the same spatial reference as the network dataset. Hence, the spatialReference property is required.

{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "paths": [
          [
            [
              -10804823.397,
              3873688.372
            ],
            [
              -10804811.152,
              3873025.945
            ]
          ]
        ]
      },
      "attributes": {
        "Name": "Barrier 1"
      }
    },
    {
      "geometry": {
        "paths": [
          [
            [
              -10804823.397,
              3873688.372
            ],
            [
              -10804807.813,
              3873290.911
            ],
            [
              -10804811.152,
              3873025.945
            ]
          ],
          [
            [
              -10805032.678,
              3863358.76
            ],
            [
              -10805001.508,
              3862829.281
            ]
          ]
        ]
      },
      "attributes": {
        "Name": "Barrier 2"
      }
    }
  ]
}

Example two: Specifying line barriers using a URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
  "url": "https://machine.domain.com/webadaptor/rest/services/Network/USA/MapServer/6/query?where=1%3D1&returnGeometry=true&f=json"
}

polygon_barriers

Use this parameter to specify polygons that either prohibit travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons.

The polygon_barriers parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url—Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either the features or url property must be specified.
  • spatialReference—Specifies the spatial reference for the geometries of barriers. This property is not required if the coordinate values are in the same spatial reference as your network dataset. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See geographic coordinate systems and projected coordinate systems to look up WKID values.
  • features—Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a polygon barrier and contains the following properties:

  • geometry—Specifies the barrier's geometry. The structure is based on an ArcGIS REST polygon object. A polygon contains an array of rings. The first point of each ring is always the same as the last point. Each point in the ring is represented as an array of numbers containing x- and y-coordinate values at index 0 and 1, respectively.
  • attributes—Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for polygon_barriers

When specifying the polygon barriers, you can set properties for each, such as its name or barrier type, using the following attributes:

  • Name

    The name of the barrier.

  • BarrierType

    Specifies whether the barrier restricts travel completely or scales the cost (such as time or distance) for traveling through it. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):

    • 0 (Restriction)—Prohibits traveling through any part of the barrier. The barrier is referred to as a restriction polygon barrier since it prohibits traveling on streets intersected by the barrier. One use of this type of barrier is to model floods covering areas of the street that make traveling on those streets impossible.
      Two maps demonstrate how a restriction polygon barrier affects finding a route between two stops.
      The left side depicts the shortest path between two stops. On the right, a polygon barrier blocks flooded streets, so the shortest path between the same two stops is different.
    • 1 (Scaled Cost)—Scales the time or distance required to travel the underlying streets by a factor specified using the ScaledTimeFactoror ScaledDistanceFactor field. If the streets are partially covered by the barrier, the travel time or distance is apportioned and then scaled. For example, a factor of 0.25 would mean that travel on underlying streets is expected to be four times faster than normal. A factor of 3.0 would mean it is expected to take three times longer than normal to travel on underlying streets. This barrier type is referred to as a scaled-cost polygon barrier. It might be used to model storms that reduce travel speeds in specific regions.
      Two maps demonstrate how a scaled-cost polygon barrier affects finding a route between two stops.
      The map on the left shows a route that goes through inclement weather without regard for the effect that poor road conditions have on travel time. On the right, a scaled polygon barrier doubles the travel time of the roads covered by the storm. Notice the route still passes through the southern tip of the storm since it's quicker to spend more time driving slowly through a small part of the storm rather than driving completely around it. The service uses the modified travel time in calculating the best route; furthermore, the modified travel time is reported as the total travel time in the response.
  • ScaledTimeFactor

    This is the factor by which the travel time of the streets intersected by the barrier is multiplied. The field value must be greater than zero.

    This field is applicable only for scaled-cost barriers and only if the travel mode used for the analysis uses an impedance attribute that is time based.

  • ScaledDistanceFactor

    This is the factor by which the distance of the streets intersected by the barrier is multiplied. The field value must be greater than zero.

    This field is applicable only for scaled-cost barriers and only if the travel mode used for the analysis uses an impedance attribute that is distance based.

  • ScaledCostFactor

    This is the factor by which the cost of the streets intersected by the barrier is multiplied. The field value must be greater than zero.

    This field is applicable only for scaled-cost barriers and only if the travel mode used for the analysis uses an impedance attribute that is neither time based nor distance based.

Syntax examples for polygon_barriers

Syntax for specifying polygon barriers using a JSON structure for features

{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>    
  }
  "features": [
    {
      "geometry": {
        "rings": [
          [
            [
              <x11>,
              <y11>
            ],
            [
              <x12>,
              <y12>
            ],
            [
              <x11>,
              <y11>
            ]
          ],
          [
            [
              <x21>,
              <y21>
            ],
            [
              <x22>,
              <y22>
            ],
            [
              <x21>,
              <y21>
            ]
          ]
        ]
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "rings": [
          [
            [
              <x11>,
              <y11>
            ],
            [
              <x12>,
              <y12>
            ],
            [
              <x11>,
              <y11>
            ]
          ],
          [
            [
              <x21>,
              <y21>
            ],
            [
              <x22>,
              <y22>
            ],
            [
              <x21>,
              <y21>
            ]
          ]
        ]
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ]
}

Syntax for specifying polygon barriers using a URL returning a JSON response

{
  "url": "<url>"
}

Examples for polygon_barriers

Example one: Specifying polygon barriers using a JSON structure

The example shows how to add two polygons as barriers. The first polygon, named Flood zone, is a restriction polygon barrier that prohibits travel on the underlying streets. The polygon is a single-part polygon feature made up of four points. The second polygon, named Severe weather zone, is a scaled-cost polygon barrier that increases the travel time on underlying streets to one-third of the original value. The polygon is a two-part polygon feature. Both parts are made up of four points.

The barrier geometries are in the same spatial reference as your network dataset. Hence, the spatialReference property is not required.

{
  "features": [
    {
      "geometry": {
        "rings": [
          [
            [
              -97.0634,
              32.8442
            ],
            [
              -97.0554,
              32.84
            ],
            [
              -97.0558,
              32.8327
            ],
            [
              -97.0638,
              32.83
            ],
            [
              -97.0634,
              32.8442
            ]
          ]
        ]
      },
      "attributes": {
        "Name": "Flood zone",
        "BarrierType": 0
      }
    },
    {
      "geometry": {
        "rings": [
          [
            [
              -97.0803,
              32.8235
            ],
            [
              -97.0776,
              32.8277
            ],
            [
              -97.074,
              32.8254
            ],
            [
              -97.0767,
              32.8227
            ],
            [
              -97.0803,
              32.8235
            ]
          ],
          [
            [
              -97.0871,
              32.8311
            ],
            [
              -97.0831,
              32.8292
            ],
            [
              -97.0853,
              32.8259
            ],
            [
              -97.0892,
              32.8279
            ],
            [
              -97.0871,
              32.8311
            ]
          ]
        ]
      },
      "attributes": {
        "Name": "Severe weather zone",
        "BarrierType": 1,
        "ScaledTimeFactor": 3
      }
    }
  ]
}

Example two: Specifying a polygon barrier using a URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
  "url": "https://machine.domain.com/webadaptor/rest/services/Network/USA/MapServer/7/query?where=1%3D1&returnGeometry=true&f=json"
}

uturn_at_junctions

Use this parameter to restrict or allow the analysis to make U-turns at junctions.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when travel_mode is set to any other value than Custom. The default value for travel_mode is Driving, so unless you set travel_mode to a different value, this parameter value will be overridden.

In order to understand the available parameter values, consider for a moment that a junction is a point where only two streets intersect each other. If three or more streets intersect at a point, it is called as an intersection. A cul-de-sac is a dead-end. The parameter can have the following values:

Parameter ValuesDescription

Allowed

U-turns are permitted everywhere. Allowing U-turns implies that the vehicle can turn around at a junction or intersection and double back on the same street.

U-turns are allowed
U-turns are permitted at junctions with any number of adjacent streets.

Allowed only at Intersections and Dead Ends

U-turns are prohibited at junctions where exactly two adjacent streets meet.

U-turns allowed only at intersections and dead-ends
U-turns are permitted only at intersections or dead ends.

Allowed only at Dead Ends

U-turns are prohibited at all junctions and interesections and are permitted only at dead ends.

U-turns allowed only at dead-ends
U-turns are permitted only at dead ends.

Not Allowed

U-turns are prohibited at all junctions, intersections, and dead-ends. Note that even when this parameter value is chosen, a route can still make U-turns at stops. If you wish to prohibit U-turns at a stop, you can set its CurbApproach property to the appropriate value (3).

The default value for this parameter is Allowed only at Intersections and Dead Ends.

use_hierarchy

Specify whether hierarchy should be used when finding the shortest paths.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when travel_mode is set to any other value than Custom. The default value for travel_mode is Driving, so unless you set travel_mode to a different value, this parameter value will be overridden.

  • true—Use hierarchy when measuring between points. This is the default value. When hierarchy is used, the tool prefers higher-order streets (such as freeways) to lower-order streets (such as local roads), and can be used to simulate the driver preference of traveling on freeways instead of local roads even if that means a longer trip. This is especially true when finding routes to faraway locations, because drivers on long-distance trips tend to prefer traveling on freeways where stops, intersections, and turns can be avoided. Using hierarchy is computationally faster, especially for long-distance routes, since the tool can determine the best route from a relatively smaller subset of streets.

  • false—Do not use hierarchy when measuring between stops. If hierarchy is not used, the tool considers all the streets and doesn't prefer higher-order streets when finding the route. This is often used when finding short-distance routes within a city.

Caution:

The service automatically reverts to using hierarchy if the straight-line distance between the stops is greater than 50 miles (80.46 kilometers), even if you have specified to find the route without using hierarchy.

restrictions

Use this parameter to specify which restrictions should be honored by the service. A restriction represents a driving preference or requirement. In most cases, restrictions cause roads or pathways to be prohibited, but they can also cause them to be avoided or preferred. For instance, using an Avoid Toll Roads restriction will result in a route that will include toll roads only when it is absolutely required to travel on toll roads in order to visit a stop. Height Restriction makes it possible to route around any clearances that are lower than the height of your vehicle. If you are carrying corrosive materials on your vehicle, using the Any Hazmat Prohibited restriction prevents hauling the materials along roads where it is marked as illegal to do so.

Caution:

The value for this parameter, regardless of whether you rely on the default or explicitly set a value, is used in the analysis only when the travel_mode parameter is set to Custom.

Note:

Some restrictions are supported only in certain countries. If you specify restriction names that are not available in the country where your input points are located, the service ignores the invalid restrictions and returns warning messages indicating the names for the restrictions that were not considered when performing the analysis.

Note:

Sometimes you need to specify an additional value, the restriction attribute parameter, on a restriction to get the intended results. This value needs to be associated with the restriction name and a restriction parameter using attribute_parameter_values.

The service supports the restriction names listed in the following table:

Restriction NameDescription

Any Hazmat Prohibited

The result will exclude roads where transporting any kind of hazardous material is prohibited.

Avoid Carpool Roads

The result will avoid roads designated exclusively for carpool (high-occupancy) vehicles.

Avoid Express Lanes

The result will avoid roads designated as express lanes.

Avoid Ferries

The result will avoid ferries.

Avoid Gates

The result will avoid roads where there are gates, such as keyed-access or guard-controlled entryways.

Avoid Limited Access Roads

The result will avoid roads designated as limited-access highways.

Avoid Private Roads

The result will avoid roads that are not publicly owned and maintained.

Avoid Roads Unsuitable for Pedestrians

The result will avoid roads that are unsuitable for pedestrians.

Avoid Stairways

The result will avoid all stairways on a pedestrian suitable route.

Avoid Toll Roads

The result will avoid toll roads.

Avoid Toll Roads for Trucks

The result will avoid all toll roads for trucks

Avoid Truck Restricted Roads

The result will avoid roads where trucks are not allowed except when making deliveries.

Avoid Unpaved Roads

The result will avoid roads that are not paved (for example, dirt, gravel, etc.).

Axle Count Restriction

The result will not include roads where trucks with the specified number of axles are prohibited. The number of axles can be specified using the Number of Axles restriction parameter.

Driving a Bus

The result will exclude roads where buses are prohibited. Using this restriction also ensures the route will honor one-way streets.

Driving a Taxi

The result will exclude roads where taxis are prohibited. Using this restriction also ensures the route will honor one-way streets.

Driving a Truck

The result will exclude roads where trucks are prohibited. Using this restriction also ensures the route will honor one-way streets.

Driving an Automobile

The result will exclude roads where automobiles are prohibited. Using this restriction also ensures the route will honor one-way streets.

Driving an Emergency Vehicle

The result will exclude roads where emergency vehicles are prohibited. Using this restriction also ensures the route will honor one-way streets.

Height Restriction

The result will exclude roads where the vehicle height exceeds the maximum allowed height for the road. The vehicle height can be specified using the Vehicle Height (meters) restriction parameter.

Kingpin to Rear Axle Length Restriction

The result will exclude roads where the vehicle kingpin-to-rear-axle length exceeds the maximum allowed for the road. The vehicle's length between the vehicle kingpin and the rear axle can be specified using the Vehicle Kingpin to Rear Axle Length (meters) restriction parameter.

Length Restriction

The result will exclude roads where the vehicle length exceeds the maximum allowed length for the road. The vehicle length can be specified using the Vehicle Length (meters) restriction parameter.

Preferred for Pedestrians

The result prefers paths designated for pedestrians.

Riding a Motorcycle

The result will exclude roads where motorcycles are prohibited. Using this restriction also ensures the route will honor one-way streets.

Roads Under Construction Prohibited

The result will exclude roads that are under construction.

Semi or Tractor with One or More Trailers Prohibited

The result will exclude roads where semis or tractors with one or more trailers are prohibited.

Single Axle Vehicles Prohibited

The result will exclude roads where vehicles with single axles are prohibited.

Tandem Axle Vehicles Prohibited

The result will exclude roads where vehicles with tandem axles are prohibited.

Through Traffic Prohibited

The result will exclude roads where through traffic (non-local) is prohibited.

Truck with Trailers Restriction

The result will exclude roads where trucks with the specified number of trailers on the truck are prohibited. The number of trailers on the truck can be specified using the Number of Trailers on Truck restriction parameter.

Use Preferred Hazmat Routes

The result will prefer roads designated for transporting any kind of hazardous materials.

Use Preferred Truck Routes

The result will prefer roads designated as truck routes, such as the roads that are part of the national network as specified by the National Surface Transportation Assistance Act in the United States, or roads that are designated as truck routes by the state or province, or or roads in an area that are generally more suitable for trucks.

Walking

The result will exclude roads where pedestrians are prohibited.

Weight Restriction

The result will exclude roads where the vehicle weight exceeds the maximum allowed weight for the road. The vehicle weight can be specified using the Vehicle Weight (kilograms) restriction parameter.

Weight per Axle Restriction

The result will exclude roads where the vehicle's weight per axle exceeds the maximum allowed for the road. The vehicle's weight per axle can be specified using the Vehicle Weight per Axle (kilograms) restriction parameter.

Width Restriction

The result will roads where the vehicle width exceeds the maximum allowed for the road. The vehicle width can be specified using the Vehicle Width(meters) restriction parameter.

Legacy:

The Driving a Delivery Vehicle restriction attribute is no longer available. The service will ignore this restriction since it is invalid. To achieve similar results, use the Driving a Truck restriction attribute along with the Avoid Truck Restricted Roads restriction attribute.

The restrictions parameter value is specified as a list of restriction names. A value of null indicates that no restrictions should be used when finding the best route, but only when travel_mode is set to Custom. The default value for this parameter is demonstrated in the example below:

restrictions=[Avoid Carpool Roads, Avoid Express Lanes, Avoid Gates, Avoid Private Roads, Avoid Unpaved Roads, Driving an Automobile, Roads Under Construction Prohibited, Through Traffic Prohibited]

Example for restrictions

restrictions=[Driving a Truck,Height Restriction,Length Restriction]

attribute_parameter_values

Use this parameter to specify additional values required by an attribute or restriction, such as to specify whether the restriction prohibits, avoids, or prefers travel on restricted roads. If the restriction is meant to avoid or prefer roads, you can further specify the degree to which they are avoided or preferred using this parameter.

Caution:

The value for this parameter, regardless of whether you rely on the default or explicitly set a value, is used in the analysis only when the travel_mode parameter is set to Custom.

The attributes_parameter_values parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents an attribute parameter and contains the following properties:

  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.
Note:

The JSON structure for the attribute_parameter_values parameter does not have a geometry property.

Attributes for attribute_parameter_values

The attribute_parameter_values parameter can be specified with the following attributes:

  • AttributeName: Lists the name of the restriction.
  • ParameterName: Lists the name of the parameter associated with the restriction. A restriction can have one or more ParameterName values based on its intended use, which implies you may need multiple attribute_parameter_values parameters for a single attribute name.
  • ParameterValue: The value for the ParameterName that is used by the service when evaluating the restriction.

Note:

In most cases, the attribute_parameter_values parameter is dependent on the restrictions parameter. The ParameterValue specified as part of attribute_parameter_values is applicable only if the restriction name is specified as the value for the restrictions parameter.

When specifying the attribute_parameter_values parameter, each restriction (listed as AttributeName) has a ParameterName value, Restriction Usage, that specifies whether the restriction prohibits, avoids, or prefers travel on the roads associated with the restriction and the degree to which the roads are avoided or preferred.

The Restriction Usage ParameterName can be assigned any of the following string values or their equivalent numeric values listed within the parentheses:

  • PROHIBITED (-1)—Travel on the roads using the restriction is completely prohibited.
  • AVOID_HIGH (5)—It is very unlikely for the service to include, in the results, roads that are associated with the restriction.
  • AVOID_MEDIUM (2)—It is unlikely for the service to include, in the results, roads that are associated with the restriction.
  • AVOID_LOW (1.3)—It is somewhat unlikely for the service to include, in the results, roads that are associated with the restriction.
  • PREFER_LOW (0.8)—It is somewhat likely for the service to include, in the results, results roads that are associated with the restriction.
  • PREFER_MEDIUM(0.5)—It is likely for the service to include, in the results, roads that are associated with the restriction.
  • PREFER_HIGH (0.2)—It is very likely for the service to include, in the results, roads that are associated with the restriction.

In most cases, you can use the default value, PROHIBITED, for Restriction Usage if the restriction is dependent on a physical vehicle characteristic, such as vehicle height. However, in some cases, the value for Restriction Usage depends on your travel preferences. For example, the Avoid Toll Roads restriction has the default value of AVOID_MEDIUM for the Restriction Usage parameter. This means that when the restriction is used, the service will try to route around toll roads when it can. AVOID_MEDIUM also indicates how important it is to avoid toll roads when finding the best route; it has a medium priority. Choosing AVOID_LOW would put lower importance on avoiding tolls; choosing AVOID_HIGH instead would give it a higher importance and thus make it more acceptable for the service to generate longer routes to avoid tolls. Choosing PROHIBITED would entirely disallow travel on toll roads, making it impossible for a route to travel on any portion of a toll road. Keep in mind that avoiding or prohibiting toll roads, and thus avoiding toll payments, is the objective for some; in contrast, others prefer to drive on toll roads because avoiding traffic is more valuable to them than the money spent on tolls. In the latter case, you would choose PREFER_LOW, PREFER_MEDIUM, or PREFER_HIGH as the value for Restriction Usage. The higher the preference, the farther the service will go out of its way to travel on the roads associated with the restriction.

The following table lists the restriction names and the default restriction parameter values for all the restrictions. The default value for the attribute_parameter_values parameter is the JSON structure containing all the rows from the below table.

Tip:

If you want to use the default value for any restriction, AttributeName, ParameterName, and ParameterValue do not have to be specified as part of the attribute_parameter_values parameter.

AttributeNameParameterNameParameterValue

Any Hazmat Prohibited

Restriction Usage

PROHIBITED

Avoid Carpool Roads

Restriction Usage

PROHIBITED

Avoid Express Lanes

Restriction Usage

PROHIBITED

Avoid Ferries

Restriction Usage

AVOID_MEDIUM

Avoid Gates

Restriction Usage

AVOID_MEDIUM

Avoid Limited Access Roads

Restriction Usage

AVOID_MEDIUM

Avoid Private Roads

Restriction Usage

AVOID_MEDIUM

Avoid Roads Unsuitable for Pedestrians

Restriction Usage

AVOID_HIGH

Avoid Stairways

Restriction Usage

AVOID_HIGH

Avoid Toll Roads

Restriction Usage

AVOID_MEDIUM

Avoid Toll Roads for Trucks

Restriction Usage

AVOID_MEDIUM

Avoid Truck Restricted Roads

Restriction Usage

AVOID_HIGH

Avoid Unpaved Roads

Restriction Usage

AVOID_HIGH

Axle Count Restriction

Number of Axles

0

Restriction Usage

PROHIBITED

Driving a Bus

Restriction Usage

PROHIBITED

Driving a Taxi

Restriction Usage

PROHIBITED

Driving a Truck

Restriction Usage

PROHIBITED

Driving an Automobile

Restriction Usage

PROHIBITED

Driving an Emergency Vehicle

Restriction Usage

PROHIBITED

Height Restriction

Restriction Usage

PROHIBITED

Vehicle Height (meters)

0

Kingpin to Rear Axle Length Restriction

Restriction Usage

PROHIBITED

Vehicle Kingpin to Rear Axle Length (meters)

0

Length Restriction

Restriction Usage

PROHIBITED

Vehicle Length (meters)

0

Preferred for Pedestrians

Restriction Usage

PREFER_LOW

Riding a Motorcycle

Restriction Usage

PROHIBITED

Roads Under Construction Prohibited

Restriction Usage

PROHIBITED

Semi or Tractor with One or More Trailers Prohibited

Restriction Usage

PROHIBITED

Single Axle Vehicles Prohibited

Restriction Usage

PROHIBITED

Tandem Axle Vehicles Prohibited

Restriction Usage

PROHIBITED

Through Traffic Prohibited

Restriction Usage

AVOID_HIGH

Truck with Trailers Restriction

Restriction Usage

PROHIBITED

Number of Trailers on Truck

0

Use Preferred Hazmat Routes

Restriction Usage

PREFER_MEDIUM

Use Preferred Truck Routes

Restriction Usage

PREFER_HIGH

Walking

Restriction Usage

PROHIBITED

WalkTime

Walking Speed (km/h)

5

Weight Restriction

Restriction Usage

PROHIBITED

Vehicle Weight (kilograms)

0

Weight per Axle Restriction

Restriction Usage

PROHIBITED

Vehicle Weight per Axle (kilograms)

0

Width Restriction

Restriction Usage

PROHIBITED

Vehicle Width (meters)

0

Syntax example for attribute_parameter_values

Syntax for specifying attribute_parameter_values
{
    "features": [
        {
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>,
                "<field3>": <value13>

            }
        },
        {
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>,
                "<field3>": <value13>
            }
        }
    ] 
}

Example for attribute_parameter_values

Example: Specifying the vehicle height and weight and a high preference to use designated truck routes

This example shows how to specify the height and weight of the vehicle for use with the height and weight restrictions respectively along with a high preference to include designated truck routes. This results in a route that does not include any roads where the clearance under overpasses or through tunnels is less than the vehicle height. The results will also not include any roads with load limited bridges or local roads that prohibit heavy vehicles if the vehicle weight exceeds the maximum permissible weight. However, the route will include as many roads as possible that are designated as preferred truck routes.

Note that the Restriction Usage ParameterName for the Height Restriction and the Weight Restriction restrictions are not specified since we want to use the default value of PROHIBITED for these restriction parameters.

attribute_parameter_values=
{
    "features": [
        {
            "attributes": {
                "AttributeName": "Height Restriction",
                "ParameterName": "Vehicle Height (meters)",
                "ParameterValue": 4.12
            }
        },
        {
            "attributes": {
                "AttributeName": "Weight Restriction",
                "ParameterName": "Vehicle Weight (kilograms)",
                "ParameterValue": 36287
            }
        },
        {
            "attributes": {
                "AttributeName": "Use Preferred Truck Routes",
                "ParameterName": "Restriction Usage",
                "ParameterValue": "PREFER_HIGH"
            }
        }
    ]
}

impedance

Specify the impedance, which is a value that represents the effort or cost of traveling along road segments or on other parts of the transportation network.

Travel time is an impedance; a car may take one minute to travel a mile along an empty road. Travel times can vary by travel mode—a pedestrian may take more than 20 minutes to walk the same mile, so it is important to choose the right impedance for the travel mode you are modeling.

Travel distance can also be an impedance; the length of a road in kilometers can be thought of as impedance. Travel distance in this sense is the same for all modes—a kilometer for a pedestrian is also a kilometer for a car. (What may change is the pathways on which the different modes are allowed to travel, which affects distance between points, and this is modeled by travel mode settings.)

Caution:

The value you provide for this parameter is ignored unless travel_mode is set to Custom, which is the default value.

Choose from the following impedance values:

  • TravelTime—takes advantage of historical and live traffic data and is good for modeling the time it takes automobiles to travel along roads at a specific time of the day using live traffic speed data where available. When using TravelTime, you can optionally specify the TravelTime::Vehicle Maximum Speed (km/h) attribute parameter to specify the physical limitation of the speed the vehicle is capable of traveling.
  • Minutes—does not use live traffic data but uses the historical average speeds for automobiles.
  • TruckTravelTime—takes advantage of historical and live traffic data, but caps the speed to the posted truck speed limit. This is good for modeling the time it takes for the trucks to travel along roads at a specific time. When using TruckTravelTime, you can optionally specify the TruckTravelTime::Vehicle Maximum Speed (km/h) attribute parameter to specify the physical limitation of the speed the truck is capable of traveling.
  • TruckMinutes—does not use live traffic data but uses the smaller of the historical average speeds for automobiles and the posted speed limits for trucks.
  • WalkTime—defaults to a speed of 5 km/hr on all roads and paths, but this can be configured through the WalkTime::Walking Speed (km/h) attribute parameter.
  • Miles—Stores length measurements along roads in miles and can be used for performing analysis based on shortest distance.
  • Kilometers—Stores length measurements along roads in kilometers and can be used for performing analysis based on shortest distance.
  • TimeAt1KPH—defaults to a speed of 1 km/hr on all roads and paths. The speed cannot be changed using any attribute parameters.

If you choose a time-based impedance, such as TravelTime, TruckTravelTime, Minutes, TruckMinutes, or WalkTime, the measurement_units parameter must be set to a time-based value; if you choose a distance-based impedance such as Miles, Kilometers, the measurement_units must be distance-based.

Legacy:

Drive Time, Truck Time, Walk Time, and Travel Distance impedance values are no longer supported and will be removed in a future release. If you use one of these values, the tool uses the value of the time_impedance parameter for time-based values or distance_impedance parameter for distance-based values.

origin_destination_line_shape

Specify the shape of the line feature connecting each origin-destination pair in the output matrix. The resulting lines of an origin-destination cost matrix can be represented with either straight-line geometry or no geometry at all. In both cases, the route is always computed along the street network by minimizing the travel time or the travel distance, never using the straight-line distance between origins and destinations.

The parameter accepts one of the following values:

  • Straight Line—Straight lines connect origins and destinations.
  • None (default)—Do not return any shapes for the lines that connect origins and destinations. This is useful when you have a large number of origins and destinations and are interested only in the origin-destination cost matrix table (and not the output line shapes).

save_output_network_analysis_layer

Use this parameter to specify if the service should save the analysis settings as a network analysis layer file. You cannot directly work with this file even when you open the file in an ArcGIS Desktop application like ArcMap. It is meant to be sent to Esri Technical Support in order to diagnose the quality of results returned from the service.

  • true—Saves network analysis layer file. The file can be downloaded from the URL provided as part of the output_network_analysis_layer parameter.

  • false—Don't save network analysis layer file. This is the default value.

overrides

Specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems.

The value for this parameter needs to be specified in JavaScript Object Notation (JSON). The values can be either a number, Boolean, or a string.

{
"overrideSetting1" : "value1", 
"overrideSetting2" : "value2"
}

The default value for this parameter is no value, which indicates not to override any solver settings.

Overrides are advanced settings that should be used only after careful analysis of the results obtained before and after applying the settings. A list of supported override settings for each solver and their acceptable values can be obtained by contacting Esri Technical Support.

time_impedance

The time-based impedance, which is a value that represents the travel time along road segments or on other parts of the transportation network.

Note:

If the impedance for the travel mode, as specified using the Impedance parameter,

is time based, the value for Time Impedance and Impedance parameters must be identical. Otherwise, the service will return an error.

distance_impedance

The distance-based impedance, which is a value that represents the travel distance along road segments or on other parts of the transportation network.

Note:

If the impedance for the travel mode, as specified using the Impedance parameter,

is distance based, the value for Distance Impedance and Impedance parameters must be identical. Otherwise, the service will return an error.

output_format

Specifies the format in which the output features will be created.

Choose from the following formats:

  • Feature Set—The output features will be returned as feature classes and tables. This is the default.
  • JSON File—The output features will be returned as a compressed file containing the JSON representation of the outputs. When this option is specified, the output is a single file (with a .zip extension) that contains one or more JSON files (with a .json extension) for each of the outputs created by the service.
  • GeoJSON File—The output features will be returned as a compressed file containing the GeoJSON representation of the outputs. When this option is specified, the output is a single file (with a .zip extension) that contains one or more GeoJSON files (with a .geojson extension) for each of the outputs created by the service.
  • CSV File—The output features are returned as a compressed file containing a comma-separated value (CSV) representation of the outputs. When this option is specified, the output is a single file (with a .zip extension) that contains one or more CSV files (with a .csv extension) for each of the outputs created by the service.

Tip:

Specifying file based output format, such asJSON File, is useful when you are calling the service using the REST endpoint of the service. In such cases, returning all the outputs as a single file allows you to download large results that can be generated by the service. For example, if you are working with GenerateOriginDestinationCostMatrix service and you generate a travel matrix with 1,000,000 records, returning such a large output as a Feature Set can cause the service to fail since the service will try to send the entire output in a single attempt. With a file based output, the service sends the output in multiple chunks reducing the possibility of timeouts when returning the outputs.

env:outSR

Specify the spatial reference of the geometries, such as the output origins and destinations or the lines in the output matrix returned by the service.

The parameter value can be specified as a well-known ID (WKID) for the spatial reference. If env:outSR is not specified, the geometries are returned in the default spatial reference, WGS84. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.

Many of the basemaps provided by ArcGIS Online are in the Web Mercator spatial reference (WKID 102100). Specifying env:outSR=102100 returns the geometries in the Web Mercator spatial reference, which can be drawn on top of the basemaps.

Output parameters

After successfully executing, the service returns the lines connecting each origin-destination pair, the output origins, the output destinations, and the status of whether the analysis was successful. This information is output in the following output parameters:

Output_Origin_Destination_Lines

Access the information about the resulting routes from the origins to the destinations. The routes include data about the total travel time and the travel distance between a given origin-destination pair. The line geometries connect an origin-destination pair using a straight line if the origin_destination_line_shape parameter was specified as Straight Line and are returned in the spatial reference specified as the env:outSR parameter.

The following table provides descriptions of the fields that are returned for each route:

FieldDescription

DestinationRank

The rank of the destination among all destinations found for the associated origin. The destination that is closest to the origin has a rank of 1.

Total_Time

The travel time along the street network between the associated origin and destination.

The value is in the units specified by the time_units parameter.

Total_Distance

The travel distance along the street network between the associated origin and destination.

The value is in the units specified by the distance_units parameter.

Total_Other

The travel cost in unknown units along the street network between the associated origin and destination.

This field is included only when the travel mode used for the analysis has an impedance attribute that is neither time based nor distance based.

OriginOID

The ObjectID value of the corresponding input origin feature. This can be used to join additional attributes between the input origins and the origin destination lines.

OriginName

The name of the corresponding input origin feature. This field is included only if the Name field is specified on input origins and at least one of the origins has a valid name. If the name is not specified for some of the origins, an automatically generated name prefixed with Location is created for those origins.

DestinationOID

The object ID value of the corresponding input destination feature. This can be used to join additional attributes between the input destinations and the origin destination lines.

DestinationName

The name of the corresponding input destination feature. This field is included only if the Name field is specified on input destinations and at least one of the destinations has a valid name. If the name is not specified for some of the destinations, an automatically generated name prefixed with Location is created for those destinations.

Output_Origins

Access the origins that participated in the analysis. It provides information about origins that could not be included in the analysis as well as the total number of destinations that could be reached from a given origin. The origin geometries are returned in the spatial reference specified as the env:outSR parameter.

The following table describes the attributes of the output origins:

FieldDescription

Name

The name of the origin. If the name of the origin was specified as part of the Name field, this field has the same value. Otherwise, it includes an automatically generated value prefixed with Location.

TargetDestinationCount

The value of the TargetDestinationCount field in the corresponding input origins.

SourceID

The numeric identifier of the source feature class containing the source feature on which the network is located.

SourceOID

The numeric identifier of the source feature in the source feature class.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. For example, a value of 0.47 indicates that the point is positioned 47 percent from the start of the source line feature.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. The field can have one of the two possible values. A value of 1 indicates that the point is on the right side of the line feature, and a value of 2 indicates that the point is on the left side of the line feature.

CurbApproach

The value of the CurbApproach field in the corresponding input origins.

Status

Indicates how the corresponding input origin was evaluated in the analysis. The possible values are the following:

  • 0 (OK)—The origin was successfully located on the transportation network and analyzed.
  • 1 (Not Located)—The origin was not included in the analysis since a traversable road was not found within the maximum search distance from the origin.
  • 3 (Elements not traversable)—The network element that the origin is on is not traversable. This can occur when the network element is restricted by a restriction attribute.
  • 4 (Invalid Field Values)—Field values fall outside a range or coded-value domain. For example, a negative number may exist where positive numbers are required.
  • 5 (Not Reached)—The origin could not find routes to any destinations due to constraints; for example, a curb approach is set so that a vehicle must travel in the wrong direction on a one-way street to reach the destination, or no destinations are within the specified travel time or travel distance based cutoff.
  • 7 (Not located on closest)—The closest network location to the origin is not traversable because of a restriction or barrier, so the origin has been located on the closest traversable network feature instead.

SnapX

The x-coordinate value for the computed network location.

SnapY

The y-coordinate value for the computed network location.

SnapZ

The z-coordinate value for the computed network location.

The field has a nonzero value only when the input network dataset supports connectivity based on z-coordinate values of the network sources.

DistanceToNetworkInMeters

The distance, in meters, between the location of the point feature and its computed network location.

Cutoff

The value of the Cutoff field in the corresponding input origins.

OriginOID

The ObjectID value of the corresponding input origin feature. This can be used to join additional attributes from the input origins.

DestinationCount

A count of destinations that were reached from the origin.

Bearing

The values for this field are copied from the Bearing field on the input facilities.

BearingTol

The values for this field are copied from the BearingTol field on the input facilities.

NavLatency

The values for this field are copied from the NavLatency field on the input facilities.

Output_Destinations

Access the destinations that participated in the analysis. It provides information about destinations that could not be included in the analysis as well as the total number of origins that were able to reach a given destination. The destination geometries are returned in the spatial reference specified as the env:outSR parameter.

The following table describes the attributes of the output destinations:

FieldDescription

Name

The name of the destination. If the name for the origin was specified as part of the Name field, this field has the same value. Otherwise, it includes an automatically generated value prefixed with Location.

SourceID

The numeric identifier of the source feature class containing the source feature on which the network is located.

SourceOID

The numeric identifier of the source feature in the source feature class.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. For example, a value of 0.47 indicates that the point is positioned 47 percent from the start of the source line feature.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. The field can have one of the two possible values. A value of 1 indicates that the point is on the right side of the line feature, and a value of 2 indicates that the point is on the left side of the line feature.

CurbApproach

The value of the CurbApproach field in the corresponding input destinations.

Status

Indicates how the corresponding input destination was evaluated in the analysis. The possible values are the following:

  • 0 (OK)—The destination was successfully located on the transportation network and analyzed.
  • 1 (Not Located)—The destination was not included in the analysis since a traversable road was not found within the maximum search distance from the destination.
  • 3 (Elements not traversable)—The network element that the destination is on is not traversable. This can occur when the network element is restricted by a restriction attribute.
  • 4 (Invalid Field Values)—Field values fall outside a range or coded-value domain. For example, a negative number may exist where positive numbers are required.
  • 5 (Not Reached)—The origin could not find routes to any destinations due to constraints; for example, a curb approach is set so that a vehicle must travel in the wrong direction on a one-way street to reach the destination, or no destinations are within the specified travel time or travel distance based cutoff.
  • 7 (Not located on closest)—The closest network location to the destination is not traversable because of a restriction or barrier, so the destination has been located on the closest traversable network feature instead.

SnapX

The x-coordinate value for the computed network location.

SnapY

The y-coordinate value for the computed network location.

SnapZ

The z-coordinate value for the computed network location.

The field has a nonzero value only when the input network dataset supports connectivity based on z-coordinate values of the network sources.

DistanceToNetworkInMeters

The distance, in meters, between the location of the point feature and its computed network location.

DestinationOID

The ObjectID value of the corresponding input destination feature. This can be used to join additional attributes from the input destinations.

OriginCount

The number of origins that reached the destination.

Bearing

The values for this field are copied from the Bearing field on the input facilities.

BearingTol

The values for this field are copied from the BearingTol field on the input facilities.

NavLatency

The values for this field are copied from the NavLatency field on the input facilities.

solve_succeeded

Determine whether the service was able to successfully generate the origin-destination cost matrix. The error messages for any failure can be obtained by making a request to get the status of the job.

The solve_succeeded parameter is returned as a JSON feature set with the following syntax:

{
  "paramName": "Solve_Succeeded",
  "dataType": "GPBoolean",
  "value": <true | false>
}

The following shows an example of the solve_succeeded parameter:

{
  "paramName": "Solve_Succeeded",
  "dataType": "GPBoolean",
  "value": true
}

Example usage

This service uses the asynchronous execution mode. The client must periodically check whether the service has finished execution and, once completed, get the result. While the service is executing, the application is available to do other things.

Caution:

The maximum time an application can use the Origin Destination Cost Matrix service is 1 hour (3,600 seconds). If your request does not complete within this time limit, it will time out and return a failure.

You can make a request to the Origin Destination Cost Matrix service using the following form:

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/submitJob?parameters

In this example, you will generate an origin-destination cost matrix between two origins and two destinations. The resulting origin-destination cost matrix will have four features.

The origins and destinations are in the same spatial reference as your network dataset, so the spatialReference property is not required.

Generate a travel cost matrix

Request to submit job

The first request submits a job and returns the job ID.

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/submitJob?origins={"features":[{"geometry":{"y":51.5254,"x":-0.1891},"attributes":{"Name":"Origin 1","TargetDestinationCount":2,"Cutoff":120,"CurbApproach":0}},{"geometry":{"y":51.5353,"x":-0.1744},"attributes":{"Name":"Origin 2","TargetDestinationCount":3,"Cutoff":90,"CurbApproach":0}}]}&destinations={"features":[{"geometry":{"y":51.5354,"x":-0.1991},"attributes":{"Name":"Destination 1","CurbApproach":0}},{"geometry":{"y":51.5458,"x":-0.1844},"attributes":{"Name":"Destination 2","CurbApproach":0}}]}&f=pjson&token=<yourToken>

JSON Response

{
  "jobId": "j5943d41e8b2c4de7a0aaca3283655a33",
  "jobStatus": "esriJobSubmitted"
}

Query job status

The job ID obtained from the response of the first request can be queried periodically to determine the status of the job.

Request to query job status

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/jobs/<jobID>?returnMessages=true&f=pjson&token=<yourToken>

JSON Response

{
  "jobId": "j5943d41e8b2c4de7a0aaca3283655a33",
  "jobStatus": "esriJobSucceeded",
  "results": {
    "Solve_Succeeded": {
      "paramUrl": "results/Solve_Succeeded"
    },
    "Output_Origin_Destination_Lines": {
      "paramUrl": "results/Output_Origin_Destination_Lines"
    },
    "Output_Origins": {
      "paramUrl": "results/Output_Origins"
    },
    "Output_Destinations": {
      "paramUrl": "results/Output_Destinations"
    }
  },
  "inputs": {
    "Origins": {
      "paramUrl": "inputs/Origins"
    },
    "Destinations": {
      "paramUrl": "inputs/Destinations"
    },
    "Travel_Mode": {
      "paramUrl": "inputs/Travel_Mode"
    },
    "Time_Units": {
      "paramUrl": "inputs/Time_Units"
    },
    "Distance_Units": {
      "paramUrl": "inputs/Distance_Units"
    },
    "Analysis_Region": {
      "paramUrl": "inputs/Analysis_Region"
    },
    "Number_of_Destinations_to_Find": {
      "paramUrl": "inputs/Number_of_Destinations_to_Find"
    },
    "Cutoff": {
      "paramUrl": "inputs/Cutoff"
    },
    "Time_of_Day": {
      "paramUrl": "inputs/Time_of_Day"
    },
    "Time_Zone_for_Time_of_Day": {
      "paramUrl": "inputs/Time_Zone_for_Time_of_Day"
    },
    "Point_Barriers": {
      "paramUrl": "inputs/Point_Barriers"
    },
    "Line_Barriers": {
      "paramUrl": "inputs/Line_Barriers"
    },
    "Polygon_Barriers": {
      "paramUrl": "inputs/Polygon_Barriers"
    },
    "UTurn_at_Junctions": {
      "paramUrl": "inputs/UTurn_at_Junctions"
    },
    "Use_Hierarchy": {
      "paramUrl": "inputs/Use_Hierarchy"
    },
    "Restrictions": {
      "paramUrl": "inputs/Restrictions"
    },
    "Attribute_Parameter_Values": {
      "paramUrl": "inputs/Attribute_Parameter_Values"
    },
    "Impedance": {
      "paramUrl": "inputs/Impedance"
    },
    "Origin_Destination_Line_Shape": {
      "paramUrl": "inputs/Origin_Destination_Line_Shape"
    }
  },
  "messages": []
}

Return the output origin-destination lines

Because the job succeeded, the travel time and travel distance between every origin-destination pair can be obtained using the output_origin_destination_lines output parameter. Since you did not specify any value for the origin_destination_line_shape parameter, the default value, None, was used by the service for this parameter. Hence, the features array in the output response does not have the geometry property.

Request to return origin-destination lines

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/jobs/<jobID>/results/output_origin_destination_lines?f=pjson&token=<yourToken>

JSON Response

{
  "paramName": "Output_Origin_Destination_Lines",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "OBJECTID",
        "type": "esriFieldTypeOID",
        "alias": "OBJECTID"
      },
      {
        "name": "DestinationRank",
        "type": "esriFieldTypeInteger",
        "alias": "Destination Rank"
      },
      {
        "name": "Total_Time",
        "type": "esriFieldTypeDouble",
        "alias": "Total Time (Minutes)"
      },
      { 
        "name": "Total_Distance",
        "type": "esriFieldTypeDouble",
        "alias": "Total Distance (Kilometers)"
      },
      {
        "name": "OriginName",
        "type": "esriFieldTypeString",
        "alias": "Origin Name",
        "length": 128
      },
      {
        "name": "OriginOID",
        "type": "esriFieldTypeInteger",
        "alias": "Origin OID"
      },
      {
        "name": "DestinationName",
        "type": "esriFieldTypeString",
        "alias": "Destination Name",
        "length": 128
      },
      {
        "name": "DestinationOID",
        "type": "esriFieldTypeInteger",
        "alias": "Destination OID"
      },
      {
        "name": "Shape_Length",
        "type": "esriFieldTypeDouble",
        "alias": "Shape_Length"
      }
    ],
    "features": [
      {
        "attributes": {
          "OBJECTID": 1,
          "DestinationRank": 1,
          "Total_Time": 6.2279130881726257,
          "Total_Distance": 2.4774838708418678,
          "OriginName": "Origin 1",
          "OriginOID": 1,
          "DestinationName": "Destination 1",
          "DestinationOID": 1,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "OBJECTID": 2,
          "DestinationRank": 2,
          "Total_Time": 9.0778785641163715,
          "Total_Distance": 3.723118842219868,
          "OriginName": "Origin 1",
          "OriginOID": 1,
          "DestinationName": "Destination 2",
          "DestinationOID": 2,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "OBJECTID": 3,
          "DestinationRank": 1,
          "Total_Time": 4.6095379183132064,
          "Total_Distance": 1.9294457981067437,
          "OriginName": "Origin 2",
          "OriginOID": 2,
          "DestinationName": "Destination 2",
          "DestinationOID": 2,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "OBJECTID": 4,
          "DestinationRank": 2,
          "Total_Time": 6.0035312672863181,
          "Total_Distance": 2.3148191217414382,
          "OriginName": "Origin 2",
          "OriginOID": 2,
          "DestinationName": "Destination 1",
          "DestinationOID": 1,
          "Shape_Length": 0
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

Return the output origins

The output origins can be obtained using the output_origins output parameter.

Request to return output origins

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/jobs/<jobID>/results/output_origins?f=pjson&token=<yourToken>

JSON Response

{
  "paramName": "Output_Origins",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPoint",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "OBJECTID",
        "type": "esriFieldTypeOID",
        "alias": "OBJECTID"
      },
      {
        "name": "Name",
        "type": "esriFieldTypeString",
        "alias": "Name",
        "length": 128
      },
      {
        "name": "TargetDestinationCount",
        "type": "esriFieldTypeInteger",
        "alias": "Target Destination Count"
      },
      {
        "name": "CurbApproach",
        "type": "esriFieldTypeInteger",
        "alias": "Curb Approach"
      },
      {
        "name": "Status",
        "type": "esriFieldTypeInteger",
        "alias": "Status"
      },
      {
        "name": "Cutoff",
        "type": "esriFieldTypeDouble",
        "alias": "Cutoff"
      },
      {
        "name": "OriginOID",
        "type": "esriFieldTypeInteger",
        "alias": "Origin OID"
      },
      {
        "name": "DestinationCount",
        "type": "esriFieldTypeInteger",
        "alias": "Destination Count"
      }
    ],
    "features": [
      {
        "attributes": {
          "OBJECTID": 1,
          "Name": "Origin 1",
          "TargetDestinationCount": 2,
          "CurbApproach": 0,
          "Status": 0,
          "Cutoff": 120,
          "OriginOID": 1,
          "DestinationCount": 2
        },
        "geometry": {
          "x": -0.18909999999993943,
          "y": 51.525400000000047
        }
      },
      {
        "attributes": {
          "OBJECTID": 2,
          "Name": "Origin 2",
          "TargetDestinationCount": 2,
          "CurbApproach": 0,
          "Status": 0,
          "Cutoff": 90,
          "OriginOID": 2,
          "DestinationCount": 2
        },
        "geometry": {
          "x": -0.17439999999993461,
          "y": 51.535300000000063
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

Return the output destinations

The output destinations can be obtained using the output_destinations output parameter.

Request to return output destinations

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/jobs/<jobID>/results/output_destinations?f=pjson&token=<yourToken>

JSON Response

{
  "paramName": "Output_Destinations",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPoint",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "OBJECTID",
        "type": "esriFieldTypeOID",
        "alias": "OBJECTID"
      },
      {
        "name": "Name",
        "type": "esriFieldTypeString",
        "alias": "Name",
        "length": 128
      },
      {
        "name": "CurbApproach",
        "type": "esriFieldTypeInteger",
        "alias": "Curb Approach"
      },
      {
        "name": "Status",
        "type": "esriFieldTypeInteger",
        "alias": "Status"
      },
      {
        "name": "DestinationOID",
        "type": "esriFieldTypeInteger",
        "alias": "Destination OID"
      },
      {
        "name": "OriginCount",
        "type": "esriFieldTypeInteger",
        "alias": "Origin Count"
      }
    ],
    "features": [
      {
        "attributes": {
          "OBJECTID": 1,
          "Name": "Destination 1",
          "CurbApproach": 0,
          "Status": 0,
          "DestinationOID": 1,
          "OriginCount": 2
        },
        "geometry": {
          "x": -0.19909999999993033,
          "y": 51.535400000000038
        }
      },
      {
        "attributes": {
          "OBJECTID": 2,
          "Name": "Destination 2",
          "CurbApproach": 0,
          "Status": 0,
          "DestinationOID": 2,
          "OriginCount": 2
        },
        "geometry": {
          "x": -0.18439999999992551,
          "y": 51.545800000000042
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

JSON Response syntax

When you submit a request, the service assigns a unique job ID to the transaction. The job ID and the status of the job are returned in the response.

{
  "jobId": <jobID>,
  "jobStatus": <jobStatus>
}

The jobStatus property can have the following values:

  • esriJobSubmitted
  • esriJobWaiting
  • esriJobExecuting
  • esriJobSucceeded
  • esriJobFailed
  • esriJobTimedOut
  • esriJobCancelling
  • esriJobCancelled

You can use the job ID to periodically check the status of the job and messages. Additionally, if the job has successfully completed, you can use the job ID to retrieve the results or the inputs. The job information and results remain available for 24 hours after the job is done.

Job execution

After the initial request is submitted, you can make a request of the following form to get the status of the job:

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/jobs/<yourJobID>/?token=<yourToken>&returnMessages=true&f=json

The example below demonstrates the JSON response syntax returned when using the above request:

{
  "jobId": "<jobId>",
  "jobStatus": "<jobStatus>",
  "messages": [
    {
      "type": "<type1>",
      "description": "<description1>"
    },
    {
      "type": "<type2>",
      "description": "<description2>"
    }
  ]
}

While a job is executing, you can cancel it by making a request of the following form:

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/jobs/<jobID>/cancel?token=<yourToken>&f=json
Note:

When you submit your request, if the service is busy processing other requests, the job will wait in the queue. The job status will be reported as esriJobSubmitted. If your application cannot wait for the entire duration while the job is in the queue, you can cancel the request and submit it at a later time. A canceled request will not incur any service credits. However, if your application did not cancel the request, it will eventually execute and will incur service credits irrespective of whether your application retrieved the results or ignored them. Therefore, your application should always cancel the request if required.

Job completion

After the successful completion of the job, you can make a request of the following form to retrieve the outputs. Refer to the Output parameters section for more information on how to interpret the solution provided by the service.

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/jobs/<jobID>/results/<output_parameter_name>?token=<yourToken>&f=pjson

You can also retrieve the value for any input parameter by making a request of the following form:

https://<gpservice-url>/GenerateOriginDestinationCostMatrix/jobs/<jobID>/inputs/<input_parameter_name>?token=<yourToken>f=pjson

Usage limits

The following table lists the limits that apply to this service:

Limit valueLimit description

12.42 miles (20 kilometers)

Maximum snap tolerance

(If the distance between an input point and its nearest traversable street is greater than the distance specified here, the point is excluded from the analysis.)

1 hour (3,600 seconds)

Maximum time a client can use the asynchronous service

1,000,000

Maximum number of allocation lines that can be returned by the asynchronous service