【发布时间】:2018-11-06 21:03:59
【问题描述】:
devtools::install_github("dkahle/ggmap", ref = "tidyup")
library(ggmap)
chicago <- get_stamenmap(bbox = c(left = -88.0225, bottom = 41.5949,
right = -87.2713, top = 42.0677),
zoom = 11)
chicago_map <- ggmap(chicago)
现在我有一张芝加哥的地图,我也有一些经度和高度的数据框,我尝试了很多次在地图上绘制这些位置,不知道为什么它不起作用。请看我的代码尝试如下:
ggplot(longitude_latitude.new, aes(x=Longitude, y=Latitude)) +
stat_density2d(aes(fill = ..level..), alpha=0.5, geom="polygon")+
geom_point(colour="red")+
geom_path(data=chicago_map,aes(x=long, y=lat,group=group),
colour="grey50")+
scale_fill_gradientn(colours=rev(brewer.pal(7,"Spectral")))+
coord_fixed()
Error: ggplot2 doesn't know how to deal with data of class gg/ggplot
我也尝试使用google API获取地图,但不起作用...
mymap <- get_map(location = longitude_latitude.new, source = "google",
zoom = 14, maptype = "satellite")
Error in get_googlemap(center = location, zoom = zoom, maptype = maptype, :
Forbidden (HTTP 403).
谁能告诉我下一步该做什么...我是 R 和编程的初学者,真的让我发疯...非常感谢。
【问题讨论】:
标签: r google-maps google-api data-science data-analysis