确定两个邮政编码之间的距离(替代mapdist) [英] Determining the distance between two ZIP codes (alternatives to mapdist)

查看:273
本文介绍了确定两个邮政编码之间的距离(替代mapdist)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要计算大约的距离。 100,000个不同的邮政编码。我知道 ggmap 包中的 mapdist 函数



mapdist 完美无缺:

  library(ggmap)
mapdist('Washington','New York',mode ='driving')

#从m km公里秒分钟小时
#1华盛顿纽约366284 366.284 227.6089 13997 233.2833 3.888056


mapdist('20001','10001',mode ='driving')

#从m km km秒钟分钟
#1 20001 10001 363119 363.119 225.6421 13713 228.55 3.809167

然而, mapdist 依赖于Google Geocoding API,该API必须符合每天2500个地理位置请求的查询限制。



您是否知道替代r代码来计算使用具有较高请求限制的其他服务(例如诺基亚地图或)的两点之间的距离Bing)?

解决方案

taRifx.geo :: georoute 此处,直到我推出另一个更新,此时它可以通过 install.packages )使用Bing Maps(支持我相信每天25k)并且可以返回距离。

  georoute(c(3817 Spruce St,Philadelphia,PA 19104,
9000 Rockville Pike,Bethesda,Maryland 20892),
verbose = TRUE,returntype =time,
service =bing)

您必须获取Bing Maps API密钥并将其设置在您的R全局选项中(理想位置在 .Rprofile 中),但密钥是免费的:

  options(BingMapsKey =whateverBingGivesYouForYourKey)


I want to calculate the distance between approx. 100,000 different ZIP codes. I know about the mapdist function in the ggmap package

mapdist works perfectly:

library(ggmap)
mapdist('Washington', 'New York', mode = 'driving')

#         from       to      m      km    miles seconds  minutes    hours
# 1 Washington New York 366284 366.284 227.6089   13997 233.2833 3.888056


mapdist('20001', '10001', mode = 'driving')

#    from    to      m      km    miles seconds minutes    hours
# 1 20001 10001 363119 363.119 225.6421   13713  228.55 3.809167

However, mapdist relies on the Google Geocoding API which is subject to a query limit of 2,500 geolocation requests per day.

Are you aware of any alternative r code to calculate the distance between two points using another service which has a higher request limit (such as Nokia Maps or Bing)?

解决方案

taRifx.geo::georoute (only available here until I push out another update, at which point it will be available via install.packages) can use Bing Maps (which supports I believe 25k per day) and can return a distance.

georoute( c("3817 Spruce St, Philadelphia, PA 19104", 
            "9000 Rockville Pike, Bethesda, Maryland 20892"), 
             verbose=TRUE, returntype="time", 
             service="bing" )

You'll have to get a Bing Maps API key and set it in your R global options (ideal placement is in .Rprofile), but the key is free:

options(BingMapsKey="whateverBingGivesYouForYourKey")

这篇关于确定两个邮政编码之间的距离(替代mapdist)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