6

I have a long list of cities in the United States, and would like to get the coordinates for each city without looking up each one individually. Is there a way to do this?

2

6 Answers 6

8

Have a look at Geonames and its free web services. The service you will most likely want to use is its full text search service.

Have a look at the documentation and examples and see how far you can get.

If you don't know how to use a web API, or know how to populate a spreadsheet, you might ask (or search first) at StackOverflow. See also other questions on this site tagged .

1
2

GPS Visualizer's Easy Batch Geocoder can do this.

Geocode multiple addresses

If you have a large batch of addresses for which you need coordinates, GPS Visualizer's Multiple Address Locator is the solution. This form allows you to geocode an large number of addresses using Yahoo or Google's Geocoding API service. Your data can be in either a raw, jumbled, unformatted list, or in a structured table with a header row; output is plain text but can be plotted on a map or written to a GPX file.

How is works Google and Yahoo each provide a geocoding "API" -- a way for other programs to quickly and easily access their services. But they only allow a certain number of queries per day, based on your IP address. This form uses JavaScript-On-Demand (JSON) code that causes your Web browser to be the one making the request (rather than gpsvisualizer.com), which means your queries don't count against my server's limit. (And thanks are due to the developers of the batch geocoder at BatchGeocode.com for the Yahoo JSON info.) Verifying strange results Sometimes the geocoder returns coordinates that don't seem right. Unfortunately, there's no way to get Yahoo's precision information using this form -- but you can see Yahoo's precision estimate for individual addresses

http://www.gpsvisualizer.com/geocoder/

1
  • This is the only service where I can drop a list of "town, country" vagueness and still get something generated from it.
    – J. Nic
    May 17, 2017 at 14:13
1

Google My Maps or Google Maps Engine possibly pro. This converts named locations to gps coordinates to a KML file.

https://mapsengine.google.com/map/

1

You can use Geocodio to geocode a list of cities. You can paste them in, upload a spreadsheet, or use an API. Note that for the best results you'll want to include the state if you can.

Edit: I'm a co-founder of Geoocodio. Apologies for any confusion about that.

1
  • Does that work in India and other countries too? Failed when I made a request to get coordinates of a city from india Jun 20, 2020 at 17:58
1

After spending some time looking for a quick and easy solution this is what I settled on. I hope someone else finds this useful. Using OpenStreetMap's python API, Nominatim is great for map queries by name. Here is the function I use.

from OSMPythonTools.nominatim import Nominatim

# Converts a iterable of string City names to a list of lat lon stings
# Example: Input - "New York, NY, USA"
#          Output = "40.7127281,-74.0060152"
def QueryLocations(city_names):
    nominatim = Nominatim()
    output = []
    for name in city_names:
        print(name)
        city_json = nominatim.query(name).toJSON()[0]
        output.append(city_json["lat"] + "," + city_json["lon"])
    return output
0

Tried to register a google cloud accont in order to get the map api while using data from simplemaps will be easier and free of charges...

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Mar 28 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.