MapTools
distance driveFree · No signup

Distance Matrix Calculator

Compute an N x N distance and travel time matrix for 2 to 50 locations. Visualize with interactive heatmap and export CSV.

Total Route Distance
0 mi
4 Stops (One-Way)
Total Drive Time
0 min
Standard highway & arterial speeds
Route Options

Waypoints4 / 25

1
Times Square
Times Square, New York, NY
2
Independence Hall
Independence Hall, Philadelphia, PA
3
National Mall
National Mall, Washington, DC
4
Shenandoah NP
Shenandoah National Park, VA
Loading Google Maps JavaScript Canvas...
Drag waypoints in the list or click 'Optimize Order' to solve TSP.

Runs entirely in your browser — your inputs never leave this page.

How this tool works

  1. 1

    Calculates pairwise distances across all origin and destination combinations and formats into a symmetric or asymmetric matrix.

Common uses

  • Supply chain hub selection
  • Fleet territory planning
  • University campus logistics

Frequently asked questions

Yes, you can export in both matrix grid (wide) and pair-list (long) CSV formats.

More in Distance & Driving

View all →
Worked example

One Depot, Three Stores: Reading a 4 by 4 Matrix in Dallas

An analyst for a small Dallas grocery chain needs every distance among four places: the central depot and three stores, Store A, Store B, and Store C, including the store-to-store runs a shuttle van makes. Doing this one pair at a time would mean a dozen separate lookups and plenty of chances to mistype a number. She enters the four locations once and gets a 4 by 4 matrix instead: 16 cells, with a diagonal of zeros, because every place is zero miles from itself. What would have been an afternoon of separate lookups and sticky notes becomes one grid she can sort, color, print, and argue with in the Monday meeting.

The distances she reads off are these, in miles: depot to A is 6, depot to B is 11, depot to C is 14, A to B is 5, A to C is 9, and B to C is 4. That is six unique pairs, which matches the counting rule for any matrix, since 4 times 3 divided by 2 equals 6. The distance half of the grid mirrors across the diagonal, so each pair appears twice, once in each direction, and she can read any pair from whichever side is convenient.

Decisions fall straight out of the numbers. The closest pair in the whole system is B to C at 4 miles, the natural shuttle pairing, and a daily round trip there is only 8 miles. The same grid quietly exposes a standing problem: C is the depot's farthest store at 14 miles, which explains why its delivery slot has always been the tight one, and why nobody should promise that store a late-morning arrival. The depot's nearest store is A at 6 miles, and at a city average of 30 mph, 6 divided by 30 is 0.2 hours, about a 12-minute run. Averaging the depot's three store runs, 6 plus 11 plus 14 divided by 3, gives about 10.3 miles per run, the figure she carries into weekly fuel planning before exporting the matrix to CSV for the operations spreadsheet.

One caution comes with the travel-time half of the output: times do not mirror as politely as distances. One-way streets, banned turns, and the direction of the morning rush can make one direction noticeably slower than the other at identical mileage; on a corridor like depot to B, for instance, the outbound morning run can take several minutes longer than the return. The heatmap view of the matrix exists precisely for this, making the expensive and lopsided pairs visible at a glance instead of hiding in a grid of numbers. For a network of this size the whole exercise takes minutes, and it scales gracefully to the day the chain opens its tenth store and the pairing questions multiply.

Common mistakes to avoid

  • Reading the zero diagonal as a real route. The diagonal is each location measured against itself, and it is always zero. Folding those zeros into averages quietly drags every statistic down and makes the whole network look closer and cheaper than it really is.
  • Assuming times are symmetric like distances. Distance mirrors across the diagonal, but travel time is directional. One-way systems, turn restrictions, and rush-hour flow mean the trip out and the trip back rarely take the same minutes, so read the time cells in the direction you will actually drive.
  • Mixing units across exported matrices. A matrix exported in miles pasted beside one exported in kilometres corrupts every plan built on top of them, and the numbers look plausible enough to escape notice. Check the unit setting before you export, every single time.

Pro tips

  • Scan the heatmap for the darkest cells first, because those are your most expensive pairs and the first candidates for change.
  • Use the matrix to settle shuttle pairings and depot assignments before the season starts, not in the middle of a crisis.
  • Keep planning reads to a dozen locations or fewer; save the big 50-location matrices for export and spreadsheet analysis.
Geospatial Engineering Reference & Field Manual

Distances, Routes & Drive Times: How Mapping Math Works

Why the Earth refuses to be flat, how calculators measure true distances, how road networks find your route, and what those drive-time blobs on the map really mean. Written for Distance Matrix Calculator and the everyday mapping tasks around it.

1

The Earth Is Not Flat (and Your Math Must Know It)

For a walk to the corner store, flat math is fine. For a drive from Chicago to Denver, it is not. The Earth bulges at the equator and flattens at the poles — an oblate ellipsoid about 13 miles wider than it is tall. Ignore that shape and long distances come out wrong by miles.

Surveyors model the planet with the WGS84 ellipsoid: an equatorial radius of 3,963 miles and a polar radius of 3,950 miles. Every serious distance tool, including the ones on this site, measures along this curved surface rather than through the planet's interior.

The practical rule is simple. Under about 10 miles, flat-map math and true geodesic math agree to within a few feet. Past 100 miles, the gap grows fast. A flight from New York to London measured on a flat map would miss by over 200 miles — which is why aviation never uses flat math.

2

Haversine vs. Vincenty: Two Ways to Measure

The Haversine formula treats the Earth as a perfect sphere. It is a few lines of code, runs instantly, and gets within about 0.5% of the true distance. For store locators and "places near me" features, that is plenty. Most web maps use it under the hood.

Vincenty's method goes further. It walks the actual WGS84 ellipsoid, iterating until the answer converges, and lands within millimeters on distances of thousands of miles. The cost is complexity: the math needs a dozen steps and can fail to converge for nearly antipodal points, though modern implementations handle that gracefully.

Which should you trust? For driving estimates and everyday questions, both agree closely enough that you will never notice. For surveying, aviation, and scientific work, Vincenty or its modern successor Karney's algorithm is the standard. This site uses ellipsoidal math wherever precision matters.

One more subtlety: "distance" has flavors. Great-circle distance is the shortest path over the surface. Rhumb-line distance holds one compass bearing the whole way — longer, but easier to steer by hand, which is why sailors used it for centuries.

This page shows the first two chapters. Read the complete Distance & Drive Time field guide →