Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
428 views
in Technique[技术] by (71.8m points)

r - Determining the distance between two ZIP codes (alternatives to 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 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)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...