Skip To Content ArcGIS for Developers Sign In Dashboard

Origin Destination Cost Matrix synchronous service

The Origin Destination Cost Matrix service helps you to create an origin-destination (OD) cost matrix from multiple origins to multiple destinations. An Origin Destination Cost Matrix is a table that contains the cost, such as the travel time or travel distance, from every origin to every 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 Origin Destination 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 travel time and/or distance for each origin-destination pair is stored in the output matrix (default) or as part of the attributes of the output lines, which can have no shapes or a straight line shape. Even though the lines are straight, they always store the travel time and/or travel distance based on the street network, not based on Euclidean distance.

Tip:

The Closest Facility and Origin Destination Cost Matrix services perform very similar analyses; the main difference, however, is in the output and the computation speed. The Origin Destination Cost Matrix service generates results faster but cannot return lines that follow the underlying streets or 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 can return routes that follow the underlying streets and directions but is slower to execute than the Origin Destination Cost Matrix service. If you need driving directions or true shapes of routes, use the Closest Facility service; otherwise, use the Origin Destination Cost Matrix service to reduce the computation time.

Request URL

This service uses the synchronous execution mode.

Caution:

The maximum time an application can use the Origin Destination Cost Matrix service is 5 minutes (300 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://route.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/NAServer/OriginDestinationCostMatrix_World/solveODCostMatrix?parameters

Dive-in:

The service works in all of the supported countries listed in the data coverage page. One or more countries are grouped together to form a region. When you pass in your inputs, the service can examine their geographic locations and try to determine the region in which the analysis should be performed.

All input features need to fall within one region.

Request parameters

The origin-destination cost matrix request takes the parameters listed below. The required parameters are origins, destinations, token, and f. The optional parameters have default values that are used when not specified in the request.

ParameterDescription
origins

(Required)

Specifies the starting points from which to travel to the destinations.

Syntax:

destinations

(Required)

Specifies the ending point locations to travel to from the origins.

Syntax:

token

(Required)

Provide the identity of a user that has the permissions to access the service.

f

(Required)

Specify the response format.

Values: json | pjson

travelMode

(Optional)

Choose the mode of transportation for the analysis.

Value: JSON object

defaultCutoff

(Optional)

Specify the travel time or travel distance value at which to stop searching for destinations. The default value is null which means to search until all destinations are found for every origin. The units are the same as the impedance attribute units.

defaultTargetDestinationCount

(Optional)

Specify the number of destinations to find per origin. The default value is null which means to search until all destinations are found for every origin.

outputType

(Optional)

Specify the type of output returned by the service. The default value is esriNAODOutputSparseMatrix.

Values: esriNAODOutputSparseMatrix | esriNAODOutputStraightLines | esriNAODOutputNoLines

timeOfDay

(Optional)

The time and date to depart from the origins. You can also specify a value of now, to set the depart time from origins to current time.

timeOfDayIsUTC

(Optional)

Specify the time zone or zones of the timeOfDay parameter. The default value is false.

Values: true | false

useHierarchy

(Optional)

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

Values: true | false

restrictUTurns

Restrict or permit the route from making U-turns at junctions. The default value is esriNFSBAtDeadEndsAndIntersections.

Values: esriNFSBAtDeadEndsAndIntersections | esriNFSBAllowBacktrack | esriNFSBAtDeadEndsOnly | esriNFSBNoBacktrack

impedanceAttributeName

(Optional)

Specify the impedance. The default value is TravelTime.

Values: TravelTime | TruckTravelTime | WalkTime | Miles | Kilometers

accumulateAttributeNames

(Optional)

Specify whether the service should accumulate values other than the value specified for impedanceAttributeName.

The parameter value should be specified as a comma-separated list of names. The parameter values are the same as the impedanceAttributeName parameter. The default values are demonstrated in the example below:

accumulateAttributeName=Miles,Kilometers

Values: Miles | Kilometers | WalkTime | TravelTime | TruckTravelTime

restrictionAttributeNames

(Optional)

Specify which restrictions should be honored by the service. The default values are demonstrated in the example below:

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

For a complete list of values, see the restrictionAttributeNames section below.

attributeParameterValues

(Optional)

Specify additional values required by an attribute or restriction. For a complete list of accepted values, see the attributeParameterValues section below.

Syntax

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.

Syntax:

polylineBarriers

(Optional)

Specify one or more lines that prohibit travel anywhere the lines intersect the streets.

Syntax:

polygonBarriers

(Optional)

Specify polygons that either prohibit travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons.

Syntax:

returnOrigins

(Optional)

Specify whether origins will be returned by the service. The default value is false.

Values: true | false

returnDestinations

(Optional)

Specify whether destination will be returned by the service. The default value is false.

Values: true | false

returnBarriers

(Optional)

Specify whether barriers will be returned by the service. The default value is false.

Values: true | false

returnPolylineBarriers

(Optional)

Specify whether polyline barriers will be returned by the service. The default value is false.

Values: true | false

returnPolygonBarriers

(Optional)

Specify whether polygon barriers will be returned by the service. The default value is false.

Values: true | false

returnZ

(Optional)

Include z values for the returned geometries if supported by the underlying network. The default value is false.

Values: true | false

ignoreInvalidLocations

(Optional)

Specify whether invalid input locations should be ignored when finding the best solution. The default value is true.

Values: true | false

outSR

(Optional)

Specify the spatial reference of the geometries.

overrides

(Optional)

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

Required parameters

origins

Specifies the starting points from which to travel to the destinations.

You can use a simple comma- and semicolon-based syntax if you are passing the input locations using their longitude and latitude values in the WGS84 coordinate system and don't need to pass additional fields for each location.

Simple syntax for origins

origins=x1,y1; x2, y2; ...; xn, yn

Example using simple syntax

origins=-117.1957,34.0564; -117.184,34.0546

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.
  • 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—Specify the input point geometry containing x and y properties along with a spatialReference property. If the spatialReference property is defined for the entire JSON, there isn't a need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has lot of features, and improves performance. This property is not required if the coordinates are in the default spatial reference WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See geographic coordinate system and projected coordinate system to look up WKID values.
    Tip:

    As a best practice, it is recommended to explicitly specify the spatialReference, and specify it for the entire JSON instead of each individual geometry.

  • 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—such as its name or the number of destinations to find from the origin— using the following attributes:

  • Name

    The name of the origin. The name can be a unique identifier for the origin. If outputType is esriNAODOutputStraightLines or esriNAODOutputNoLines, the name is included in the output lines Name field (the output lines name will be origin name – destination name). The name is also included in the output origins as the Name field.

    If the name is not specified, a unique name prefixed with Location is automatically generated.

  • ObjectID

    The ObjectID of the origin. The ObjectID is a unique identifier for the origin. If the outputType is esriNAODOutputStraightLines or esriNAODOutputNoLines, the ObjectID is included in the output lines (as the OriginID field). If outputType is esriNAODOutputSparseMatrix, the ObjectID is included in the output matrix. The ObjectID is also included in the output origins (as the ObjectID field) and can be used to join additional information from tool outputs to the attribute of your origins. If the ObjectID is not specified, a unique ID is automatically generated in the output.

  • TargetDestinationCount

    The maximum number of destinations to find for the origin.

    If a value is not specified, the value from the defaultTargetDestinationCount 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 the three closest destinations from one origin and the two closest destinations from another origin.

  • Cutoff_[Impedance]

    If you want to stop searching for destinations once the search has exceeded a certain impedance value, specify a Cutoff_[Impedance] field for your origin.

    The impedance is the impedance attribute name in your analysis, or the impedance name of your travel mode if you specify a travel mode. 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 units of the cutoff is the same as the units of your impedance attribute. If a value is not specified, the value from the defaultCutoff 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.

    Either side of vehicle
    All arrival and departure combinations are allowed with the Either side of vehicle curb approach.

    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
    The allowed arrival and departure combination for the Right side of vehicle curb approach is shown.

    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
    The allowed arrival and departure combination for the Left side of vehicle curb approach is shown.

    No U-Turn

    3

    When the vehicle departs the origin, the origin can be on either side of the vehicle; however, when it departs, the vehicle must continue in the same direction in which it arrived. A U-turn is prohibited.

    No U-turns
    The allowed arrival and departure combinations for the No U-Turn curb approach are shown.

    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, choose 1 (Right side of vehicle) in the United States and 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.

    Learn more about bearing and bearing tolerance

  • 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 Network Analyst 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.

    Learn more about bearing and bearing tolerance

  • 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 cost 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 units of NavLatency are the same as the units of the impedance attribute.

Syntax for origins

Syntax for specifying origins using JSON structure for features

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

Syntax for specifying origins using a URL returning a JSON response

{
  "url": "<url>"
}

Examples for origins

Example one: Specifying origins geometries in the Web Mercator spatial reference using JSON structure.

The example also shows how to specify the originsName attribute for each origin and specify a different number of destinations to find for each origin using the TargetDestinationCount attribute.

{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "x": -13635398.9398,
        "y": 4544699.034400001
      },
      "attributes": {
        "Name": "123 Main St",
        "TargetDestinationCount": 1
      }
    },
    {
      "geometry": {
        "x": -13632733.3441,
        "y": 4547651.028300002
      },
      "attributes": {
        "Name": "845 Mulberry St",
        "TargetDestinationCount": 2
      }
    }
  ]
}

