我正试图用RgoogleMaps制作地图。我的代码曾经在今天早上工作过,但现在我得到了这个错误:
map.lyon <- GetMap(center=c(45.77338,4.856039), zoom = 15, destfile = "tile1.png", maptype = "mobile")
Error in download.file(url, destfile, mode = "wb", quiet = TRUE) :
cannot open URL 'http://maps.google.com/maps/api/staticmap?center=45.77338,4.856039&zoom=15&size=640x640&maptype=mobile&format=png32&sensor=true'
In addition: Warning message:
In download.file(url, destfile, mode = "wb", quiet = TRUE) :
cannot open: HTTP status was '403 Forbidden'我今天早上做了很多地图(大概200张左右),谷歌地图API的要求有限制吗?
我还尝试使用OpenStreetMaps而不是RgoogleMaps,总是使用RgoogleMaps包,但这也不起作用(尽管这只是网站上代码的一个简单例子),错误非常相似,下面是代码:
library(RgoogleMaps)
lat_c<-51.47393
lon_c<-7.22667
bb<-qbbox(lat = c(lat_c[1]+0.01, lat_c[1]-0.01), lon = c(lon_c[1]+0.03, lon_c[1]-0.03))
OSM.map<-GetMap.OSM(lonR=bb$lonR, latR=bb$latR, scale = 20000, destfile="bochum.png")这是我在运行它时所拥有的:
> library(RgoogleMaps)
> lat_c<-51.47393
> lon_c<-7.22667
> bb<-qbbox(lat = c(lat_c[1]+0.01, lat_c[1]-0.01), lon = c(lon_c[1]+0.03, lon_c[1]-0.03))
> OSM.map<-GetMap.OSM(lonR=bb$lonR, latR=bb$latR, scale = 20000, destfile="bochum.png")
[1] "http://tile.openstreetmap.org/cgi-bin/export?bbox=7.19637,51.46383,7.25697,51.48403&scale=20000&format=png"
trying URL 'http://tile.openstreetmap.org/cgi-bin/export?bbox=7.19637,51.46383,7.25697,51.48403&scale=20000&format=png'
Error in download.file(url, destfile, mode = "wb", quiet = FALSE) :
cannot open URL 'http://tile.openstreetmap.org/cgi-bin/export?bbox=7.19637,51.46383,7.25697,51.48403&scale=20000&format=png'
In addition: Warning message:
In download.file(url, destfile, mode = "wb", quiet = FALSE) :
cannot open: HTTP status was '403 Forbidden'我不明白问题出在哪里。还有别的包裹我可以用吗?基本上,我只需要有一个背景地图与主要城市和道路在该地区,并能够绘制点以上。
谢谢您抽时间见我。
发布于 2014-02-14 15:02:51
您可以尝试这个包ggmap,它允许您从google或osm下载地图,并且可以使用ggplot2添加数据。
发布于 2015-08-11 02:59:04
如果您使用RStudio: 1-转到Tools 2- Global 3-Packages4-在CRAN镜像下:单击change -您选择了Global (CDN) - RStudio (您选择了不同的选项取决于您所在的位置)
https://stackoverflow.com/questions/21781902
复制相似问题