The Scenario
A public policy researcher at a university gets a handoff from a colleague who is going on parental leave: a sheet 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 Google Sheet. It reads the coordinates, calls Geoapify's boundaries API for each row, and writes the administrative fields into the correct columns.
For each coordinate row in this sheet, look up the Geoapify boundaries and write the suburb, city, county, and state into columns E through H
What You Get
- Column E receives the suburb or neighborhood name for each location.
- Column F receives the city name.
- Column G receives the county name.
- Column H receives the state name.
- Rows where the boundaries lookup returned no result are noted in column I rather than left blank, so the researcher knows which locations need manual review.
What If the Data Is Not Quite Ready
The sheet 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 tab — for US rows, write county and state into columns G and H; for non-US rows, write the equivalent administrative level 2 and level 1 labels, and add the country code in column I
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 tab — 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 tab 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 sheet 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.