Example two: 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://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/1/query?where=1%3D1&outFields=Name,RouteName&f=json"
}

destinations

Specifies the ending point locations to travel to from the origins.

You can use a simple comma- and semicolon-based syntax if you are passing the input locations using their longitude and latitude values in the WGS84 coordinate system and don't need to pass additional fields for each location.

Simple syntax for destinations

destinations=x1,y1; x2, y2; ...; xn, yn

Example using simple syntax

destinations=-117.1957,34.0564; -117.184,34.0546

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.
  • 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—Specify the input point geometry containing x and y properties along with a spatialReference property. If the spatialReference property is defined for the entire JSON, there isn't a need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has lot of features, and improves performance. This property is not required if the coordinates are in the default spatial reference WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See geographic coordinate system and projected coordinate system to look up WKID values.
    Tip:

    As a best practice, it is recommended to explicitly specify the spatialReference, and specify it for the entire JSON instead of each individual geometry.

  • 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—such as its name—using the following attributes:

  • Name

    The name of the destination. The name can be a unique identifier for the destination. If outputType is esriNAODOutputStraightLines or esriNAODOutputNoLines, the name is included in the output lines Name field (the output lines name will be origin name – destination name). The name is also included in the output destinations as the Name field.

    If the name is not specified, a unique name prefixed with Location is automatically generated.

  • ObjectID

    The ObjectID of the destination. The ObjectID is a unique identifier for the destination. If the outputType is esriNAODOutputStraightLines or esriNAODOutputNoLines, the ObjectID is included in the output lines (as the DestinationID field). If outputType is esriNAODOutputSparseMatrix, the ObjectID is included in the output matrix. The ObjectID is also included in the output destinations (as the ObjectID field) and can be used to join additional information from tool outputs to the attribute of your destinations. If the ObjectID is not specified, a unique ID is automatically generated in the output.

  • 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 the 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 the 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.

    Either side of vehicle
    All arrival and departure combinations are allowed with the Either side of vehicle curb approach.

    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
    The allowed arrival and departure combination for the Right side of vehicle curb approach is shown.

    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
    The allowed arrival and departure combination for the Left side of vehicle curb approach is shown.

    No U-Turn

    3

    When the vehicle arrives at the destination, the destination can be on either side of the vehicle; however, when it departs, the vehicle must continue in the same direction in which it arrived. A U-turn is prohibited.

    No U-turns
    The allowed arrival and departure combinations for the No U-Turn curb approach are shown.

    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, choose 1 (Right side of vehicle) in the United States and 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.

    Learn more about bearing and bearing tolerance

  • 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 Network Analyst 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.

    Learn more about bearing and bearing tolerance

  • 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 cost 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 units of NavLatency are the same as the units of the impedance attribute.

Syntax examples for destinations

Syntax for specifying destinations using JSON structure for features.

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

Syntax for specifying destinations using a URL returning a JSON response.

{
  "url": "<url>"
}

Examples for destinations

Example one: Specifying destinations geometry in the Web Mercator spatial reference using JSON structure.

The example also shows how to specify the Name attribute.

{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "x": -13635398.9398,
        "y": 4544699.034400001
      },
      "attributes": {
        "Name": "Store 45"
      }
    },
    {
      "geometry": {
        "x": -13632733.3441,
        "y": 4547651.028300002
      },
      "attributes": {
        "Name": "Store 67"
      }
    }
  ]
}

Example two: Specifying destinations 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://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/1/query?where=1%3D1&outFields=Name,RouteName&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>

Optional parameters

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.

travelMode

Choose the mode of transportation for the analysis.

Travel modes are managed in ArcGIS Online and can be configured by the administrator of your organization to better reflect your organization's workflows.

Learn more about travel modes

The value for the travelMode parameter is the JSON object containing the settings for a travel mode supported by your organization. To get the supported travel modes, execute the retrieveTravelModes operation.

You can make a request to retrieve travel modes using the following form:

https://route.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/NAServer/OriginDestinationCostMatrix_World/retrieveTravelModes?f=json&token=

Note:

If you copy and paste the above URL into a web browser, you will get an invalid token error message. You need to replace <yourToken> with a valid token. See Accessing services provided by Esri to see how to generate one.

Below is the response as returned by the retrieveTravelModes operation.

Note:

Because the response is quite verbose, the elements in the response are abbreviated for clarity.

