Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put all countries/cities/states of the world into my database?

I have a difficult architectural and web problem. I am trying to make a page about hiking for every city in the world for http://www.comehike.com

I have to somehow import all the cities in the world and structure them by state, which is in turn structured by country.

I already have a list of countries which I added by hand into the db, then added all the cities of California (there are 300+ if you consider small places), and realized there will be no way for me to do this by hand with accuracy for all the cities in the world.

Is there a way to do this in an automated fashion? Where do I get the reliable data from? Ideally I would have their lat/lng as well.

like image 851
Genadinik Avatar asked Apr 28 '11 03:04

Genadinik


1 Answers

You can download free geographical data from GeoNames -- this comes in a text file from which the pertinent information can easily be parsed. If the free data is not reliable enough for your needs, they also offer verified data with higher quality control for a fee.

like image 122
goldPseudo Avatar answered Nov 15 '22 11:11

goldPseudo