python 地理编码库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/373383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Geocoding libraries
提问by bgoncalves
I'm using python and I need to map locations like "Bloomington, IN" to GPS coordinates so I can measure distances between them. What Geocoding libraries/APIs do you recommend? Solutions in other languages are also welcome.
我正在使用 python,我需要将“Bloomington, IN”等位置映射到 GPS 坐标,以便我可以测量它们之间的距离。您推荐哪些地理编码库/API?也欢迎使用其他语言的解决方案。
采纳答案by dF.
The Google Maps API supports geocoding, and the Python Cookbook has a simple exampleof accessing it from Python (although the recipe doesn't use the API directly, just simple maps.google.com URLs).
Google Maps API支持 geocoding,Python Cookbook 有一个从 Python 访问它的简单示例(虽然该配方不直接使用 API,只是简单的 maps.google.com URL)。
回答by Aaron
回答by xster
The Google's web service is very easy to use. Just put the query in the URL. To make it even easier/lazier, I will shamelessly advertise pygeocoder, a Python wrapper for Google Geocoding. Then you can just do something like
Google 的网络服务非常易于使用。只需将查询放在 URL 中即可。为了让它更容易/更懒惰,我将无耻地宣传pygeocoder,这是一个用于 Google 地理编码的 Python 包装器。然后你可以做类似的事情
print Geocoder.geocode("Montreal, Canada")[0].coordinates
to get a tuple with coordinates. You can also do stuff like
得到一个带坐标的元组。你也可以做类似的事情
Geocoder.geocode("sushi, San Francisco").count
or
或者
Geocoder.geocode("sushi, San Francisco")[0].postal_code
回答by Craig
Both Google and Microsoft have API's that are very easy to hook into. There are some limitations but they are pretty generous. You might also want to look at http://geocoder.us/. I am not aware of any free geocoding services that are any good (and I have spent time looking!)
谷歌和微软都有很容易使用的 API。有一些限制,但它们非常慷慨。您可能还想查看http://geocoder.us/。我不知道有任何好的免费地理编码服务(我已经花时间寻找了!)
回答by nickf
You could take a look at GeoLite City. It's free (GPL), but they say it's not the most accurate.
你可以看看GeoLite City。它是免费的 (GPL),但他们说这不是最准确的。
Over 99.5% on a country level and 79% on a city level for the US within a 25 mile radius
在 25 英里半径范围内,美国超过 99.5% 的国家级和 79% 的城市级
That still might suit you, depending on your needs.
这仍然可能适合您,具体取决于您的需求。
回答by Vasil
You can use a web API like google maps to find the coordinates. Then if you just need to calculate distances (in a straight line), there is a formulayou can apply to get pretty accurate results.
您可以使用诸如谷歌地图之类的网络 API 来查找坐标。然后,如果您只需要计算距离(直线),则可以应用一个公式来获得非常准确的结果。
回答by Vasil
The USC WebGIS Geocoder(https://webgis.usc.edu) is free. It has API's that you can call from scripts or you can upload and process databases (mdb, csv, etc.). The accuracy levels depend on where your addresses are. For example, in Los Angeles County parcel centroids are available, while in other parts of the country only TIGER/Lines are. A coverage map of reference data sources is not available at this time, but is in development. The underlying tools are planned to be open-sourced in the future once more development is completed as well.
在南加州大学的WebGIS地理编码(https://webgis.usc.edu)是免费的。它具有可以从脚本调用的 API,也可以上传和处理数据库(mdb、csv 等)。准确度取决于您的地址所在位置。例如,在洛杉矶县,可以使用包裹质心,而在该国其他地区,只有 TIGER/Lines 可用。参考数据源的覆盖图目前不可用,但正在开发中。一旦完成更多的开发,底层工具计划在未来开源。
回答by Rosstified
I came across http://www.geonames.org/the other day. You can actually download all the data for postcodes, including lat / long etc even for commericial use to save having to connect to external sources. I think you can do the same for city names (post code data has subrub names associated with it already).
前几天我遇到了http://www.geonames.org/。您实际上可以下载邮政编码的所有数据,包括经纬度等,甚至可以用于商业用途,以节省连接外部资源的麻烦。我认为您可以对城市名称执行相同的操作(邮政编码数据已经具有与其关联的子区域名称)。
Some maths on finding the distance "As The Crow Flies" - direct from point to point can be found hereand here (.NET example).
回答by rahman.bd
You can have better look in Geopy module.And it is worth enough to use as it contains Google map, yahoo map geocoders with which you can implement geocodings.
您可以在 Geopy 模块中更好地查看。它非常值得使用,因为它包含可以实现地理编码的谷歌地图、雅虎地图地理编码器。