The Scenario
You are a fleet operations analyst. A delivery van's GPS unit had a loose antenna last Tuesday and logged eighty position pings that are clearly off-road — scattered across fields, through buildings. The raw data is in an Excel workbook, latitude in column A and longitude in column B. You need to snap those coordinates to the actual road network before the weekly fleet report goes to the operations director.
You have heard of map matching but never called the Mapbox Map Matching API.
The bad version:
- Read the Mapbox Map Matching API documentation, learn it accepts a GeoJSON LineString, has a 100-waypoint limit per request, and requires timestamps or radiuses for noisy traces.
- Write a script to batch the 80 pings under that limit, make the API calls, parse the snapped coordinate arrays, and reassemble them in row order.
- Discover three pings are too far off-road for Mapbox to snap and the response has a gap — you have to decide how to handle that.
The fleet report is due Friday morning and you also need total route distance from the snapped coordinates.
The Easy Way: One Prompt in SheetXAI
SheetXAI is an AI agent that lives inside your Excel workbook. It reads the raw GPS pings, sends them to the Mapbox Map Matching API in appropriately sized groups, and writes corrected road-snapped coordinates back into the workbook.
Take the GPS coordinates in columns A and B of this workbook, send them to the Mapbox map-matching API in groups of 100, and write the road-snapped latitude and longitude into columns C and D. Flag any pings that could not be snapped to a road in column E as UNSNAPPED.
What You Get
- Column C with road-snapped latitude for each ping.
- Column D with road-snapped longitude.
- Column E blank for successfully matched pings; UNSNAPPED for any ping too far off-road to match.
What If the Data Is Not Quite Ready
The pings are timestamped and you want to preserve timestamps in the output
Take GPS coordinates in columns A and B, preserving timestamps in column C. Send coordinates to the Mapbox map-matching API in groups of 100. Write snapped latitude into column D, snapped longitude into column E, and keep column C timestamps aligned. Flag unsnapped rows in column F as UNSNAPPED.
You want total route distance from the snapped coordinates
Snap all GPS coordinates in columns A and B to the road network using Mapbox map-matching. Write corrected coordinates into columns C and D. Then compute cumulative distance in kilometers between consecutive snapped coordinate pairs and write the total into cell E1.
About twenty pings are obvious outliers — more than 500 meters from any road
First, flag any GPS coordinate more than 500 meters from the nearest road in column E as OUTLIER. Then send the remaining coordinates to the Mapbox map-matching API in order and write the snapped coordinates into columns C and D.
Full pipeline: filter outliers, batch snap, compute segment distances, and flag large corrections
Remove any pings more than 300 meters from the nearest road — mark them OUTLIER in column E. Send remaining coordinates to Mapbox map-matching in groups under 100. Write snapped coordinates into columns C and D. Compute the distance in meters between original and snapped coordinate for each ping and write into column F — flag any correction greater than 100 meters as LARGE CORRECTION in column G. Compute total route distance from snapped coordinates and write it into cell H1.
One prompt covers outlier filtering, batched map matching, correction distance computation, and total distance summary.
Try It
Get the 7-day free trial of SheetXAI and open your next GPS export workbook — bring the raw lat/lon columns and ask SheetXAI to snap the trace to the road network through Mapbox. The reverse geocoding article covers converting those snapped coordinates into street addresses. The Mapbox hub lists every geographic workflow.
