Skip to main content
All CollectionsGIS PluginsAlteryxAlteryx Tutorials
How to create travel time matrices in Alteryx
How to create travel time matrices in Alteryx

Tutorial on creating travel time matrices (distance matrices) with the Alteryx Travel Time Matrix macro.

Updated over a week ago

The Travel Time Matrix macro can be used to create Origin-Destination journey time matrices, as well as distance matrices and public transport fare matrices.

If you haven't already installed the macro, you can download it from the Alteryx Gallery here .

To use the macro, drag it onto an Alteryx workflow from the TravelTime Platform tab in the top navigation.

Next we need to connect to some input data. This can be done either by connecting to a file using the Input Data tool, or by entering data manually using the Text Input tool.

The input data needs to contain the four fields as a minimum:

1. Origin Latitudes

2. Origin Longitudes

3. Destination Latitudes

4. Destination Longitudes

If your location data is in the form of addresses (e.g Postcodes) and not lat-long coordinates, then you can use our Geocoder macro to make this conversion first, before using the Travel Time Matrix macro.

In the example below we begin with one file of 500 origin postcodes, and 5 destination postcodes. These are then converted into lat-long coordinates using the Geocoder macro, before being combined into a single file using the Append Fields tool:

Input-data

To configure the macro you first need to enter your API key details in the Credentials tab of the tool configuration.

api-key


If you don't already have a TravelTime API key, you can get one for free here.

On the Configuration tab we select the fields in the input data that contain the Latitude and Longitude values for both the Origins and the Destinations, as well as whether we want to run an 'Arriving By' or 'Departing At' search.

config1

Configuring the fields to maximise performance

The TravelTime API which is used when running the macro is optimised for 1-to-many calculations when running an 'Arriving By' search, and for many-to-1 calculations when running a 'Departing At' search.

To maximise performance of the macro (both in terms of time to complete and staying within your usage limits) is it therefore recommended to use one of the following setups:

  1. Arriving By - use the smaller set of locations as the 'To' coordinate fields (e.g a morning commute analysis of journeys from employee home addresses to a number of offices)

  2. Departing at - use the smaller set of locations as the 'From' coordinate fields (e.g an evening commute analysis of journeys from a number of offices, to employee home addresses)

On the next tab, Basic, we choose the method(s) of transport (ticking multiple allows different matrices to be created for different transport methods), and the date/time.

Selecting the Get Fare Data? tick-box will add public transport fare data to the macro output - this is only currently available in the UK.

config2

For an 'Arriving By' search, this date/time is the arrival time. For a 'Departing At' search, this date/time is the departure time.

Finally, the parameters in the Advanced tab can be used to fine-tune the analysis if required.

config3

These Advanced fields only apply to transport types that involve public transport. For a full explanation of what each field means, please see the documentation here.

The output of the Travel Time Matrix macro contains a Metric field and a Value field.

Each row of the output data contains one Origin, one Destination, and one Metric. Possible values of the Metric field are:

  • distance

  • travel_time

  • Fare single (GBP)

  • Fare week (GBP)

  • Fare month (GBP)

  • Fare year (GBP)


To create the desired matrix, we add a Filter tool to isolate the Metric we are interested in, followed by a Cross Tab tool.

For any records that cause an error, details of the error can be found in the Failure output anchor, including the Error Code and links to more information.

In the example below we apply two filters:

"Query Transport Method" = Driving

"Metric" = travel_time

We then add a Cross Tab tool with the following configuration:

Crosstab

The resulting output is a matrix of travel times with our 500 employee postcodes in the rows and the 5 office postcodes as the column headings:

Output


To create a matrix of distances or public transport fares, simply change the value in the Metric filter.

Did this answer your question?