【发布时间】:2017-01-17 02:42:40
【问题描述】:
当我从接受的答案 (Plot coordinates on map) 运行代码时,安装 ggmap 后第一次运行时收到以下错误消息:
# loading the required packages
library(ggplot2)
library(ggmap)
# creating a sample data.frame with your lat/lon points
lon <- c(-38.31,-35.5)
lat <- c(40.96, 37.5)
df <- as.data.frame(cbind(lon,lat))
# getting the map
mapgilbert <- get_map(location = c(lon = mean(df$lon), lat = mean(df$lat)), zoom = 4,
maptype = "satellite", scale = 2)
# plotting the map with some points on it
ggmap(mapgilbert) +
geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8), size = 5, shape = 21) +
guides(fill=FALSE, alpha=FALSE, size=FALSE)
给出错误:
错误:GeomRasterAnn 是使用不兼容的 ggproto 版本构建的。请重新安装提供此扩展的软件包。
我尝试安装ggproto,但错误是:
> Warning in install.packages :
package ‘ggproto’ is not available (for R version 3.3.2)
在随后的尝试中,错误是:
错误:ggplot2 不知道如何处理 ggmap/raster 类的数据
我可以使用以下方法绘制图像:
plot(mapgilbert)
我试过了:
map2 <- get_map("Rotorua", zoom = 16)
ggmap(data = map2)
返回以下错误信息:
错误:ggplot2 不知道如何处理 ggmap/raster 类的数据
我只是不太了解 R,不知道下一步该去哪里寻找解决方案 - 已确保所有软件包都已更新。
【问题讨论】:
-
第一张地图:
ggmap(mapgilbert) + ...第二张地图:ggmap(map2) -
什么是
mapgilbert? ggmap 不接受数据参数 -
@RichardTelford,mapgilbert 是吉尔伯特群岛地区的地块。为了完整起见,我添加了完整的代码块。我还在另一台机器上从头开始尝试了相同的代码,添加了关于版本不兼容的错误。我希望这可以提供更多的清晰度。我想知道某些错误是否与 API 密钥有关,但这似乎不会影响简单的 plot(mapgilbert) 调用,所以可能不会。
-
关于
mapgilbert的问题,已经回答here。也就是说,你使用的是最新版本的ggplot2和ggmap吗?关于罗托鲁瓦地图的问题,请参阅我之前的评论。ggmap (map2)有什么用? -
mapgilbert 代码在我的电脑上工作(R 版本 3.3.2)。