{
  "currentVersion": 10.8,
  "defaultTravelMode": "FEgifRtFndKNcJMJ",
  "supportedTravelModes": [
    {
      "attributeParameterValues": [
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Private Roads",
          "value": "AVOID_MEDIUM"
        },
        {
          "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
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Roads Unsuitable for Pedestrians",
          "value": "AVOID_HIGH"
        }
      ],
      "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": [
        "Avoid Private Roads",
        "Avoid Roads Unsuitable for Pedestrians",
        "Preferred for Pedestrians",
        "Walking"
      ],
      "useHierarchy": false,
      "simplificationTolerance": 2,
      "timeAttributeName": "WalkTime",
      "distanceAttributeName": "Kilometers",
      "type": "WALK",
      "id": "caFAgoThrvUpkFBW",
      "name": "Walking Time"
    },
    {
      "attributeParameterValues": [
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Unpaved Roads",
          "value": "AVOID_HIGH"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Private Roads",
          "value": "AVOID_MEDIUM"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Driving an Automobile",
          "value": "PROHIBITED"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Through Traffic Prohibited",
          "value": "AVOID_HIGH"
        },
        {
          "parameterName": "Vehicle Maximum Speed (km/h)",
          "attributeName": "TravelTime",
          "value": 0
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Roads Under Construction Prohibited",
          "value": "PROHIBITED"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Gates",
          "value": "AVOID_MEDIUM"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Express Lanes",
          "value": "PROHIBITED"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Carpool Roads",
          "value": "PROHIBITED"
        }
      ],
      "description": "Models the movement of cars and other similar small automobiles,
                      such as pickup trucks, and finds solutions that optimize travel
                      time. Travel obeys one-way roads, avoids illegal turns, and
                      follows other rules that are specific to cars. When you specify
                      a start time, dynamic travel speeds based on traffic are used
                      where it is available.",
      "impedanceAttributeName": "TravelTime",
      "simplificationToleranceUnits": "esriMeters",
      "uturnAtJunctions": "esriNFSBAtDeadEndsAndIntersections",
      "restrictionAttributeNames": [
        "Avoid Unpaved Roads",
        "Avoid Private Roads",
        "Driving an Automobile",
        "Through Traffic Prohibited",
        "Roads Under Construction Prohibited",
        "Avoid Gates",
        "Avoid Express Lanes",
        "Avoid Carpool Roads"
      ],
      "useHierarchy": true,
      "simplificationTolerance": 10,
      "timeAttributeName": "TravelTime",
      "distanceAttributeName": "Kilometers",
      "type": "AUTOMOBILE",
      "id": "FEgifRtFndKNcJMJ",
      "name": "Driving Time"
    }
  ]
}

From the above JSON , to pass Walking Time as the travel mode, use the following JSON as the value for the travelMode parameter:

travelMode={"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"}

Caution:

When the travelMode parameter is set, you are choosing a travel mode configured in 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: impedanceAttributeName, attributeParameterValues, restrictUturns, useHierarchy, restrictionAttributeNames, and directionsTimeAttributeName.

If you don't set the travelMode parameter, the service honors the default or user-defined values for the parameters that would otherwise be overridden, so you can create your own travel mode.

defaultCutoff

Use this parameter to specify the travel time or travel distance value at which to stop searching for destinations from a given origin.

The unit for this parameter is based on the unit of the impedance attribute specified using the impedanceAttributeName parameter or the impedanceAttributeName of the travel mode if travel mode is specified . If the impedanceAttributeName parameter is TravelTime, the defaultCutoff is specified in minutes. Otherwise, the value is specified in miles or kilometers based on whether the impedanceAttributeName is set to Miles or Kilometers, respectively.

The value for the defaultCutoff parameter can be overridden on a per origin basis by specifying a value for the Cutoff_[Impedance] attribute when specifying the origins parameter.

defaultTargetDestinationCount

The maximum number of destinations to find per origin. If a value for this parameter is not specified, the output matrix includes travel costs from each origin to every destination.

The value for the defaultTargetDestinationCount parameter can be overridden by specifying a value for the TargetDestinationCount attribute when specifying the origins parameter.

outputType

Specify the type of route features that are output by the service. The outputType parameter can have one of the following values:

  • esriNAODOutputSparseMatrix— Return the cost between origin and destination using a sparse matrix format.
  • esriNAODOutputStraightLines— Return a straight line between the origin and the destination.
  • esriNAODOutputNoLines— Do not return any shapes for the result.

timeOfDay

The time and date to depart from the origins. You can also specify a value of now, to set the depart time from origins to current time.

Specifying a time of day results in more accurate estimations of travel times because the travel times account for the traffic conditions that are applicable for that date and time.

To use traffic in the analysis, set impedanceAttributeName to TravelTime, and assign a value to timeOfDay.

The timeOfDay value represents the time at which the travel begins from the input origins. The time is specified as Unix time (milliseconds since midnight, January 1, 1970).

If a value of now is passed to timeOfDay parameter, the travel begins at current time. This will also override timeOfDayIsUTC parameter value to be true. When timeOfDay is nowand timeOfDayIsUTC is true, the travel will begin or end at input locations at current time regardless of the time zone the input locations belong to.

If a time of day is not passed in, the service uses static road speeds based on average historical speeds or posted speed limits. It uses posted speeds in areas where historical traffic information isn't available.

Note:
Traffic is supported only with the driving time impedance or travel mode. It's not supported with trucking.

The service support two kinds of traffic: live and typical.

If the timeOfDay specified is within 4 hours of the current time, live traffic will be used where available. Live traffic retrieves speeds based on phone probe records, sensors, and other data sources and reflects the current travel speeds and predicts speeds for the near future. If the timeOfDay specified is earlier than 4 hours or later than 4 hours from the current time, or the road does not have live traffic, typical traffic speeds will be used. Typical speeds are based on historical traffic patterns. The travel time data is aggregated in 15 minute intervals per day of week based on multiple years worth of data. So a road may have a different travel time at Monday at 8 am, Monday at 8:15 am, or Tuesday at 8 am. Since the variance is just at the day of week and time of day, the travel time is the same on a road for any Monday at 8 am, regardless of the month or year.

If your goal is to model typical travel conditions and avoid large variances from the average due to live traffic, it is recommended to use a date from the past to ensure it doesn't coincide with the 4 hour window from the current time. As an extreme example, you can even use dates from 1990.

The Data Coverage page shows the countries Esri currently provides traffic data for.

Typical Traffic

To ensure the task uses typical traffic in locations where it is available, choose a time and day of the week, and then convert the day of the week to one of the following dates from 1990:

  • Monday—1/1/1990
  • Tuesday—1/2/1990
  • Wednesday—1/3/1990
  • Thursday—1/4/1990
  • Friday—1/5/1990
  • Saturday—1/6/1990
  • Sunday—1/7/1990

Set the time and date as Unix time in milliseconds. For example, to solve for 1:03 p.m. on Thursdays, set the time and date to 1:03 p.m., January 4, 1990; and convert to milliseconds (631458180000). Although the dates representing days of the week are from 1990, typical traffic is calculated from recent traffic trends—usually over the last two years worth of data.

