Aqu*_*irl 3 png r ggplot2 google-maps-static-api ggimage
历史记录:从静态Google地图png中提取的栅格数据,将其加载到R设备上ggimage.
library (png)
library (ggmap)
rasterArray <- readPNG ("My.png")
x = c (40.702147,40.718217,40.711614)
y = c (-74.012318,-74.015794,-73.998284)
myData <- data.frame (x, y)
print (ggimage (rasterArray, fullpage = TRUE, coord_equal = FALSE)
+ geom_point (aes (x = x, y = y), data = myData, colour = I("green"),
size = I(5), fill = NA))
Run Code Online (Sandbox Code Playgroud)
我确实运行dput了,rasterArray但输出是20 MB,不能在这里发布.
顺便说一句,这是静态地图的URL:
问:为绘制"GPS坐标"包含的像素地图将R设备上,我需要scale的data.frame?
我看到这个页面:http://www-personal.umich.edu/~varel/rdatasets/Langren1644.html 我是否需要按照他们在这里展示的方式进行缩放?
如果是,那么除了scale函数的手册之外的其他内容我还需要了解才能完成这项工作吗?
我在错误的树上吠叫吗?
And*_*rie 22
我认为你的错误如下:
以下是您应该如何执行此操作,分两步:
get_map()并将其保存到磁盘save()ggmap()首先,获取地图.
library (ggmap)
# Read map from google maps and save data to file
mapImageData <- get_googlemap(
c(lon=-74.0087986666667, lat=40.7106593333333),
zoom=15
)
save(mapImageData, file="savedMap.rda")
Run Code Online (Sandbox Code Playgroud)
然后,在一个新的会话中:
# Start a new session (well, clear the workspace, to be honest)
rm(list=ls())
# Load the saved file
load(file="savedMap.rda")
# Set up some data
myData <- data.frame(
lat = c (40.702147, 40.718217, 40.711614),
lon = c (-74.012318, -74.015794, -73.998284)
)
# Plot
ggmap(mapImageData) +
geom_point(aes(x=lon, y=lat), data=myData, colour="red", size=5)
Run Code Online (Sandbox Code Playgroud)
