此代码仅适用于中心坐标(x = -95.36,y = 29.76)。我想更改它们并从该区域中选择随机数据。
有谁知道发生了什么事?
#Select random data and connect it
get_googlemap(urlonly = TRUE)
ggmap(get_googlemap())
# markers and paths are easy to access
d <- function(x=-95.36, y=29.76, n,r,a){
round(data.frame(lon = jitter(rep(x,n), amount = a),
lat = jitter(rep(y,n), amount = a)),
digits = r)
}
df <- d(n=50,r=3,a=.3)
map <- get_googlemap(markers = df, path = df,, scale = 2)
ggmap(map)
ggmap(map, extent = "device") +
geom_point(aes(x = lon, y = lat), data = df, size = 3, colour = "black") +
geom_path(aes(x = lon, y = lat), data = df)