Using Bing option with taRifx.geo in R

2019-07-15 10:02发布

I'm attempting to find the coordinates for several cities in Ghana. I've used the geocode function in taRifx.geo with the "google" option and had success, but Google doesn't know where all my cities are.

I'd like to use the Bing service to fill in the coordinates that were missing from my Google list and I'm starting with just one city ("Awutu Breku") to make sure the code works. I run this code, though, and get an error:

 > Bkey <- "______________(my key would be here)____"

 > Loc5 <- geocode("Awutu Breku", service="bing", BingMapsKey = Bkey,
 +                 returntype="coordinates")
 Error in geocode.default("Awutu Breku", service = "bing", BingMapsKey = Bkey,  : 
   To use Bing, you must save your Bing Maps API key (obtain at      http://msdn.microsoft.com/en-us/library/ff428642.aspx) using options(BingMapsKey='mykey').

This error is very confusing since I do include the BingMapsKey argument but the function doesn't seem to be recognizing it.

I've searched quite a bit for an answer to this one and haven't come across anything. I even looked on the github page but couldn't figure out what might be wrong with my code. I feel like I'm missing something simple. Any help would be appreciated!

标签: r geocode
1条回答
手持菜刀,她持情操
2楼-- · 2019-07-15 10:19

I needed to do a devtools::install_github("gsk3/taRifx.geo") to be able to use the geocode function and the instructions clearly state that you need to do a:

options(BingMapsKey='ridiculously_long_string')

before calling using the bing option:

geocode("1600 Pennsylvania Ave NW, Washington, DC 20500", service="bing")

## [1]  38.89719 -77.03655
查看更多
登录 后发表回答