2010-04-23 155 views
31

我需要世界上所有國家的列表,一個國家的經緯度座標。需要世界所有國家的經緯度座標的列表

我看了一下GeoNames,但我可以看到的所有列表都包含同一個列表中的國家和城市。我想我可以解析它並過濾掉這些國家,但我希望避免這種情況。

基本上,我需要什麼;

國家名稱 - 緯度/長座標(某種國家中心)

它並不需要說一下大陸什麼,但我不介意,如果它沒有。

_L

+0

謝謝,abelenky – ptrn 2010-04-23 22:31:07

+0

檢查http://dev.maxmind.com/geoip/legacy/codes/country_latlon/ – Boern 2016-06-10 08:22:41

回答

28

兩個Web服務,可能是你的興趣來建立這樣的數據:

你可以稱之爲http://ws.geonames.org/countryInfo獲得的國家代碼和國家的完整列表名稱,然後分別撥打http://ws.geonames.org/search?country=<code>&name=<name>&maxRows=1以獲得該國中心點的經緯度。 (例如:http://ws.geonames.org/search?country=US&name=United%20States&maxRows=1

編輯

這裏是一個C#腳本,您可以對上面列出的服務運行。
你可以像LinqPad那樣運行它。

void Main() 
{ 
    var countries = new List<Country>(); 
    XDocument xmlDoc = XDocument.Load(@"http://ws.geonames.org/countryInfo"); 
    var countryList = (from c in xmlDoc.Descendants("country") select c); 

    foreach (var country in countryList) 
    { 
     var countryPath = string.Format("http://ws.geonames.org/search?country={0}&name={1}&maxRows=1", country.Element("countryCode").Value, country.Element("countryName").Value); 
     var element = (from e in XDocument.Load(countryPath).Descendants("geoname") select e).FirstOrDefault(); 

     countries.Add(new Country 
     { 
      Code = element.Element("countryCode").Value, 
      Name = element.Element("countryName").Value, 
      Latitude = Convert.ToDecimal(element.Element("lat").Value), 
      Longitude = Convert.ToDecimal(element.Element("lng").Value), 
      Continent = country.Element("continentName").Value 
     }); 
    } 

    Console.WriteLine("{0},{1},{2},{3},{4}","Continent", "Code", "Name", "Latitude", "Longitude"); 

    foreach (var country in countries) 
    { 
     Console.WriteLine("{0},{1},{2},{3},{4}",country.Continent, country.Code, country.Name, country.Latitude, country.Longitude);  
    } 
} 

public class Country 
{ 
    public string Continent {get;set;} 
    public string Name { get;set;} 
    public string Code { get;set;} 
    public decimal Latitude { get;set;} 
    public decimal Longitude { get;set;} 
} 
+0

整潔的解決方案。我已經用Andrew McGregor的方式解決了這個問題,但這非常聰明。謝謝 – ptrn 2010-04-24 02:44:19

+1

事實上,這原來是最好的解決方案。中央情報局的實況記錄中有一個與國會大廈協調。 – ptrn 2010-04-24 20:12:41

1

一個國家的中心概念不是很清楚。首都城市的協調會做什麼?如果是這樣,你可能能夠從維基百科等地方相對直接地提取它們。畢竟只有200左右。也就是說,我注意到CIA World Factbook(在線提供)給出了國家地理中心的大致座標。

+0

只要它是一致的,它究竟是不是很重要,無論是國會大廈還是有點在中心。感謝提示 – ptrn 2010-04-24 00:04:37

5

那麼,你可以下載this GIS layer並在其上運行點對多邊形。

編輯:也許this list會做。

+0

啊,完美!我以前真的用過它,我想我會忘記它。感謝一羣:-) – ptrn 2010-04-23 23:59:39

+0

最後一個環節缺乏南蘇丹FYI。第一個鏈接被打破。 – thadk 2015-02-06 21:40:32

23

還有這個http://dev.maxmind.com/geoip/legacy/codes/country_latlon/,這正是我們都是尋找,但沒有解析需要。它的csv會很好地發揮

+2

如果只有你快了一年半,它會有所幫助:) – ptrn 2011-12-15 11:35:55

+0

我只是跳了進來:-D – ioc32 2012-01-06 20:13:04

+0

警告:MaxMind的越南的座標是'16.0000,106.0000',它實際上位於老撾南部的中部 - 絕對沒用。美國中央情報局的世界實況報道協議是「16 10 N,107 50 E」,這對越南中部是正確的。不幸的是,這些是我測試的第一個也是唯一的MaxMind座標,因此我不相信任何其他人。 CIA Fact Book是要走的路。 – verbumSapienti 2014-02-20 13:06:49

0

如果您下載最新版本的從天然地球這個國家的國際數據文件:ne_10m_admin_0_countries.zip

然後把它變成QGIS,你CA n通過運行菜單項Vector-> Geometry Tools-> Polygon Centroids輕鬆獲取質心,然後通過右擊和另存爲導出。

-2

geographicdb PAKAGE與緯度經度和時區信息+240國家與他們的城市的名稱和國家代碼和27萬點的記錄

世界城市數據庫

你可以下載geographicdb PAKAGE from here

+1

你可以再次分享該鏈接?當前鏈接被破壞 – Pooran 2015-07-24 08:22:42

6

這裏是一個Google CSV document ,與國家座標。

+1

tks,你如何下載它?或者你只是複製和粘貼和編輯,以獲得它的CSV格式? – HattrickNZ 2015-08-12 19:57:19

+0

您可以從源代碼複製表格,然後按照您的喜好進行處理(例如,在MS Word中編寫簡單的REGEX,甚至在Python中編寫簡單的REGEX,C#等)。 – 2015-09-04 16:14:59

+3

在這裏,我使用了在線轉換器,您可以獲取我的文件:https://drive.google.com/file/d/0B52RjTfri3LPNDFuc0JHRDkxNE0/view?usp=sharing – yshahak 2017-08-18 08:42:27