Live traffic

To use live traffic when and where it is available, choose a time and date and convert to Unix time.

Esri saves live traffic data for 4 hours and references predictive data extending 4 hours into the future. If the time and date you specify for this parameter is outside the 8-hour time window, or the travel time in the analysis continues past the predictive data window, the task falls back to typical traffic speeds.

Examples for timeOfDay

Example one: 13:03, January 4, 1990. Typical traffic on Thursdays at 1:03 p.m.

"timeOfDay": 631458180000

Example two: 17:00, January 7, 1990. Typical traffic on Sundays at 5:00 p.m.

"timeOfDay": 631731600000

Example three: Specify value of now. The analysis will begin at current time and live traffic speeds are referenced in the analysis.

"timeOfDay": now

Example four: 10:20, March 18, 2015. If the current time is between 6:20 a.m., March 18, 2015, and 14:20 p.m., March 18,2015, live traffic speeds are referenced in the analysis; otherwise, typical traffic speeds are referenced.

"timeOfDay": 1426674000000

timeOfDayIsUTC

Specify the time zone or zones of the timeOfDay parameter.

The default value is false

False (i.e. use geographically local time zones)

The timeOfDay value refers to the time zone or zones in which the input points are located. This option causes the analysis to have rolling start times across time zones.

Illustration of setting the value to false (geographically local): Setting timeOfDay to 9:00 a.m., January 4, 1990 (631443600000 milliseconds); timeOfDayIsUTC to false; and submitting a valid request causes the drive times for points in the eastern time zone to start at 9:00 a.m. eastern Time and 9:00 a.m. central time for points in the central time zone. (The start times are offset by an hour in real or UTC time.)

Time of day is UTC parameter set to false
Input: timeOfDay is 9:00 a.m., January 4, 1990 (631443600000 milliseconds), and timeOfDayIsUTC is set to false

True (i.e. UTC)

The timeOfDay value refers to coordinated universal time (UTC). The start times for all points are simultaneous, regardless of time zones.

Illustration of setting the value to true (UTC): Setting timeOfDay to 9:00 a.m., January 4, 1990 (631443600000 milliseconds) and the value to true, the start times for points in the eastern time zone is 4:00 a.m. Eastern Time and 3:00 a.m. central time for those in the central time zone.

Time of day is UTC parameter set to true
Input: timeOfDay is 9:00 a.m., January 4, 1990 (631443600000 milliseconds), and timeOfDayIsUTC is set to true

Note:

This parameter is ignored when impedanceAttributeName is set to distance units.

useHierarchy

Specify whether hierarchy should be used when finding the destinations.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

  • true—Use hierarchy when travelling from origins to destinations. When hierarchy is used, the service 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 service can determine the best route from a relatively smaller subset of streets.

  • false—Do not use hierarchy when travelling from origins to destinations. If hierarchy is not used, the service considers all the streets and doesn't prefer higher-order streets. This is often used when solving problems in a small area and have a lot of destination but are specifying a cutoff based to find a subset of them.

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.

restrictUTurns

Use this parameter to restrict or permit the route from making 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 you pass in travelMode.

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

esriNFSBAllowBacktrack

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

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

esriNFSBAtDeadEndsAndIntersections

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.

esriNFSBAtDeadEndsOnly

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

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

esriNFSBNoBacktrack

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 is esriNFSBAllowBacktrack

impedanceAttributeName

Specify the impedance.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

Impedance is a value that quantifies travel along the transportation network. Travel distance is an example of impedance; it quantifies the length of walkways and road segments. Similarly, drive time—the typical time it takes to drive a car along a road segment—is an example of impedance. Drive times may vary by type of vehicle—for instance, the time it takes for a truck to travel along a path tends to be longer than a car—so there can be many impedance values representing travel times for different vehicle types. Impedance values may also vary with time; live and typical traffic reference dynamic impedance values. Each walkway and road segment stores at least one impedance value. When performing a network analysis, the impedance values are used to calculate the best results, such as finding the shortest route—the route that minimizes impedance—between two points.

The impedanceAttributeName parameter can be specified using the following values:

  • TravelTime—Historical and live traffic data is used. This option is good for modeling the time it takes automobiles to travel along roads at a specific time of day using live traffic speed data where available. When using TravelTime, you can optionally set the TravelTime::Vehicle Maximum Speed (km/h) attribute parameter to specify the physical limitation of the speed the vehicle is capable of traveling.
  • Minutes—Live traffic data is not used, but historical average speeds for automobiles data is used.
  • TruckTravelTime—Historical and live traffic data is used, but the speed is capped at 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 set the TruckTravelTime::Vehicle Maximum Speed (km/h) attribute parameter to specify the physical limitation of the speed the truck is capable of traveling.
  • TruckMinutes—Live traffic data is not used, but the smaller of the historical average speeds for automobiles and the posted speed limits for trucks are used.
  • WalkTime—The default is 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—Length measurements along roads are stored in miles and can be used for performing analysis based on shortest distance.
  • Kilometers—Length measurements along roads are stored in kilometers and can be used for performing analysis based on shortest distance.
  • TimeAt1KPH—The default is a speed of 1 km/hr on all roads and paths. The speed cannot be changed using any attribute parameter.

accumulateAttributeNames

Use this parameter to specify whether the service should accumulate values other than the value specified for impedanceAttributeName. For example, if your impedanceAttributeName is set to TravelTime, the total travel time for the route will be calculated by the service. However, if you also want to calculate the total distance of the route in miles, you can specify Miles as the value for the accumulateAttributeNames parameter.

The parameter value should be specified as a comma-separated list of names. The parameter values are the same as the impedanceAttributeName parameter. For example, accumulateAttributeNames=Miles,Kilometers indicates that the total cost of the route should also be calculated in miles and kilometers.

Note:

The values specified for the accumulateAttributeNames parameter are purely for reference. The service always uses impedanceAttributeName to find the best routes.

restrictionAttributeNames

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 of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

The parameter value is specified as a comma-separated list of restriction names. A value of none indicates that no restrictions should be used when finding shortest paths.

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 attributeParameterValues.

