All posts

Noël Vranckx • • 11 min read

Geocoding and distance APIs for network design

Every network study stands on two numbers per customer: where it is, and how far away. Most studies guess both. Here are the APIs that measure them, what they cost, and a sixth-hub test on Upshift’s dealers that shows why the guess is the expensive part.

Illustration of a 1950s transport office wall with a road map pinned to a cork board, a brick-red string stretched straight between two brass pins while the drawn road between them loops around a lake, and a plank shelf below with a surveyor’s measuring wheel, a brass map-measuring wheel, a pair of dividers, a folded map and a pencil

*A network model is only as good as the distances you feed it. The solver gets the credit. The distance matrix does the work.*

The cleverest optimiser in the world cannot repair a wrong distance.

Yet most network studies I have seen start from a spreadsheet of straight-line distances, or from a colleague’s memory of how long the lorry takes. The solver then grinds those numbers into a confident answer. The answer is exactly as reliable as the guess underneath it.

Ask a chatbot how far Antwerp is from Lyon by road and you get the same thing: an answer from memory, sometimes close, never checkable. That is not the model’s fault. Nobody gave it a map.

The map exists, and it comes as a set of APIs. One turns an address into coordinates. Another turns two lists of coordinates into a matrix of kilometres and hours, and a third draws the area a driver can reach before lunch.

This post is about those APIs, what they cost and where they trip you up. A test on the fictional Upshift network shows how much they change the answer.

What these APIs are

Four questions cover almost everything a network or distribution study asks the map. Each has its own family of services.

Where is it? Geocoding turns “Rue de Fer 12, 5000 Namur” into a latitude and longitude. Google, HERE and Mapbox sell it, Nominatim on OpenStreetMap gives it away, and OpenCage and Geoapify wrap open data into a supported service.

Several European registers are free and official: the Flemish address register, Belgium’s federal BeST files and the Dutch PDOK Locatieserver. The French Géoplateforme geocoder even takes a CSV of up to 200,000 lines in one upload.

How far, and how long? A matrix API takes a list of origins and a list of destinations and returns distance and time for every pair. Request limits differ a lot.

Google’s Routes API caps a matrix at 625 elements and Mapbox at 25 coordinates. HERE goes to 10,000 by 10,000 as a batch job, and PTV Developer takes 1,000 locations and adds tolls.

If you would rather own the engine, OSRM, Valhalla, GraphHopper and OpenRouteService are open source and run on OpenStreetMap data. A 5,000 by 20 matrix then costs a server, not a bill. In North America, Trimble’s PC*MILER describes itself as the industry standard for truck mileage.

Truck matters. Google’s TRUCK mode is limited to selected customers and covers the contiguous United States, so in Europe its matrix is a car matrix. HERE, TomTom, PTV, AWS, Azure and Valhalla take weight, height, axles and hazardous goods, and route around the bridges a 40-tonne lorry cannot use.

What can we reach in two hours? Isochrone APIs draw the area reachable from a site within a given time. HERE’s Isoline goes up to nine hours with a truck profile, Mapbox stops at 60 minutes, and OpenRouteService’s public API at one hour.

What else does the lane cost? HERE returns tolls per section for cars and trucks, and PTV forecasts future toll rises. Searoutes gives port-to-port sea distance and duration. EcoTransIT World and Climatiq turn a lane into CO2 under the GLEC Framework and ISO 14083, the 2023 standard for transport emissions.

Here are the ten I would shortlist for a network study, with the vendors’ list prices on 30 September 2026. HERE marks its page as indicative, and HERE and TomTom count matrix “transactions” with a formula that favours large matrices.

