Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing an application that calculates the distance between cities using their respective Longitude and Latitude values.

But the problem is where to get a comprehensive list of latitude and longitude values of these cities?

share|improve this question

migrated from Mar 19 '12 at 11:08

This question came from our site for professional programmers interested in conceptual questions about software development.

I'd look around and for a start – Morawski Mar 19 '12 at 9:14
Sounds like a good query for – user59492 Oct 17 '15 at 16:53

10 Answers 10

up vote 5 down vote accepted

This is pretty much the standard as far as I'm aware:

MaxMind GeoLite

share|improve this answer
I don't get it, how is this a list of global cities? Is this link even correct? Shouldn't it point to GeoliteCity? – G-wizard Mar 22 '12 at 14:06
The link is – vero4ka Aug 4 '14 at 20:06

Don't forget about Geonames dataset:

The GeoNames geographical database covers all countries and contains over eight million placenames that are available for download free of charge.

share|improve this answer
download a "cities" file at – Mike T Mar 19 '12 at 18:34

Natural Earth's Populated Places could be another option.

share|improve this answer
Thanks for the help. But i was looking for Latitude and Longitudes of Cities round the world. – hello Mar 19 '12 at 12:07
@dotman14: Dataset is meant to consist of all admin-0 and many admin-1 capitals, major cities and towns, plus a sampling of smaller towns in sparsely inhabited regions. And latlon values can be found as two columns inside DBF file. – radek Mar 19 '12 at 12:53

You could also extract the data from OpenStreetMap (using e.g. their API, as described here), or simply from Wikipedia. Most Wikipedia pages for cities have the city's coordinates.

Of course, this would require a bit of scripting, and possibly a list of the cities you want.

share|improve this answer

Use OpenStreetMap, Internet access, the wget tool and a XPath Filter like XML::XPath. The request should be chunked in 2x2 degree BBoxes. Here an example for 12 degs west till 14 degs east and 52 degs south and 54 degs north. Berlin is inside .. with a lot of infos. For smaller units use place=town. The incoming format is XML.

  wget -O osm-city-12-52-14-54.xml  "[place=city][bbox=12,52,14,54]"

  wget -O osm-town-12-52-14-54.xml  "[place=town][bbox=12,52,14,54]"
<?xml version='1.0' encoding='UTF-8'?>
<osm version="0.6" generator="Osmosis SNAPSHOT-r26564">
  <node id="21484051" version="7" timestamp="2010-07-13T20:11:08Z" uid="15720" user="J budissin" changeset="5211741" lat="52.2994511" lon="13.6244389">
    <tag k="openGeoDB:auto_update" v="population,is_in"/>
    <tag k="openGeoDB:loc_id" v="19549"/>
    <tag k="openGeoDB:is_in_loc_id" v="294"/>
    <tag k="openGeoDB:name" v="Königs Wusterhausen"/>
    <tag k="openGeoDB:is_in" v="Dahme-Spreewald,Brandenburg,Bundesrepublik Deutschland,Europe"/>
    <tag k="openGeoDB:layer" v="6"/>
    <tag k="openGeoDB:version" v=" / 2007-12-04 /"/>
    <tag k="openGeoDB:telephone_area_code" v="03375"/>
    <tag k="openGeoDB:population" v="32785"/>
    <tag k="is_in" v="Dahme-Spreewald,Brandenburg,Bundesrepublik Deutschland,Europe"/>
    <tag k="openGeoDB:community_identification_number" v="12061260"/>
    <tag k="openGeoDB:license_plate_code" v="LDS"/>
    <tag k="openGeoDB:sort_name" v="KOENIGS WUSTERHAUSEN"/>
    <tag k="openGeoDB:type" v="Stadt"/>
    <tag k="openGeoDB:postal_codes" v="15711,15831"/>
    <tag k="name:hsb" v="Parsk (Königs Wusterhausen)"/>
    <tag k="name" v="Königs Wusterhausen"/>
    <tag k="opengeodb:lat" v="52.296999"/>
    <tag k="opengeodb:lon" v="13.6297229"/>
    <tag k="place" v="town"/>
    <tag k="population" v="33370"/>

A simple perl harvester script:

#!/usr/bin/perl -w 
# --------------------------------------------------------
# Simple OSM Harvester 
# --------------------------------------------------------
use strict;
use XML::XPath;
use XML::XPath::XMLParser;

# Use UFT 8
binmode(STDOUT, ":utf8");
# --------------------------------------------------------
# Parameter @todo put params into commandline arguments
# --------------------------------------------------------
    # while ($cmd = shift) {
    #  $level = shift if $cmd =~ /level/;
    #  $east  = shift if $cmd =~ /east/;
    #  ....
    # }
# --------------------------------------------------------
my $level="town";
my $east=14;
my $west=12;
my $north=54;
my $south=52;

# --------------------------------------------------------
# OS Call wget
# --------------------------------------------------------
my @call =`wget -O osm-town-$west-$south-$east-$north.xml "[place=$level][bbox=$west,$south,$east,$north]"`;    

# --------------------------------------------------------
# Parse the stuff
# --------------------------------------------------------
my $xp = XML::XPath->new(filename => "osm-town-$west-$south-$east-$north.xml");
my $nodes = $xp->find('/osm/node'); # find all paragraphs
for my $node ($nodes->get_nodelist) {
    # print $n, "\n";
    my $lat = $xp->find('./@lat', $node);
    my $lon = $xp->find('./@lon', $node);
    my $name = $xp->find('./tag[@k=\'name\']/@v', $node);
    my $pop  = $xp->find('./tag[@k=\'population\']/@v', $node);
    print "name=$name\tlogitude=$lon\tlatitude=$lat\tpopulation=$pop\n";

# --------------------------------------------------------
# --------------------------------------------------------

Generated output (sorry german LANG of wget)

Warnung: Joker-Zeichen werden bei HTTP nicht unterstützt.
--2014-02-04 01:13:23--[place=town][bbox=12,52,14,54]
Auflösen des Hostnamen » («...
Verbindungsaufbau zu (||:80... verbunden.
HTTP-Anforderung gesendet, warte auf Antwort... 200 OK
Länge: nicht spezifiziert [text/xml]
In »»osm-town-12-52-14-54.xml«« speichern.

    [   <=>                                                                                                                                                                                  ] 128.148      242K/s   in 0,5s    

2014-02-04 01:13:30 (242 KB/s) - »»osm-town-12-52-14-54.xml«« gespeichert [128148]

name=Königs Wusterhausen    logitude=13.6244389 latitude=52.2994511 population=q33370
name=Teterow    logitude=12.5753569 latitude=53.7709505 population=9647
name=Neukalen   logitude=12.7905515 latitude=53.822817  population=2304
name=Premnitz   logitude=12.3384178 latitude=52.5310487 population=9671
name=Havelberg  logitude=12.0733335 latitude=52.8234367 population=7400
name=Teltow logitude=13.2644532 latitude=52.4016457 population=19541

Bye Huck

share|improve this answer

Here is another option for Global Cities: GRUMP version 1 now has a free layer of settlement points with attributes, such as population size.

share|improve this answer

I have downloaded the list of cites from, they have other languages german, italian, spanish...

share|improve this answer

Another free database bla bla to 30 characters..

share|improve this answer

I'm using the geodata from

share|improve this answer
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – iant Aug 14 '12 at 10:26

You can try the one from geonames which is absolutely free..

There are also many paid databases on the internet like or as well

You can also use open street data but you need to understand the tagging system to extract the data.

share|improve this answer

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.