The restrictionAttributeNames parameter can be specified using the following values:

  • Any Hazmat Prohibited—The results will not include roads where transporting any kind of hazardous material is prohibited.

  • Avoid Carpool Roads—The results will avoid roads that are designated exclusively for car pool (high-occupancy) vehicles.

  • Avoid Express Lanes—The results will avoid roads designated as express lanes.

  • Avoid Ferries—The results will avoid ferries.

  • Avoid Gates—The results will avoid roads where there are gates, such as keyed access or guard-controlled entryways.

  • Avoid Limited Access Roads—The results will avoid roads that are limited-access highways.

  • Avoid Private Roads—The results will avoid roads that are not publicly owned and maintained.

  • Avoid Roads Unsuitable for Pedestrians—The results will avoid roads that are unsuitable for pedestrians.

  • Avoid Stairways—The results will avoid all stairways on a pedestrian-suitable route.

  • Avoid Toll Roads—The results will avoid all toll roads for automobiles.

  • Avoid Toll Roads for Trucks—The results will avoid all toll roads for trucks.

  • Avoid Truck Restricted Roads—The results will avoid roads where trucks are not allowed, except when making deliveries.

  • Avoid Unpaved Roads—The results will avoid roads that are not paved (for example, dirt, gravel, and so on).

  • Axle Count Restriction—The results 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 results will not include roads where buses are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Driving a Taxi—The results will not include roads where taxis are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Driving a Truck—The results will not include roads where trucks are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Driving an Automobile—The results will not include roads where automobiles are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Driving an Emergency Vehicle—The results will not include roads where emergency vehicles are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Height Restriction—The results will not include 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 results will not include roads where the vehicle length exceeds the maximum allowed kingpin to rear axle for all trucks on the road. The 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 results will not include 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 results will use preferred routes suitable for pedestrian navigation.

  • Riding a Motorcycle—The results will not include roads where motorcycles are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Roads Under Construction Prohibited—The results will not include roads that are under construction.

  • Semi or Tractor with One or More Trailers Prohibited—The results will not include roads where semis or tractors with one or more trailers are prohibited.

  • Single Axle Vehicles Prohibited—The results will not include roads where vehicles with single axles are prohibited.

  • Tandem Axle Vehicles Prohibited—The results will not include roads where vehicles with tandem axles are prohibited.

  • Through Traffic Prohibited—The results will not include roads where through traffic (non-local) is prohibited.

  • Truck with Trailers Restriction—The results will not include 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 results will prefer roads that are designated for transporting any kind of hazardous materials.

  • Use Preferred Truck Routes—The results will prefer roads that are 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 roads that are preferred by truckers when driving in an area.

  • Walking—The results will not include roads where pedestrians are prohibited.

  • Weight Restriction—The results will not include 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 results will not include roads where the vehicle weight per axle exceeds the maximum allowed weight per axle for the road. The vehicle weight per axle can be specified using the Vehicle Weight per Axle (kilograms) restriction parameter.

  • Width Restriction—The results will not include roads where the vehicle width exceeds the maximum allowed width for the road. The vehicle width can be specified using the Vehicle Width (meters) restriction parameter.

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 restrictionAttributeName 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 travelMode is set to null.

attributeParameterValues

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. For example, you can choose to never use toll roads, avoid them as much as possible, or prefer them.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

The parameter value is specified as an array of objects each having the following properties:

  • attributeName— The name of the restriction

  • parameterName—The name of the parameter associated with the restriction. A restriction can have one or more parameterName properties.

  • value—The value for parameterName.

Most attribute parameters are related to the restriction attributes in restrictionAttributeNames. Each restriction has at least one attribute parameter named Restriction Usage, which 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 parameter can be assigned any of the following string values, or their equivalent numeric values listed within the parentheses:

  • Prohibited (-1)—Travel on the roads that have the restriction is completely prohibited.
  • Avoid_High (5)—It is very unlikely for the service to include in the route the roads that are associated with the restriction.
  • Avoid_Medium (2)—It is unlikely for the service to include in the route the roads that are associated with the restriction.
  • Avoid_Low (1.3)—It is somewhat unlikely for the service to include in the route the roads that are associated with the restriction.
  • Prefer_Low (0.8)—It is somewhat likely for the service to include in the route the roads that are associated with the restriction.
  • Prefer_Medium(0.5)—It is likely for the service to include in the route the roads that are associated with the restriction.
  • Prefer_High (0.2)—It is very likely for the service to include in the route the roads that are associated with the restriction.

Note:

The restrictionAttributeNames parameter is associated with attributeParameterValues. The restriction attribute's parameter value is specified as part of attributeParameterValues. Each restriction has at least one parameter named Restriction Usage, which specifies whether travel on roads that have the restriction is prohibitied, should be avoided, or should be preferred. For the latter two options, it also specifies the degree to which the roads are avoided or preferred.

The following table lists the attribute parameter names and the default parameter values.

Tip:

If you want to use the default value for a restriction, attributeName, parameterName and value do not have to be specified as part of the attributeParameterValues parameter.

Restriction NameRestriction Parameter NameRestriction Parameter Default Value

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 attributeParameterValues

Syntax for specifying attributeParameterValues
[
    {
        "attributeName": "<attribute1>",
        "parameterName": "<parameter1>",
        "value": "<value1>"
    },
    {
        "attributeName": "<attribute2>",
        "parameterName": "<parameter2>",
        "value": "<value2>"
    }
]

Example for attributeParameterValues

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 the 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 route 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 parameter for the Height Restriction and the Weight Restriction are not specified as we want to use the default value of Prohibit for these restriction parameters.

attributeParameterValues=
[
    {
        "attributeName": "Height Restriction",
        "parameterName": "Vehicle Height (meters)",
        "value": 4.12
    },
    {
        "attributeName": "Weight Restriction",
        "parameterName": "Vehicle Weight (kilograms)",
        "value": 36287
    },
    {
        "attributeName": "Use Preferred Truck Routes",
        "parameterName": "Restriction Usage",
        "value": "Prefer_High"
    }
]

barriers

Use this parameter to specify one or more points that will 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.

Caution:

The service imposes a maximum limit of 250 point barriers. If the value is exceeded, the response returns an error message.

You can use a simple comma- and semicolon-based syntax if you are passing the point barrier locations using their longitude and latitude values in the WGS84 coordinate system and don't need to pass additional fields for each location.

Simple syntax for barriers

barriers=x1,y1; x2, y2; ...; xn, yn

Example using simple syntax

barriers=-117.1957,34.0564; -117.184,34.0546

You can specify barrier geometries as well as attributes using a more comprehensive JSON structure that represents a set of features. The JSON structure can include the following properties:

  • features— Specify an array of features. This property is optional. However, either the features or url property must be specified.
  • 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.

Each feature in this array represents a point barrier and contains the following fields:

  • geometry—Specify the input point geometry containing x and y properties along with a spatialReference property. If the spatialReference property is defined for the entire JSON, there isn't a need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has lot of features, and improves performance. This property is not required if the coordinates are in the default spatial reference WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See geographic coordinate system and projected coordinate system to look up WKID values.
    Tip:

    As a best practice, it is recommended to explicitly specify the spatialReference, and specify it for the entire JSON instead of each individual geometry.

  • 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.

Attribute for barriers

When specifying the barriers parameter using JSON structure, you can specify additional information about barriers, such as the barrier type, using attributes. The barriers parameter can be specified with the following attributes:

Name

The name of the barrier.

ObjectID

The ObjectID of the barrier. The ObjectID is a unique identifier for the barrier. If you want to maintain relationship between input and output, set preserveObjectID to true. The ObjectID of the input barrier is included in the output barrier (as the ObjectID field) and can be used to join additional information from analysis outputs to the attribute of your barriers. If the ObjectID is not specified, a unique ID is automatically generated in the output.

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 a route analysis.
    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 Attr_[Cost] attributes. This barrier type is referred to as an added cost point barrier.
    Two maps demonstrate how added cost point barriers affect a route analysis.
    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.

