Where can I get a list of Countries, States and Cities? [closed]
Asked Answered
D

6

70

This probably seems like a duplicate, since there are identical questions out there.

Unfortunately all of the answers to all of these questions are missing one detail: the states.

Where can I get a list of countries, states and cities?

For example, I want this:

| Sydney  |  New South Wales  |  Australia  |

or

|  Miami  |  Florida          |  United States  |

I don't want something like this, which excludes the state:

|  Miami  |  United States  |

Is there any place where I can get this kind of data?

I've already tried the following data sources:

But all of them exclude the states.

Delitescence answered 9/3, 2012 at 1:19 Comment(5)
Another resource: http://liststates.com/Manzoni
you can find here also rubygems.org/gems/country_state_selectGarey
This is pretty awesome: github.com/prograhammer/countries-regions-citiesHomosporous
I am using this and works great !! universal-tutorial.com/rest-apis/…Tetrabranchiate
I found this one and helped me a lot! back4app.com/database/back4app/…Waterbuck
M
74

The UN maintains a list of countries and "states" / regions for economic trade. That DB is available here: http://www.unece.org/cefact/locode/welcome.html

Myasthenia answered 18/12, 2013 at 0:20 Comment(4)
Thanks Eric!! This is much closer to what I need. Their CSV files have a format like this: Country Code | ... | Locality | Locality/City | State. This isn't ideal, but it gives me the info I need. All I need to do is use a string splitting function to parse out the City name, then I've got what I want: Locality | City | State. Thanks a tonne!Delitescence
Hi Jonathan, may I know what the url for this list? Somehow I could not find country, state, city data in the UN website.Dodona
Unfortunately, it doesn't contain state/region/admin_level when I downloaded the csv data and checked it today. See manual.Obituary
@kiatngI just downloaded this data and find the state-level data is included. "MY","01","Johor","State" "MY","02","Kedah","State"Guglielma
S
34

geonames.org has an api and a data dump of worldwide geographical places.

Stickleback answered 9/3, 2012 at 1:20 Comment(9)
I can't find any list of Countries, States and Cities on this website. All I can find is a list of countries, a list of capital cities and capitals.Delitescence
I think you're looking at the browse features of the site. Look at the data that you can export from them here download.geonames.org/export/dumpStickleback
I looked through the list of files. There seems to be nothing there that simply lists countries and states. There are lists of cities, highly detailed lists of locations, lists of countries and country-specific lists which contain a grab-bag of location types including states and small localities (with nothing to indicate which items are states and which aren't; since some countries would call them 'State of' but other countries would call them something else, e.g. 'Province of'). This isn't very useful I'm afraid.Delitescence
I believe what you are looking for is what they call the admin 1 zones and can be found in the admin1CodesASCII.txt file from that previous link.Stickleback
So this is slightly better. At least I can see states per country. So I can get this: 'New South Wales | Australia'. Unfortunately this still doesn't give me what I wanted originally. I want this: 'Sydney | New South Wales | Australia'. I want the city AND state AND country, not just the state and country. Perhaps I should just be happy with this and match the cities up by state name, but then I'd need a list of cities and states, which I still don't have.Delitescence
check this out vikku.info/programming/geodata/…Crematorium
@Roylee when it can't even get my first world country's city of 200,000 people included in the list, it obviously isn't complete. I wouldn't recommend that data.Phyllida
I've been using an import of the Geonames "cities1000" database pretty heavily over the last year - this theoretically includes all cities in the world over 1000 in population, and also happens to include many with fewer people. I haven't hit upon any notable omissions yet; makes me wonder where bcsteeve lives.Kwabena
Countries: geonames.org/countries - is this list not accurate? It seems to be quite exhaustive with 252 entries, although you might argue that not everything in that list is a country.Stalinist
A
10

geonames is nice. an export tool based on geonames:

https://github.com/yosoyadri/GeoNames-XML-Builder

https://github.com/yosoyadri/GeoNames-XML-Builder/blob/master/continents-countries-statesprovinces.xml

there's also the excellent pycountry module:

http://pypi.python.org/pypi/pycountry

Ariosto answered 9/3, 2012 at 1:33 Comment(0)
C
5

Check this out! It was built no longer ago in 2014.

Get a list of country/state/city in a hierarchy using geonames webservice

Crematorium answered 7/2, 2014 at 9:30 Comment(2)
Link is dead by now!Crucial
I've just tried the link, its still working. @JunaidAtari :)Crematorium
W
4

Geonames has a lot of data on places (including towns and cities) but it seems to be contributed and perhaps not complete.

Perhaps also try SQL Dumpster, I've used this website a lot for these kinds of databases, cities, provinces, etc. Unfortunately it's not free but only appears to be a one-time fee.

Wheeling answered 22/6, 2012 at 14:39 Comment(0)
C
2

This may be a sideways answer, but if you download Virtuemart (A Joomla component), it has a countries table and all the related states all set up for you included in the installation SQL. They're called jos_virtuemart_countries and jos_virtuemart_states. It also includes the 2 and 3 character country codes. I'd attach it to my answer, but don't see a way of doing it.

Compressive answered 8/8, 2012 at 21:30 Comment(3)
Please upload a file to dropbox, to enable the download. It would be very helpful.Halicarnassus
@philip-enc I don't have the database I was referring to anymore, but you can get what you need at geodatasource.com/world-cities-database/free or just google "free world city state country database"Compressive
Thank for the response but I already spent a lot of time with free databases and I found bugs, duplicated entries.... Now I am searching for something to pay and solve the problem. I you have some advice, you are welcome. ThanksHalicarnassus

© 2022 - 2024 — McMap. All rights reserved.