APIWhat it gives a network studyFree band, then list priceWorth knowingSource
Google Maps PlatformGeocoding, address validation, route matrix10,000 geocodes and 10,000 matrix elements a month, then $5 down to $0.38 per 1,000625 elements a request; truck mode only for selected customers in the US; coordinates cached 30 days at mostPricing
HEREGeocoding, matrix up to 10,000 by 10,000, isolines, tolls30,000 geocodes and 2,500 matrix transactions a month, then €0.70 and €4.66 per 1,000Truck profiles with weight, height and hazardous goods; results kept 30 days at mostPricing
MapboxGeocoding, matrix, isochrones, an MCP server100,000 geocodes and 100,000 matrix elements a month, then $0.75 and $2 per 1,00025 coordinates a matrix request; cheap geocodes may not be stored, permanent ones cost $5 per 1,000Pricing
TomTomMatrix routing with truck profiles, an MCP server2,500 matrix transactions a month, then €3 down to €1.95 per 1,000100 elements a synchronous request, 2,500 as a batch job, 100 million on the enterprise tierPricing
PTV DeveloperTruck matrix with toll costs on European road dataFree trial, then prices on request; none published on the pages I opened1,000 locations a request; toll prices only in the asynchronous modeDocs
OpenCageGeocoding on open data, results yours to keep2,500 requests a day on trial, then €45 to €900 a month for 10,000 to 300,000 a dayAttribution required; no matrixPricing
GraphHopperMatrix and route optimisation, hosted or self-run500 credits a day free for non-commercial use, then €69 to €479 a month for 5,000 to 50,000 a dayA matrix costs origins times destinations divided by two credits; the engine is Apache 2.0Pricing
openrouteserviceMatrix and isochrones on OpenStreetMapFree: 500 matrix requests a day, 3,500 elements eachRun your own instance for no limitsRestrictions
OSRMThe fastest self-hosted matrixFree under the BSD licence; you pay for the serverCar, bicycle and foot profiles; 100 locations a table by default, configurableDocs
ValhallaSelf-hosted matrix with truck costingFree under the MIT licence; you pay for the serverRespects height, width, weight and hazardous-goods restrictionsDocs

Not in the ten, but free and official: Nominatim, at one request a second and no bulk runs, and the Belgian, Dutch and French address registers above.

What it means for supply chain

I think of distance data as a ladder. Every rung costs more than the one below, and most questions have a rung that is good enough.

RungWhat you measureWhere it comes fromGood enough for
1Straight lineA formula in the spreadsheetA first centre-of-gravity sketch
2Straight line times a circuity factorThe same formula and one constant per countryScreening candidate regions
3Road distance, car profileA matrix API, or your own OSRMAllocating customers to hubs, cost-to-serve
4Road distance and time, truck profileHERE, TomTom, PTV, ValhallaLane costing, tender benchmarks, service promises
5Plus tolls, ferries, driver hours and CO2Toll, sea-route and emission APIsRoute design, lane cost, ISO 14083 reporting

The circuity factor on rung 2 has a literature. Ballou’s 2002 country factors, as reported in an MIT lecture, put Germany at 1.32, Poland at 1.21 and France at 1.65. A 2012 study of 66,000 US locations found roads 1.417 times longer than the straight line.

Where the rungs land in practice:

  • Greenfield and the sixth hub. Rung 2 screens candidate regions across thousands of customers for free, and rung 3 confirms the shortlist.
  • Allocating customers to hubs. Rung 3 is the minimum. Straight lines misallocate anyone near a coast, a mountain range or a ferry.
  • Lane benchmarks for the transport tender. Rung 4 gives the kilometres a carrier will actually drive, so a rate per kilometre means something.
  • Service promises by drive time. Isochrones show which postcodes a hub can reach next day, before you promise it.
  • CO2 per lane. ISO 14083 reporting needs a distance per leg and per mode, and a matrix per mode is the raw material.
  • A map for your AI agent. Mapbox and TomTom publish MCP servers with geocoding, matrix and isochrone tools, so an assistant can measure instead of guess.

The Upshift scenario list has a question that touches all of this: should the company open a sixth hub in Vienna? Let’s climb the ladder with it.

Worked example: does a Vienna hub pay off?

Upshift, the fictional bicycle maker behind this site, ships from five hubs (Venlo, Kassel, Lyon, Northampton and Basel) to 52 customers in nine countries. I ran the study on 30 September 2026 with two free services: Nominatim for geocoding and the public OSRM demo server for road distances. The numbers are real outputs on that small dataset, unweighted per customer, and you can rerun them from the [Upshift dataset](/dataset).

Step 1: geocode the file as it is. Fifty-two rows went in and ten came back empty. Three had a city in the wrong country: Stuttgart filed under Switzerland, Bordeaux under Germany, Utrecht under “Deutschland”. Seven were British rows with “UK” instead of “GB”, or a postcode district like M1 instead of a full postcode.

The other 42 resolved, all at city level, because the file has no street. That is the first result of any geocoding run: a list of rows you must fix by hand.

Step 2: screen with a straight line. With the countries corrected, a haversine formula gave the crow-flies distance from every customer to every hub. Multiplied by a circuity factor, that approximates road. Across my own matrix the median factor came out at 1.28, between Ballou’s Poland and Germany.