Note:

There is no point barrier type with a value of 1 for the BarrierType attribute.

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.

Attr_[Cost]

Indicates how the cost (time or distance) is added when the barrier is traversed. This attribute is applicable only for added cost point barriers. The attribute value must be greater than or equal to zero.

Syntax examples for barriers

Syntax for specifying barriers using JSON structure for features

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

Syntax for specifying barriers using a URL to a JSON response

{
  "url": "<url>"
}

Examples for barriers

Example one: Specifying an added cost point barrier using JSON structure

This example shows how to use an added cost point barrier to model a five-minute delay at a railroad crossing. The BarrierType attribute is used to specify that the point barrier is of type added cost and the Attr_TravelTime attribute is used to specify the delay in minutes.

{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "x": -122.053461,
        "y": 37.541479
      },
      "attributes": {
        "Name": "Haley St rail road crossing",
        "BarrierType": 2,
        "Attr_TravelTime": 5
      }
    }
  ]
}

Example two: Specifying a restriction point 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://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/0/query?where=1%3D1&returnGeometry=true&f=json"
}

polylineBarriers

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 polyline barrier.

You can specify polyline barrier geometries as well as attributes using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • features— Specify an array of features. This property is optional. However, either the features or url property must be specified.
  • 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.

Each feature in this array represents a polyline barrier and contains the following fields:

  • geometry—Specify the input point geometry containing x and y properties along with a spatialReference property. If the spatialReference property is defined for the entire JSON, there isn't a need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has lot of features, and improves performance. This property is not required if the coordinates are in the default spatial reference WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See geographic coordinate system and projected coordinate system to look up WKID values.
    Tip:

    As a best practice, it is recommended to explicitly specify the spatialReference, and specify it for the entire JSON instead of each individual geometry.

  • 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 polylineBarriers

When specifying the polylineBarriers parameter using JSON structure, the parameter can be specified with the following attribute:

Name

The name of the barrier.

ObjectID

The ObjectID of the line barrier. The ObjectID is a unique identifier for the line barrier. If you want to maintain relationship between input and output, set preserveObjectID to true. The ObjectID of the input line barrier is included in the output line barrier (as the ObjectID field) and can be used to join additional information from analysis outputs to the attribute of your line barriers. If the ObjectID is not specified, a unique ID is automatically generated in the output.

Syntax examples for polylinesBarriers

Syntax for specifying polyline barriers using 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 polyline barriers using a URL returning a JSON response

{
  "url": "<url>"
}

Examples for polylineBarriers

Example one: Specifying polyline barriers using JSON structure

The example shows how to add two lines as polyline 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. The first part is made up of three points, and the second part is made up of two points.

{
  "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 polyline 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://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/6/query?where=1%3D1&returnGeometry=true&f=json"
}

polygonBarriers

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

You can specify polygon barrier geometries as well as attributes using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • features— Specify an array of features. This property is optional. However, either the features or url property must be specified.
  • 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.

Each feature in this array represents a polygon barrier and contains the following fields:

  • geometry—Specify the input point geometry containing x and y properties along with a spatialReference property. If the spatialReference property is defined for the entire JSON, there isn't a need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has lot of features, and improves performance. This property is not required if the coordinates are in the default spatial reference WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See geographic coordinate system and projected coordinate system to look up WKID values.
    Tip:

    As a best practice, it is recommended to explicitly specify the spatialReference, and specify it for the entire JSON instead of each individual geometry.

  • 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 polygonBarriers

When specifying the polygonBarriers parameter using JSON structure, you can specify additional information about barriers, such as the barrier type, using attributes. The polygonBarriers parameter can be specified with the following attributes:

Name

The name of the barrier.

ObjectID

The ObjectID of the polygon barrier. The ObjectID is a unique identifier for the polygon barrier. If you want to maintain relationship between input and output, set preserveObjectID to true. The ObjectID of the input polygon barrier is included in the output polygon barrier (as the ObjectID field) and can be used to join additional information from analysis outputs to the attribute of your polygon barriers. If the ObjectID is not specified, a unique ID is automatically generated in the output.

BarrierType

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

  • 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.

    This is the default value.

    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 Attr_[Cost]. 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 is 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.

Attr_[Cost]

This is the factor by which the cost of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled cost barriers. The attribute value must be greater than zero.

Syntax examples for polygonBarriers

Syntax for specifying polygon barriers using 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 polygonBarriers

Example one: Specifying polygon barrier using 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 reduces 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.

{
  "spatialReference": {
    "wkid": 4326
  },
  "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,
        "Attr_TravelTime": 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://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/7/query?where=1%3D1&returnGeometry=true&f=json"
}

returnOrigins

Use this parameter to specify whether origins will be returned by the service. The possible values for this parameter are true or false. A true value indicates that the origins used as input will be returned as part of the origins property in the JSON response. The default value for this parameter is false.

returnDestinations

Use this parameter to specify whether destinations will be returned by the service. The possible values for this parameter are true or false. A true value indicates that the destinations used as input will be returned as part of the destinations property in the JSON response. The default value for this parameter is false.

returnBarriers

Specify whether barriers will be returned by the service.

  • true—The input point barriers are returned as part of the barriers property in the JSON response.
  • false (default)—Point barriers are not returned.

Setting this parameter has no effect if you don't also specify a value for the barriers parameter.

If you have specified the barriers parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, returning barriers can allow you to draw the point barrier locations in your application. You may also want to set the returnBarriers property to true to see where the barriers were located on the street network or, if they weren't located at all, understand what the problem was by checking the Status property in the JSON response.

returnPolylineBarriers

Specify whether polyline barriers will be returned by the service.

  • true—The input polyline barriers are returned as part of the polylineBarriers property in the JSON response.
  • false (default)—Polyline barriers are not returned.

Setting this parameter has no effect if you don't also specify a value for the polylineBarriers parameter.

If you have specified the polylineBarriers parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, the returnPolylineBarriers parameter can be set to true so that you can draw the polyline barrier locations in your application.

returnPolygonBarriers

Specify whether polygon barriers will be returned by the service.

  • true—The input polygon barriers are returned as part of the polygonBarriers property in the JSON response.
  • false (default)—Polygon barriers are not returned.

Setting this parameter has no effect if you don't also specify a value for the polygonBarriers parameter.

If you have specified the polygonBarriers parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, the returnPolygonBarriers parameter can be set to true so that you can draw the polygon barrier locations in your application.

returnZ

Include z values for the returned geometries if supported by the underlying network. The default value is false

  • true—The output geometries will have a Z value.
  • false (default)—Z value is not returned.

ignoreInvalidLocations

