我正在使用 ggmap 并希望有一张以澳大利亚为中心的世界地图,我可以轻松地绘制地理编码点。与其他一些映射包相比,ggmap 似乎更容易使用。然而,当我使用下面的代码打开地图时,它会出错。
gc <- geocode('australia')
center <- as.numeric(gc)
> map <- get_map(location = center, source="google", maptype="terrain", zoom=0)
Error: zoom must be a whole number between 1 and 21
来自 get_map 帮助:“zoom:地图缩放,从0(全球)到 21(建筑)的整数,默认值 10(城市)。openstreetmaps 将缩放限制为 18,雄蕊地图的限制取决于地图类型。 'auto' 自动确定边界框规格的缩放,并且默认为 10 与中心/缩放规格。”
将缩放更改为一个对于 get_map 不会出错,但对于绘制该地图会出错
map <- get_map(location = center, source="google", maptype="terrain", zoom=1)
ggmap(map)
Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
看起来经度没有被拉过。最后,放大 2 倍,它确实有效,但并没有带来整个世界的地图
所以,我的问题是如何使用 get_map 来获取世界地图?
会话信息:
sessionInfo() R 版本 2.15.0 (2012-03-30) 平台:i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mapproj_1.1-8.3 maps_2.2-6 rgdal_0.7-12 sp_0.9-99
[5] ggmap_2.1 ggplot2_0.9.1
loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2 grid_2.15.0
[5] labeling_0.1 lattice_0.20-6 MASS_7.3-17 memoise_0.1
[9] munsell_0.3 plyr_1.7.1 png_0.1-4 proto_0.3-9.2
[13] RColorBrewer_1.0-5 reshape2_1.2.1 RgoogleMaps_1.2.0 rjson_0.2.8
[17] scales_0.2.1 stringr_0.6 tools_2.15.0