OT: Country -> (State) -> City/Town (XML/JSON)

3,046 views
Skip to first unread message

Ants Pants

unread,
Apr 7, 2010, 3:02:13 PM4/7/10
to rubyonra...@googlegroups.com
Does anyone know where I can find Country -> (State) -> City/Town data in easy to read format (XML/JSON)?

I need it for my application and would like a good base of countries/states/towns/cities before I start asking users to add missing information.

Regards

-ants

--
100% naturally selected. 0% designed.

Joe Smith

unread,
Apr 8, 2010, 11:24:11 PM4/8/10
to rubyonra...@googlegroups.com

"Ants Pants" <antsmai...@gmail.com> wrote
in message
news:v2pc1f9ecae1004071202t2...@mail.gmail.com...

>Does anyone know where I can find Country -> (State) -> City/Town data in
> >easy to read format (XML/JSON)?

There is a databse that provides city (and state/province information for
the US and Canada). It is freely available, but requires a short message in
the legal section of your site, as well as in any documention/advertisements
that mention the address portion of the product. If sounds acceptable, then
what you want is:

MaxMind's worldcitiespop.txt database. The database is a text file encoded
using the ISO-8859-1 encoding. It is a simple comma seperated value (CSV)
database. The fields are CountryCode, ASCIICityName, CityName, StateCode,
Population, Latitude, Longitude.

You can ignore the last 3 fields. You will need a database to match
CountryCodes to country names, but MaxMind provides one. A trivial 2 feild
CSV file. You will also need a State/CanadaProvince-code to name, and
MaxMind also provides that too, as a trivial 2 field CSV file.

A few quick gotchas: The file is 130MB uncompressed, and is a 30 MB
download. The first line is not a record, but gives the feild names. A few
cities might have country codes of "A1","A2","EU",or "AP". you should not
include those, since they are special codes for the geoIP database. The
statecode feild has a numeric region code for countries other than the US or
Canada, I'd advise you ignore them.

The main database is at:
http://www.maxmind.com/download/worldcities/worldcitiespop.txt.gz
The license is at:
http://geolite.maxmind.com/download/geoip/database/LICENSE_WC.txt

The Country Code and City Code databases are small enough they provide them
as text on html pages: http://www.maxmind.com/app/iso3166 and
http://www.maxmind.com/app/iso3166_2 respectively.

I hope this helps.


Reply all
Reply to author
Forward
0 new messages