Specify whether invalid input locations should be ignored when finding the best solution. An input point is deemed invalid by the service if it is not within the maximum snap tolerance of any traversable street.

  • true—Invalid points are ignored.
  • false— Any invalid point in your request will cause the service to return a failure.

The default value is true.

outSR

Use this parameter to specify the spatial reference of the geometries, such as line or point features, returned by the service.

The parameter value can be specified as a well-known ID (WKID) for the spatial reference. 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 outSR=102100 returns the geometries in the Web Mercator spatial reference, which can be drawn on top of the basemaps.

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 must be specified in JavaScript Object Notation (JSON). The values can be either a number, a Boolean, or a string.

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

The default value for this parameter is no value, which indicates to not 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.

Output parameters

Upon successfully execution, the service returns the travel time and/or distance for each origin-destination pair. It returns either odLines or odCostMatrix for this information depending on the outputType you specify. The service can also return the output origins, the output destinations, the output barriers, the output polygon barriers, and the output polyline barriers if you choose to return them. It also returns the status of whether the analysis was successful. This information is output in the following output parameters:

odLines

When the outputType is esriNAODOutputNoLines or esriNAODOutputStraightLines, the output will be odLines. The odLines output include geometry for the straight line connecting each origin-destination pairs when the outputType is esriNAODOutputStraightLines.

FieldDescription
ObjectID

The system-managed ID field.

Name

The name of the corresponding input origin and destination feature. The origin name is first and the destination name is second. For example, Origin 1 – Destination 1. If the name is not specified for origin and or destination, a unique name prefixed with Location is automatically generated for that origin/destination.

OriginID

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.

DestinationID

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

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_[Cost](for instance Total_TravelTime, where TravelTime is the travel cost)

The travel cost along the street network from the associated origin to the associated destination. These fields are populated for the impedance attribute and any accumulated attributes.

odCostMatrix

When the outputType is esriNAODOutputSparseMatrix, the output is a JSON object that contains an array identified by costAttributeNames to know what cost attributes are in the matrix and in what index. It then has an associative array of origins (identified by their ObjectID) each of which has an associative array of destinations (identified by their ObjectID) containing an array of costs that are in the same order as the costAttributeNames array.

In the example below, TravelTime is the impedance attribute; and Miles and Kilometers are the accumulate attributes used in the analysis. In the returned matrix that contains the time and distance between origin-destination pair, each nested JSON is composed of origin ObjectID, destination ObjectID, and the costs from origin to destination in the order defined in the costAttributeNames. In the example below, travel from origin ObjectID 1 to destination ObjectID 1 takes 62.88 miles.

"odCostMatrix": {
  "costAttributeNames": [
   "TravelTime",
   "Miles",
   "Kilometers"
  ],
  "1": {
   "1": [
    78.61,
    62.88,
    101.20
   ]
  }
 }

origins

Access the origins that participated in the analysis. It provides information about origins that could not be included in the analysis.

The following table describes the attributes of the output origins:

FieldDescription
ObjectID

The object ID of the input origin. If ObjectID is not specified, it will be system generated ID for the origin.

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 network dataset source feature class on which the input point is located.

SourceOID

The ObjectID of the feature in the source on which the input point is located.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

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. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

CurbApproach

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

Status

Indicates the status of the point with respect to its location on the network and the outcome of the analysis. The possible values are the following:

  • 0 (OK)—The point was successfully located on the network.
  • 1 (Not Located)—The point was not successfully located on the network and consequently was not included in the analysis.
  • 2 (Network element not located)—The network element identified by the point's network location fields can't be found. This can occur when a network element where the point should be was deleted, and the network location was not recalculated.
  • 3 (Element not traversable)—The network element that the point is located on is not traversable. This can occur when the 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 exists where positive numbers are required.
  • 5 (Not Reached)—The point can't be reached by the solver. The point may be on a separate, disconnected area of the network from the other inputs, or barriers or restrictions prevent travel to or from the point.
  • 6 (Time window violation)—The point could not be reached within the designated time windows. This status only applies to network analysis types that support time windows.
  • 7 (Not located on closest)—The closest network location to the point is not traversable because of a restriction or barrier, so the point has been located on the closest traversable network feature instead.

SnapX

The x-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.

SnapY

The y-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.

SnapZ

The z-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset. The SnapZ field is 0 if the network is two dimensional.

DistanceToNetworkInMeters

The distance in meters between the point's geographic location and the position where it was located on the network.

Cutoff_[Cost]

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

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 following table describes the attributes of the output destinations:

FieldDescription
ObjectID

The object ID of the input destination. If ObjectID is not specified, it will be system generated ID for the destination.

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 network dataset source feature class on which the input point is located.

SourceOID

The ObjectID of the feature in the source on which the input point is located.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

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. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

CurbApproach

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

Status

Indicates the status of the point with respect to its location on the network and the outcome of the analysis. The possible values are the following:

  • 0 (OK)—The point was successfully located on the network.
  • 1 (Not Located)—The point was not successfully located on the network and consequently was not included in the analysis.
  • 2 (Network element not located)—The network element identified by the point's network location fields can't be found. This can occur when a network element where the point should be was deleted, and the network location was not recalculated.
  • 3 (Element not traversable)—The network element that the point is located on is not traversable. This can occur when the 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 exists where positive numbers are required.
  • 5 (Not Reached)—The point can't be reached by the solver. The point may be on a separate, disconnected area of the network from the other inputs, or barriers or restrictions prevent travel to or from the point.
  • 6 (Time window violation)—The point could not be reached within the designated time windows. This status only applies to network analysis types that support time windows.
  • 7 (Not located on closest)—The closest network location to the point is not traversable because of a restriction or barrier, so the point has been located on the closest traversable network feature instead.

SnapX

The x-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.

SnapY

The y-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.

SnapZ

The z-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset. The SnapZ field is 0 if the network is two dimensional.

DistanceToNetworkInMeters

The distance in meters between the point's geographic location and the position where it was located on the network.

barriers

This provides access to points that act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets.

Field nameDescription

ObjectID

The object ID of the associated input barrier. If ObjectID is not specified, it will be system generated ID for the barrier.

Name

The name of the barrier.

SourceID

The numeric identifier of the network dataset source feature class on which the input point is located.

SourceOID

The ObjectID of the feature in the source on which the input point is located.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

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. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

CurbApproach

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.

Status

Indicates how the barrier was evaluated in the analysis. The possible values are the following:

  • 0 (OK)—The barrier was successfully located on the transportation network and analyzed.
  • 1 (Not Located)—The barrier was not included in the analysis since a traversable road was not found within the maximum search distance from the feature.
  • 3 (Elements not traversable)—The network element that the barrier 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.

FullEdge

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.

BarrierType

Specify if 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.
  • 2 (Added Cost)- Traveling through the barrier increases the travel time or distance by the amount specified in the Attr_[Cost] property value

Attr_[Cost]

(for instance Attr_TravelTime, where TravelTime is the travel cost)

This property is specific to added-cost barriers and is limited to values that are greater than or equal to zero. It indicates how much cost is added when the barrier is traversed.

