问题
I am looking for a list of towns, cities by country (the countries I mean here are all countries that exist on planet Earth). Is there any open-source SQL database available online which I can download and use, or any geography social network sites APIs I can use?
Or is it something I have to make it up myself? - I hope not!
回答1:
There is a sample database for PostgreSQL with that information. I don't know how outdated it is, though...
It's hosted in http://pgfoundry.org/projects/dbsamples/.
回答2:
Try this:
The downloadable file contains a list of all towns, administrative divisions and agglomerations with their current population, their English name (if not equal to the international name) and parent country. The international names are displayed in UTF-8 format, which means that special characters which are not displayable with a normal text editor, are displayed as two characters. A freeware text editor that can read UTF-8 characters is UniRed. When opening the file with UniRed you have to specify the charset UTF-8.
http://www.world-gazetteer.com/wg.php?x=1129163518&men=stdl&lng=en&gln=xx&dat=32&srt=npan&col=aohdq
回答3:
This gives you the SQL to insert a list of countries into a table - 239 of them:
http://www.sqldumpster.com/databases/geographic/
Look for "Countries (and ISO codes)"
Didn't find anything obvious for the cities and towns. Maybe you can use the countries list an make a crawler to find them.
来源:https://stackoverflow.com/questions/4140099/an-open-source-sql-database-for-the-list-of-towns-cities-by-country