历史:从静态Google map png中提取栅格数据,通过ggimage将其加载到R设备上。
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))我确实在rasterArray上运行了dput,但输出是20MB,不能在这里发布。
顺便说一句,this is the URL of that static map:
问:要在包含地图的R设备上绘制"GPS坐标“(以像素为单位),我是否需要scale data.frame
我看到了这个页面:http://www-personal.umich.edu/~varel/rdatasets/Langren1644.html,我需要像他们在这里展示的那样进行缩放吗?
如果是,那么除了scale函数的手册页之外,我还需要了解什么才能完成这项工作?
我是不是冲错树叫了?
发布于 2012-07-25 23:13:45
我认为你的错误如下:
中转置您的纬度和经度
下面是你应该怎么做,分两步来做:
使用ggmap()使用save()
get_map()地图并将其保存到磁盘首先,拿到地图。
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")然后,在新的会话中:
# 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)

https://stackoverflow.com/questions/11648870
复制相似问题