Travel cost matrix
A travel cost matrix between five major cities in Australia. Each row in the table represents the driving time in minutes and the driving distance in kilometers between a city pair.
What is a travel cost matrix?
A travel cost matrix, also known as the origin-destination (OD) cost matrix, is a table or a matrix containing the cost, such as the travel time or travel distance, from multiple origins to multiple destinations. 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.
You can use a travel cost matrix to build applications that:
- Determine the accessibility of real estate by measuring the driving or walking time from the property to various nearby attractions.
- Predict the travel behavior of people in a city by calculating the distances people would need to travel to reach certain attractions.
- Calculate the shipping costs between postal codes using the travel distances from the cost matrix.
- Use the travel cost matrix as an input in other mathematical models, for example, linear programming, that can be used to make better decisions.
How a travel cost matrix works
The typical workflow for generating a travel cost matrix is to define:
- Starting locations from which to travel to the destinations.
- Ending locations to travel to from the origins.
- The type of travel for the analysis.
- Call the service to find the travel cost matrix between origins and destinations.
URL requests
You can create travel cost matrix by making an HTTPS request to the origin-destination cost matrix service solve
operation or by using client APIs. Specify one or more origins and destinations, and optionally, additional parameters to refine the operation. Some of the most common parameters are described below.
Required parameters
Name | Description | Examples |
---|---|---|
f | The format of the data returned. | f=json f=pjson |
token | An API key or OAuth 2.0 access token. Learn how to get an access token in Security and authentication. | token=< token=< |
Direct
Use for shorter transactions with up to 10 origins and 10 destinations that will complete in less than 5 minutes.
Key parameters
Name (Direct) | Description | Examples |
---|---|---|
origins | Starting locations from which to travel to the destinations. | origins=-118.245843,34.057794;-117.16274,32.719178 |
destinations | Ending locations to travel to from the origins. | destinations=-117.182676,34.055909;-118.144184,34.147832 |
travel | The mode of transportation such as driving a car or a truck or walking. | travel JSON Object |
default | The number of destinations to find per origin. A null value or no value for this parameter results in a search for all destinations from every origin. | default default |
default | The travel time or travel distance value at which to stop searching for destinations from a given origin. The default value is null which means to search until all destinations are found for every origin. The units are time or distance based depending on your travel mode. | default |
Additional parameters: Set additional constraints when creating the travel cost matrix such as time
to use live traffic conditions or output
to specify if the output is a table or a matrix representing travel costs.
Job
Use for longer transactions with up to 1,000 origins and 1,000 destinations that will complete in less than 60 minutes.
Key parameters
Name (Direct) | Description | Examples |
---|---|---|
origins | Starting locations from which to travel to the destinations. | origins={"features":[{"geometry":{"x":-118.245843,"y":34.057794}},{"geometry":{"x":-117.16274,"y":32.719178}}]} |
destinations | Ending locations to travel to from the origins. | destinations={"features":[{"geometry":{"x":-117.182676,"y":34.055909}},{"geometry":{"x":-118.144184,"y":34.147832}}]} |
travel_ | The mode of transportation such as driving a car or a truck or walking. | travel_ JSON Object |
number_ | The number of destinations to find per origin. A null value or no value for this parameter results in a search for all destinations from every origin. | number_ number_ |
cutoff | The travel time or travel distance value at which to stop searching for destinations from a given origin. The default value is null which means to search until all destinations are found for every origin. The units are time or distance based depending on your travel mode. | cutoff=5 |
Additional parameters: Set additional constraints when creating the travel cost matrix such as time_
to use live traffic conditions or output_
to specify if the output is a table or a file in CSV or GeoJSON format.
Code examples
Direct: Create time-distance matrix
In this example, the travel cost matrix service is used to find the travel time and travel distance between five major cities in Australia. Such a matrix can be used to calculate the cost of shipping goods between these cities by using the travel time and travel distance between any city pair.
To create the travel cost matrix, you need to provide the origins
and destinations
. In this example, the origins and destinations are identical, but they can be different. By default, the output matrix contains a system-generated identifier to represent each origin and destination. If you need to use your own identifier, you must pass this identifier as the Object
field when specifying the inputs.
The response contains o
that contains an array of travel costs in minutes, miles, and kilometers between each origin ID and all the destination IDs. The order of the travel costs are based on the cost
.
APIs
REST API
Job: Calculate walkability
In this example, the walkability is calculated for the location of real estate property to basic amenities such as ATMs, restaurants, grocery stores, and parks. To determine walkability, you need to first find the walking distance (travel distance) to all of the amenities from the property location using the travel cost matrix service. Once you have all of the travel distances between the property location and the amenities, you can use them in a mathematical formula (such as a weighted mean) to calculate walkability.
You specify the property location as origins
and the amenities as destinations
. The default travel_
is driving time, so in this case the travel mode is set to walking distance.
APIs
REST API
Unlike Direct request type which allows you to make a request and get back all the results in the response, when working with a Job request type, you need to follow a three step workflow:
- Make the
submit
request with the appropriate request parameters to get a job id.Job - Using the job id, check the job status to see if the job completed successfully.
- Use the job id to get one or more results.
Tutorials

Find a route and directions
Find a route and directions with the routing service.

Find service areas
Create an isochrone with driving distance with the routing service.
Services
Routing service
Get turn-by-turn directions and solve advanced routing problems.
API support
Routing | Optimized Routing | Fleet routing | Closest facility routing | Service areas | Location-allocation | Travel cost matrix | |
---|---|---|---|---|---|---|---|
ArcGIS Maps SDK for JavaScript | 1 | 1 | 1 | ||||
ArcGIS Maps SDK for .NET | 1 | 1 | 1 | ||||
ArcGIS Maps SDK for Kotlin | 1 | 1 | 1 | ||||
ArcGIS Maps SDK for Swift | 1 | 1 | 1 | ||||
ArcGIS Maps SDK for Java | 1 | 1 | 1 | ||||
ArcGIS Maps SDK for Qt | 1 | 1 | 1 | ||||
ArcGIS API for Python | |||||||
ArcGIS REST JS | |||||||
Esri Leaflet | 2 | 2 | 2 | 2 | 2 | 2 | 2 |
MapLibre GL JS | 2 | 2 | 2 | 2 | 2 | 2 | 2 |
OpenLayers | 2 | 2 | 2 | 2 | 2 | 2 | 2 |
- 1. Access with geoprocessing task.
- 2. Access via ArcGIS REST JS.
Tools
Developer dashboard
Manage API keys, service usage, and data with the ArcGIS Developers website.
ArcGIS Online
Create, manage, and share content and data with cloud-based GIS tools.
Map Viewer
Create, explore, and share web maps for 2D applications.
Scene Viewer
Create, explore, and share web scenes for 3D applications.
ArcGIS Pro
Explore, visualize, and analyze both 2D and 3D data with desktop GIS tools.