Sunday 12 April 2015

Database of Countries and their Cities

Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
I need a database of Countries and their Cities.
any idea where i can get it. or any one can share it with me ?
shareimprove this question

11 Answers

up vote18down voteaccepted
There are quite a few available.
The following has database for 2,401,039 cities
shareimprove this answer

   
thanks a lot :D its not an over kill :D –  Harsha M V Oct 2 '10 at 9:08 
   
Is there anyway to know the state/province related to the city with this? –  Arya Feb 3 at 8:36
From all my searching around I strongly say that the most practical, accurate and free data source is provided by http://geonames.org.
You can access their data in 2 ways, 1. The easy way through their free web services. 2. Import their free text files into Database tables and use the data in any way you wish. This method offers much greater flexibility and have found that this method is better.
shareimprove this answer

It Includes the following fields:
  1. Country Code
  2. ASCII City Name
  3. City Name
  4. Region
  5. Population
  6. Latitude (The latitude and longitude are near the center of the most granular location value returned: postal code, city, region, or country)
  7. Longitude
shareimprove this answer

1 
Is there an information about what the Region codes mean. These are mainly numbers, but sometimes they are not. (Perhaps they are Country abbreviation of the USA.) –  Arpad Horvath Oct 12 '14 at 8:18
   
Is there a mapping what county in a Country a number means? –  Arpad Horvath Oct 12 '14 at 15:56
http://cldr.unicode.org/ - ommon standerd multilanguage database include country list and other localizable data.
shareimprove this answer

   
Thank you buddy :) –  Harsha M V Feb 8 '11 at 12:39
   
Question about cities with global permanent ID and localized names is open :( I can't find solution. I plan maintain own application codelist with user contribution. –  Kuvalda.Spb.Ru Feb 8 '11 at 15:36
   
ipinfodb.com/ip_database.php - free community supported geo ip database. Include list of cities with latin names. MaxMind use this database as source. –  Kuvalda.Spb.Ru Feb 8 '11 at 15:58
Check this out:
The company MaxMind.com1 has agreed to release their cities of the world database under the GPL. The database contains locations by country, city, latitude and longitude. There are over 3,047,000 records in the database. For those of you who have tried the location.module with the zipcodes database from CivicSpace, you will recognize how cool it is and how well this fits with that project and therefore Drupal.
Here's another free one that might help you get started.
Creating and maintaining such a database is quite a bit of work - so anyone who's done it is likely keeping it to themselves, or offering it for a fee.
shareimprove this answer

   
thats neat. only problem is how to get around getting the country names into that. they just have abrev :( – Harsha M V Oct 2 '10 at 8:54
   
Well, it's free and thus could be a starting point. Based on the abbrev., you should have no trouble finding the country names for those 200 countries or so and add them to your database table... –  marc_s Oct 2 '10 at 8:59 
   
cool. guess.. makes sense :D –  Harsha M V Oct 2 '10 at 9:01
Have a look at WorldCitiesDatabase.Info Depending on what you need the database for, it may be the ideal solution. This one was designed for all sorts of multi-level location selector scripts, and so only contains a manageable amount of entries that would not stall the browser.
shareimprove this answer

This database has multi languages country names, region names, city names and they's latitude and longitude number and country's alpha2 code .
shareimprove this answer

1 
i ended up using this one it is not an overkill like others with 3 million rows –  user1607528 Dec 24 '14 at 5:02
You can use database from here -
CREATE TABLE `cities` (
  `cityID` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `cityName` varchar(50) NOT NULL,
  `stateID` smallint(5) unsigned NOT NULL DEFAULT '0',
  `countryID` varchar(3) NOT NULL DEFAULT '',
  `language` varchar(10) NOT NULL DEFAULT '',
  `latitude` double NOT NULL DEFAULT '0',
  `longitude` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`cityID`),
  UNIQUE KEY `unq` (`countryID`,`stateID`,`cityID`),
  KEY `cityName` (`cityName`),
  KEY `stateID` (`stateID`),
  KEY `countryID` (`countryID`),
  KEY `latitude` (`latitude`),
  KEY `longitude` (`longitude`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
shareimprove this answer

I was comparing worldcitiesdatabae.info with www.worldcitiesdatabase.com and it appears the latter one to be more resourceful. However, maxmind has a free database so then why buy a cities database. Just get the free one and there is lot of help available on internet about maxmind db. If you put in extra efforts then you can save those few bucks :)
shareimprove this answer

have a cities of the world CSV dataset compiled from the USGS GNIS Server (US) and US NGA GNS Server (non-US), that I have placed into the public domain. Below is a link and metadata of the layout.
Column 1: ISO 3166-1 alpha-2 country code.
Column 2: US FIPS 5-2 1st level administrative division code (e.g., state/province).
Column 3: NGA GNS Feature Description (DSG) code.
Column 4: NGA GNS Unique Feature Identifier (UFI).
Column 5: ISO 639-1 alpha-2/3 code for language corresponding to the feature name.
Column 6: Language script (e.g., latin, arabic, chinese, etc) corresponding to the feature name.
Column 7: Feature name.
Column 8: Latitude coordinate of the area centroid.
Column 9: Longitude coordinate of the area centroid.
shareimprove this answer

You can use GeographicDB, it contains about 270,000 major cities across 240+ countries all over the world.
shareimprove this answer

   
Removed the download link because it seemed redundant with the project's homepage. –  logc Mar 30 at 14:05

Your Answer

 
By posting your answer, you agree to the privacy policy and terms of service.

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

No comments:

Post a Comment

>