Step 3: ask for one matrix. Eight sites (two plants, five hubs and the Vienna candidate) by 30 distinct customer towns is 240 elements. OSRM returned distance and drive time for all of them in one call, in under a second. On Google that is 240 elements and on HERE or TomTom 150 transactions, all inside the free bands.

Step 4: compare the rungs. Allocate each customer to the nearest hub by straight line, then measure the result by road: 389 km per customer on average. Allocate by road instead: 347 km, twelve per cent less. Four customers flip.

Paris sits 392 km from Venlo and 393 km from Lyon as the crow flies, but 476 km and 463 km by road.

Three customers in Bergen look closest to Northampton on a globe, 984 km away. By road they are closest to Kassel, 1,836 km and 23 hours later. Nobody drives a bike delivery for 23 hours, so the real lane is a short-sea crossing, and the matrix showed exactly where the road stops being the right question.

Step 5: answer the Vienna question. Add the sixth hub and three customers move to it: Vienna itself, Graz and Warsaw. The average falls from 347 km to 316 km, and total delivery kilometres from 18,056 to 16,424, a nine per cent saving before anyone has priced the building. Both rungs agreed on which customers move.

Step 6: hand the AI the matrix, not the question. I let an assistant write the script and the summary, with one rule: every kilometre comes from the matrix. Its own memory of European geography stays out of the model.

Notice two things. The rung-2 screen was good enough for the strategic question, and the rung-3 matrix was needed to get the allocation right. And the twelve per cent error from allocating by straight line is bigger than the nine per cent the new hub saves. When the distances are wrong, the optimiser is optimising noise.

What it can’t do, and the traps

  • Read the licence before you store anything. Google and HERE let you cache coordinates for 30 days, and Mapbox’s cheaper “temporary” geocodes may not be cached at all. OpenCage, Geoapify and the public registers let you keep results, with attribution.
  • Public demos are not batch tools. Nominatim’s policy is one request per second, an identifying user agent and no bulk geocoding. For a real customer file use a paid tier, a national register or your own server.
  • A car matrix is not a truck matrix. Rung 3 ignores bridges, tunnels and weight limits. Use a truck profile before you turn kilometres into lane rates.
  • Road distance is not lane cost. Tolls, ferries, driver hours and empty returns sit on top, and Bergen showed how a road answer can be the wrong mode entirely.
  • Customer addresses can be personal data. The GDPR names location data as an identifier and a home address as personal data. Pseudonymise consumer files before they leave your systems, and check where the vendor processes them.
  • APIs move. Google’s Distance Matrix API is now marked legacy, the old French address API was scheduled for decommissioning in January 2026, and HERE has deprecated its truck parameters. Keep the provider name and the date next to every stored coordinate.

Geocode your customer file this week

Take the 200 customers with the most deliveries, run them through a national register or a free tier, and plot the dots. Count the rows that fail, and count the dots that land in the wrong country. That hour tells you more about your network data than a month with a solver.

Supply chain people have always known that the map matters. The difference now is that the map answers in seconds, for cents, and that your AI can call it too.

Which rung is your current network study standing on?

Sources

Illustration of a scale model of a small company on a workbench: two factories and a warehouse linked by roads with miniature lorries, beside a pair of callipers, a pencil and an open notebook

Read it, then try it

The posts on this blog are meant to be used, not only read. Each one ends in something to do: a prompt to run, a calculation to rebuild or a first step for this week. You learn what AI can do in supply chain by putting it to work on a real problem.

Meet Upshift

Most examples use Upshift, a fictional bicycle maker. It builds road and gravel bikes, each as a regular and an e-bike version, in two plants, and serves dealers and retail chains through five distribution hubs. Upshift isn’t a real company, and none of its data comes from one. Meet the company.

The dataset and the exercises

Behind Upshift sits a complete synthetic company dataset: products, suppliers, dealers, orders, stock, production and the transport network, all consistent with each other. Its dates follow a date you choose, so the data always looks current. The exercises on this site use the same company, each with a task, the files you need and a way to check your result.

A post keeps its example small enough to paste into a chat. The dataset and the exercises let you do the same work at the scale of a real company.

The dataset and the exercises are free with an account. Accounts are by invitation for now: join the waiting list from the sign-in screen and I’ll send you one.

Pass it on

Know a colleague who should read this? Post it where they will see it, or send it to them directly.

More posts