The Scenario
A new logistics manager joined the team two weeks ago and inherited a Google Sheet of 80 customer locations — latitudes in column B, longitudes in column C, no territory assignments anywhere. The previous manager had five delivery zones drawn from memory, never documented. The new manager's first deliverable is a zone map before the quarterly planning meeting on Thursday. Someone mentioned GraphHopper can cluster locations by travel distance. It's Tuesday afternoon.
The bad version:
- Export the lat/lon columns as a CSV, find the GraphHopper clustering endpoint in the documentation, build a request payload with 80 location objects, run the call, and parse the cluster assignment out of each response object.
- Match each cluster ID back to the correct row in the sheet and paste it into column D.
- Discover that the endpoint uses 0-indexed cluster IDs and your paste offset is off by one. Redo.
Thursday is two days away. This is supposed to be analysis work, not a data plumbing project.
The Easy Way: One Prompt in SheetXAI
SheetXAI is an AI agent that lives inside your Google Sheet. It reads the coordinates from columns B and C, calls the GraphHopper clustering API with the parameters you specify, and writes the zone assignment back into column D for every row — no JSON, no index offsets, no manual paste.
Cluster the 80 customer locations in this sheet (lat in column B, lon in column C) into 5 groups using GraphHopper and write the assigned cluster number into column D
What You Get
- Column D fills with a zone number (1–5) for every customer row.
- The clustering minimizes total travel distance within each zone, not just geographic proximity.
- Rows with missing or invalid coordinates are flagged in column D rather than silently assigned to a default cluster.
What If the Data Is Not Quite Ready
Coordinates are missing for some rows — address is in column A but lat/lon are blank
For any row where columns B and C are blank but column A has an address, geocode the address using GraphHopper to fill in lat and lon, then cluster all 80 locations into 5 zones by driving distance and write the zone number into column D
You need the clusters to be roughly equal in customer count, not just minimized by distance
Cluster the 80 customer locations (lat in column B, lon in column C) into 5 zones using GraphHopper with balanced cluster sizes — each zone should have between 14 and 18 customers — and write the zone assignment into column D
Some customers are flagged as high-value in column D and must stay together
Cluster the 80 customer locations into 5 zones using GraphHopper, but keep all rows marked "KEY ACCOUNT" in column E within the same zone — write the zone assignment into column D
Geocode, cluster, name zones, and flag zone imbalances in one pass
Geocode any rows in column A where lat/lon are missing, cluster all 80 customer locations into 5 zones by driving distance using GraphHopper, write the zone number into column D, name each zone by its dominant city in column E, and flag any zone with fewer than 10 customers as "UNDERSERVED" in column F
One prompt does the geocoding, the clustering, the labeling, and the audit.
Try It
Get the 7-day free trial of SheetXAI and open the Google Sheet with your customer coordinates — ask it to cluster the locations into delivery zones and write every assignment in a single pass. Related: Optimize a Delivery Route From Stops in a Google Sheet and the GraphHopper overview.
