For one of my projects, I need the geographical location (latitude, longitude, altitude) of all main cities of the world. It was a adobe air project to determine worldwide salat timetable automatically.

I couldn’t find a complete list. Then I found this site, Aneki World Cities. Then I designed a scrapper using PHP, and scrapped all the countries first, then their respective cities list, then respective geographical location. Then end result was a table in the database with all countries, respective cities and locations :)

As I have only compiled the database, the information aren’t mine, so I have decided to make the table publicly available. You can download the zip file here: World Cities Locations (The zip file contains 4 types of file for same content. SQL, CSV, CSV for MS EXCEL, MS EXCEL 2000. All of them are exported from MySQL using phpMyAdmin)

The sql file contains the schema to reproduce the location table in your designated database (assuming you are using mysql database engine. If you aren’t, you can easily convert the sql schema :D ).

The table has in 10,567 rows (means 10,567 unique cities, their locations and 170 countries).

The table has 5 fields, id, country, city, latitude, longitude, altitude. From their name, I hope you can understand their significance.

The table can be used in different ways:

  • Getting all countries of the world (170 countries): SELECT DISTINCT(country) FROM location
  • Getting all cities of a country: SELECT city FROM location WHERE country = 'YOUR_COUNTRY_NAME_HERE'
  • Getting the location of a specific city of a specific country:
    SELECT latitude,longitude,altitude FROM location WHERE country='COUNTRY_NAME' AND city = 'CITY_NAME'

I hope this small contribution to the open world helps all. You can use the content in location based applications, finding a city easily in map services etc.

  • http://Website Seregwethrin

    Thank you, it is really useful :)

  • Neo_t

    Appreciate your efforts. FOund some cities missing. I tried http://www.worldcitiesdatabase.com and found it good. Thanks again.

  • http://www.tarikatechnologies.com Ajay

    Thanks buddy…… It helped me a lot.

  • Crendy

    Thank U

  • Crendy

    the file is not available , can U send one to me ? Thank U , my email : crendy@126.com

  • http://askbahar.com Habib Ullah Bahar

    I have just checked the link, it seems to work fine.

  • Milenski

    Very nice :) 10x

  • DrLightman

    Not good, it doesn’t seem to be free.

  • Rehan Sheikh

    Dear Brother Habibullah, Thank you so much. I am much thankful to you for posted this database. I was searching for it since long time.

  • David

    Great Job! I noticed though that some swedish cities used for example “oe” instead of the swedish characters “ö”. So i corrected the spellings for all the swedish cities, and uploaded an sql-export of the table which you can download here:
    http://www.mobrand.se/dump/world_cities_location_table.zip

  • limer

    a world cities database with sql script can also be found here: http://ebusinessgems.com/blog/geographical-database/world-city-names-database-latitude-longitude/

  • Avk

    Thank You brother, it took a long time for me to search for this.
    You made my life simpler with this!
    May God bless you.

  • Pow261986

    thank you

  • http://www.adakoo.com/ Adakoo

    i like it

  • Alexgo Tw

    There’s some country missed such as Taiwan…

  • Nevestella

    But you missed the TIME ZONE! It’s unuseful…

  • http://profile.yahoo.com/S2KQWNWMS5ZHA7GELXFEJYLULM Paul

    Nice. Problem is the data must be genuine. I am using the one from http://www.worldcitiesdatabase.com/world-city-latitude-longitude.aspx and it is good. Your logic help me more..

Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...