The Scenario
A public policy researcher at a university gets a handoff from a colleague who is going on parental leave: an Excel workbook of 1,200 school locations with lat/lon, and a half-finished legislative analysis that needs each school assigned to its county, state, and congressional district before the grant report deadline next Tuesday. The colleague left a note saying "the boundary lookup was taking too long so I stopped at row 400."
The bad version:
- Find a Geoapify boundaries API call that returns the right administrative fields, write a script to loop through 1,200 rows, and wait for each synchronous request to complete.
- Parse the nested GeoJSON response to extract county, state, and congressional district from deeply nested properties — each of which uses a different key depending on the country.
- Paste the results into columns E, F, and G, then manually verify a sample of rows to confirm the congressional district assignments are using the 2022 redistricting, not the 2010 one.
The grant report requires the boundary assignments to be verifiable and reproducible. The remaining 800 rows need to be done by Friday.
The Easy Way: One Prompt in SheetXAI
SheetXAI is an AI agent that lives inside your Excel workbook. It reads the coordinates, calls Geoapify's boundaries API for each row, and writes the administrative fields into the correct columns.
Use Geoapify boundaries lookup for all 1,200 rows in the Schools sheet and populate the County, State, and Country columns from the boundary data returned for each lat/lon
What You Get
- The County column receives the county name for each location.
- The State column receives the state name.
- The Country column receives the country name.
- Rows where the boundaries lookup returned no result are noted in a separate column rather than left blank, so the researcher knows which locations need manual review.
What If the Data Is Not Quite Ready
The workbook has a mix of US and international locations and the column labels should reflect the correct administrative terminology for each country
Run Geoapify boundaries lookup for all 1,200 rows in the Schools worksheet — for US rows, write county and state into the County and State columns; for non-US rows, write the equivalent administrative level 2 and level 1 labels, and add the country code in a separate column
Some rows have lat/lon swapped based on a visual check of the map
Before running Geoapify boundaries lookup, check each coordinate pair in columns A and B — if the latitude appears to be outside the plausible US range, swap A and B for that row, then run the lookup and write suburb, city, county, and state into columns E through H
The analysis needs congressional district in addition to county and state
Use Geoapify boundaries lookup for all rows in the Schools worksheet — write suburb, city, county, state, and congressional district into columns E through I for each coordinate pair
Geocode any rows missing coordinates, then run the full boundary lookup and flag locations that cross county lines
For rows in the Schools worksheet where columns A and B are blank, geocode the address in column D using Geoapify to get the coordinates. Then run boundaries lookup for all 1,200 rows and write county, state, and congressional district into columns G, H, and I. Flag any school within 100 meters of a county boundary in column J.
One instruction handles the coordinate recovery, the boundary enrichment, and the edge-case flagging.
Try It
Get the 7-day free trial of SheetXAI and open any Excel workbook with coordinates that need administrative classification — schools, clinics, properties, field sites — and ask it to append the boundary data. See the related spoke on IP address geolocation, or return to the Geoapify hub.