polylineBarriers

This provides access to one or more lines that prohibit travel anywhere the lines intersect the streets.

Field nameDescription

ObjectID

The object ID of the associated input polyline barrier. If ObjectID is not specified, it will be system generated ID for the polyline barrier.

Name

The name of the barrier.

BarrierType

Specify if the barrier restricts travel completely or scales 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 line barrier since it acts as a restriction.
  • 1 (Scaled Cost)-Scales the time or distance required to travel the underlying streets by a factor specified using the Attr_[Cost] attribute.

Attr_[Cost]

(for instance Attr_TraveTime, where TravelTime is the travel cost)

This property is specific to scaled-cost barriers. It is the factor by which the cost of edges underlying the barrier are multiplied.

polygonBarriers

This provides access to polygons that either completely restrict travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons.

Field nameDescription

ObjectID

The object ID of the associated input polygon barrier. If ObjectID is not specified, it will be system generated ID for the polygon barrier.

Name

The name of the barrier.

BarrierType

Specify if the barrier restricts travel completely or scales 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 traveling through any part of the barrier. The barrier is referred to as restriction polygon barrier since it prohibits traveling on streets intersected by the barrier.
  • 1 (Scaled Cost)—Scales the time or distance required to travel the underlying streets by a factor specified using the Attr_[Cost] attribute.

Attr_[Cost]

(for instance Attr_TravelTime, where TravelTime is the travel cost)

This property is specific to scaled-cost barriers. It is the factor by which the cost of edges underlying the barrier are multiplied.

Example usage

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

https://route.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/NAServer/OriginDestinationCostMatrix_World/solveODCostMatrix?<parameters>

The Origin Destination Cost Matrix service supports synchronous and asynchronous execution modes.

The request URL and the parameter names supported by the service when using asynchronous execution are different and described in Origin Destination Cost Matrix service with asynchronous execution.

Calculate total travel time and distance between two cities

This example shows how to calculate total travel time and distance between two cities (San Diego and Los Angeles), a typical Origin Destination Cost Matrix problem.

Specify the same two cities as the origins and destinations parameter to get travel time and distance traveling between these two cities. Use the JSON structure to specify the origins and destinations parameter, to specify the Name and ObjectID of the cities that will be included in the service output.

Request URL

https://route.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/NAServer/OriginDestinationCostMatrix_World/solveODCostMatrix?origins=
{"spatialReference":{"wkid":102100},"features":[{"geometry":{"x":-13042381.897669187,"y":3857625.761983883},"attributes":{"ObjectID":1,"Name":"San Diego"}},
{"geometry":{"x":-13163008.811087687,"y":4035986.6896486743},"attributes":{"ObjectID":2,"Name":"Los Angeles"}}]}&destinations={"spatialReference":{"wkid":102100},"features":[{"geometry":{"x":-13042381.897669187,"y":3857625.761983883},"attributes":{"ObjectID":1,"Name":"San Diego"}},
{"geometry":{"x":-13163008.811087687,"y":4035986.6896486743},"attributes":{"ObjectID":2,"Name":"Los Angeles"}}]}&f=pjson&token=<yourToken>

JSON response example

The default outputType is esriNAODOutputSparseMatrix, so the response is a matrix format. The default impedanceAttributeName is TravelTime, and the default accumulateAttributeNames are Miles and Kilometers in the example below. The response contains the travel time, travel distance in miles and travel distance in kilometers between San Diego and Los Angeles. Within odCostMatrix property, each nested JSON is composed of origin ObjectID, destination ObjectID, and the costs from origin to destination in the order defined in the costAttributeNames.

{
  "messages": [],
  "odCostMatrix": {
    "1": {
      "1": [
        0,
        0,
        0
      ],
      "2": [
        157.0376430630198,
        124.20114191467465,
        199.88236253353011
      ]
    },
    "2": {
      "1": [
        158.82792954092292,
        124.16291635554705,
        199.82084445930158
      ],
      "2": [
        0,
        0,
        0
      ]
    },
    "costAttributeNames": [
      "TravelTime",
      "Miles",
      "Kilometers"
    ]
  }
}

JSON response syntax

The JSON response from the Origin Destination Cost Matrix service is based on the following syntax when outputType is esriNAODOutputSparseMatrix. The properties returned in the response are based on the request parameters. For example, the origins property is returned only if the returnOrigins parameter is set to true. If a request fails, the JSON response only contains the error property. The examples in the subsequent section illustrate the response returned with specific request parameters.

JSON Response syntax for successful request

{
  "odCostMatrix": {
    "<OriginID1>": {
      "<DestinationID1>": [
        <costAttribute1Value1>,
        <costAttribute2Value1>
      ],
      "<DestinationID2>": [
        <costAttribute1Value2>,
        <costAttribute2Value2>
      ]
    },
    "<OriginID2>": {
      "<DestinationID1>": [
        <costAttribute1Value3>,
        <costAttribute2Value3>
      ],
      "<DestinationID2>": [
        <costAttribute1Value4>,
        <costAttribute2Value4>
      ]
    },
    "costAttributeNames": [
      "<costAttribute1>",
      "<costAttribute2>"
    ]
  },
  "origins": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<point1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<point2>}
      }
    ]
  },
  "destinations": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<point1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<point2>}
      }
    ]
  },
  "barriers": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<point1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<point2>}
      }
    ]
  },
  "polylineBarriers": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<polyline1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<polyline2>}
      }
    ]
  },
  "polygonBarriers": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<polygon1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<polygon2>}
      }
    ]
  }
}

JSON Response syntax for failed request

{
  "error": {
    "code": <code>,
    "message": "<message>",
    "details": ["<details>"]
  }
}

When outputType is esriNAODOutputStraightLines or esriNAODOutputNoLines, the JSON response from Origin Destination Cost Matrix service includes odLinesproperty.

JSON Response syntax for successful request when outputType is esriNAODOutputStraightLines

When the outputType is esriNAODOutputStraightLines, the odLines property include geometry property for each feature.

{
  "odLines": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<polyline1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<polyline2>}
      }
    ]
  }
}

JSON Response syntax for successful request when outputType is esriNAODOutputNoLines

When outputType is esriNAODOutputNoLines, the odLines property doesn't include geometry property for each feature.

{
  "odLines": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        }
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        }
      }
    ]
  }
}

Usage limits

The table below lists the limits that apply to this service.

Limit descriptionLimit value

Maximum number of origins

10

Maximum number of destinations

10

Maximum number of (point) barriers

250

Maximum number of street features intersected by polyline barriers

500

Maximum number of street features intersected by polygon barriers

2,000

Force hierarchy beyond a straight-line distance of

(If the straight-line distance between any facility and demand point is greater than the limit shown here, the analysis uses hierarchy, even if useHierarchy is set to false.)

50 miles (80.46 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.)

12.42 miles (20 kilometers)

Maximum time a client can use the synchronous service

5 minutes (300 secods)