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

问题描述

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

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

mapdist 完美运行:

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

但是,mapdist 依赖于 Google Geocoding API,该 API 受到每天查询限制为 2,500 个地理定位请求的约束.

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

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

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(仅可用 这里 直到我推出另一个更新,此时它将通过 install.packages 可用)可以使用 Bing 地图(我相信每天支持 25k)并且可以返回一个距离.

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" )

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

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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 05:04