我正在使用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
Run Code Online (Sandbox Code Playgroud)
从get_map帮助:"缩放:地图缩放,从0(全世界)到21(建筑物)的整数,默认值10(城市).openstreetmaps限制缩放18,雄蕊地图的限制取决于地图类型. 'auto'自动确定边界框规格的缩放,默认为中心/缩放规格为10."
将缩放更改为1对于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) : …Run Code Online (Sandbox Code Playgroud) 我想在点ID的情况下在Google地图上绘制坐标:
数据样本:
coordinates id
1 (7.1735, 45.8688) 2
2 (7.17254, 45.8689) 3
3 (7.17164, 45.8692) 4
4 (7.18018, 45.8716) 5
5 (7.17807, 45.8701) 6
6 (7.17723, 45.8692) 7
7 (7.17524, 45.8681) 8
8 (7.18141, 45.8718) 9
9 (7.1793, 45.8702) 10
10 (7.17836, 45.8707) 11
11 (7.17519, 45.8697) 12
12 (7.17938, 45.8708) 13
13 (7.17551, 45.8693) 14
14 (7.17684, 45.8694) 15
15 (7.18099, 45.8726) 17
16 (7.18015, 45.8725) 18
17 (7.18122, 45.8736) 19
18 (7.17491, 45.8692) 20
19 (7.15497, 45.8706) 25 …Run Code Online (Sandbox Code Playgroud)