The Scenario
You are a logistics coordinator. A route-planning tool your company uses requires latitude and longitude for every stop. Your customer list has 400 delivery city names in column A of a Google Sheet and nothing else.
The route-planning tool import fails without coordinates. Your ops manager needs the updated import file by 2 PM so the drivers have tomorrow's routes before end of day.
The bad version of this afternoon:
- You search Google Maps for the first city, copy the coordinates from the URL
- You paste lat into column B, long into column C
- You do city two, city three
- By city fifteen you are doing two-city blocks and losing your place
- At 1:45 PM you have done 80 cities and have 320 left
- The ops manager sends the routes without your 320 missing stops.
The fast version is one prompt.
The Easy Way: One Prompt in SheetXAI
SheetXAI is an AI agent inside your spreadsheet. It reads your city list and calls the API Ninjas geocoding endpoint for each row, writing coordinates back to the columns you name.
Open the SheetXAI sidebar and type:
Geocode every city in column A using API Ninjas and write the latitude into column B and longitude into column C. If a city returns no result, write "NOT FOUND" in both columns so I can review those rows.
SheetXAI calls the geocode endpoint for all 400 cities, extracts the lat and long fields, and writes them back. The NOT FOUND rows are flagged so you can manually review the edge cases.
What You Get
A sheet with every city geocoded:
- Column B: Latitude — decimal degrees
- Column C: Longitude — decimal degrees
- NOT FOUND rows flagged — unresolved cities are visible instead of silently wrong
Ready to drop into your route-planning tool's import format without a second pass.
Need county and timezone too? Ask for those in the same prompt, SheetXAI writes them into columns D and E.
What If the Data Is Not Quite Ready
Delivery address lists are rarely just clean city names. SheetXAI handles the variations alongside the geocoding.
When the city column mixes cities and ZIP codes
Some rows have city names, others have ZIP codes, others have both.
For rows in column A that look like ZIP codes (5-digit numbers), look up city, state, county, and timezone using API Ninjas and fill columns B through E. For rows that look like city names, geocode them and write latitude and longitude into columns B and C.
When you need county data for territory assignment
Your sales territory map is defined by county, not city. You need county added to every row.
Geocode every city in column A using API Ninjas and write latitude into column B and longitude into column C. Then for each row, also look up the county using API Ninjas and write it into column D so I can assign territories.
When some city names are ambiguous and need a state hint
Column A has city names but no state. "Springfield" exists in forty states.
For each city in column A, check if column B has a state code. If it does, geocode using city and state together. If column B is blank, geocode by city name alone and write a "AMBIGUOUS" note in column D if the result returns multiple candidates.
When the full geocoding-plus-analysis run is one prompt
Raw city list, mixed ZIP codes and city names, need coordinates, county, and a count of stops per territory in one pass.
For each row in column A, determine if it is a city name or ZIP code. Geocode appropriately using API Ninjas — latitude into column B, longitude into column C. Look up county and write into column D. Then create a summary table in a new sheet called "Territory Summary" with a count of delivery stops per county, sorted by stop count descending.
The pattern: geocoding and territory analysis in a single prompt so you hand the ops manager the import file and the territory summary at the same time.
Try It
Get the 7-day free trial of SheetXAI and open any sheet with city names, addresses, or ZIP codes, then ask SheetXAI to geocode it using API Ninjas. The API Ninjas integration is included in every SheetXAI plan. See also how to check milestone dates against public holidays or the API Ninjas in Google Sheets overview.
