使用 get_map 函数创建纽约市地图时出错

Error while creating a new york city map with get_map Function

我一直在尝试绘制纽约市消耗天然气的不同类型建筑物位置的地图

我尝试使用 get_map 功能下载纽约地图

map <- get_map(location ="New York", maptype = "terrain",
         source='google',color='color')

当我尝试这个时,我总是收到这个错误

Error in data.frame(ll.lat = ll[1], ll.lon = ll[2], ur.lat = ur[1], ur.lon = ur[2]) : arguments imply differing number of rows: 0, 1

如何纠正这个错误?

我也试过用经纬度定位好像也不行

这个问题困扰我很久了。把我逼疯了。有时它自己起作用,有时却不起作用。即使在更新所有软件包之后。我正在使用 rmarkdown 并启用了缓存。

我想我找到了问题所在。这是由于隐藏对象.GeocodedInformation中的caching

现在我把它放在我的代码之前,我再也看不到错误了:

if (exists('.GeocodedInformation')) rm(.GeocodedInformation)

我在我的 R 中遇到了同样的问题,甚至使用了这条线 if

(exists('.GeocodedInformation')) rm(.GeocodedInformation)

没用。

但是,这个问题的解决方案是 运行 在 Knitr 之前,getmap 的块。