Back to Mapbox in Google Sheets
SheetXAI logo
Mapbox logo
Mapbox · Google Sheets Guide

Calculate a Driving-Time Matrix Between Locations in a Google Sheet

2026-05-14
5 min read

The Scenario

A real estate analyst on your team put together a Google Sheet with twenty property addresses in column A and five school addresses in column E. The VP of acquisitions wants a driving-time matrix — how many minutes from each property to each school — before the investment committee call on Friday morning. It is Wednesday. You inherited the task when the analyst who built the sheet left for vacation this morning.

The bad version:

  • Open the Mapbox Matrix API docs, read through the authentication section, realize you need to geocode all twenty-five locations before you can even start the matrix call.
  • Write or copy a Python script, run it locally, debug the JSON response shape, figure out why the matrix only accepts 25 origin-destination pairs per call and your 20x5 grid requires pagination logic.
  • Get results back as a flat list of durations and spend thirty minutes figuring out how to reshape them into the 20x5 grid the committee wants to see.

The committee call is at 9 AM Friday. The analyst is on a flight to Lisbon.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent that lives inside your Google Sheet. It reads the property and school addresses, calls Mapbox to geocode them and compute the driving-time matrix, then writes the results into the grid format you need — without you writing a line of code or reshaping a JSON payload.

Use the Mapbox travel time matrix to calculate driving durations in minutes between all origin addresses in column A and destination addresses in column E, then fill the results starting at cell G2 as a grid — rows correspond to properties in column A, columns correspond to schools in column E.

What You Get

  • A 20x5 grid starting at G2, where each cell contains the driving time in minutes between the property in that row and the school in that column.
  • Header row in G1:K1 with the school names pulled from column E for easy reading.
  • Any origin-destination pairs that Mapbox cannot resolve — due to ambiguous addresses or routing failures — appear as N/A in the grid cell rather than a blank that looks like zero.

What If the Data Is Not Quite Ready

Some property addresses are missing city or ZIP

A handful of addresses in column A have only street and state, which might geocode to the wrong city.

Before computing the matrix, check column A for addresses that appear to be missing a city. For each incomplete address, use context from the surrounding rows — same ZIP or city — to fill in the missing city field. Then run the driving-time matrix using Mapbox and fill the grid starting at G2.

You need driving times and straight-line distances side by side

The committee wants both driving time and crow-flies distance to evaluate whether the route penalty is significant.

Compute a driving-time matrix in minutes using Mapbox for all origin-destination pairs (column A origins, column E destinations) and write it starting at G2. Then compute the straight-line distance in kilometers for each pair and write that into a second grid starting at M2, using the same row/column alignment.

The school list is on a different tab

The schools are on a tab called Schools, column A, and the properties are on a tab called Properties, column A.

Compute a Mapbox driving-time matrix between all addresses in column A of the Properties tab and all addresses in column A of the Schools tab. Write the result grid to a new tab called Drive Times, with property addresses as row labels and school names as column headers.

Full pipeline: geocode, compute matrix, flag long commutes, and sort properties by average drive time

Geocode all addresses in column A and column E using Mapbox. Compute the full driving-time matrix in minutes and fill it starting at G2. Then add a column in F called Avg Drive Time that averages each property row's driving times across all five schools. Highlight any matrix cell above 20 minutes in column G with a note LONG. Sort the entire dataset by column F ascending so the best-located properties appear first.

One prompt handles geocoding, matrix computation, aggregation, and sorting without running separate steps.

Try It

Get the 7-day free trial of SheetXAI and open the next property analysis workbook your team hands you — paste the addresses in, describe the matrix shape you need, and let SheetXAI call Mapbox and build the grid. The route optimization article covers the multi-stop sequencing problem if you need to go beyond point-to-point times. The full Mapbox hub has every geographic workflow.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more