在R中使用OpenstreetMap绘制点
我试图从在R中使用OpenstreetMap绘制点,r,plot,openstreetmap,R,Plot,Openstreetmap,我试图从OpenStreetMap获取柏林地图,然后在上面绘制一些位置(它们应该看起来像点,而不是标记) 我得到的地图基于我的数据,因为我不想要一个完整的地图,但该地区包括所有的位置。但是,当我在地图上绘制点时,它会传递一条错误消息: 二进制运算符的非数值参数 我的代码: library(ggplot2) library(OpenStreetMap) # creating a sample data.frame with lat/lon points lon <- read.csv("
OpenStreetMap
获取柏林地图,然后在上面绘制一些位置(它们应该看起来像点,而不是标记)
我得到的地图基于我的数据,因为我不想要一个完整的地图,但该地区包括所有的位置。但是,当我在地图上绘制点时,它会传递一条错误消息:
二进制运算符的非数值参数
我的代码:
library(ggplot2)
library(OpenStreetMap)
# creating a sample data.frame with lat/lon points
lon <- read.csv("Data.csv", header = TRUE, colClasses=c("NULL", "NULL", NA))
lat <- read.csv("Data.csv", header = TRUE, colClasses=c("NULL", NA, "NULL"))
df <- as.data.frame(cbind(lon,lat))
# getting the map
mapberlin <- openmap(c(max(lat)+0.03,min(lon)-0.03), c(min(lat)-0.03,max(lon)+0.03), zoom = NULL,type = 'osm')
# plotting the map with some points on it and draw line between points
plot(mapberlin) + geom_point(data = df, aes(x = lon, y = lat, fill = 'red'), size = 2, shape = 21)
+geom_line(data = df, aes(x = lon, y = lat), color = 'blue') +
+guides(fill=FALSE, size=FALSE)
库(ggplot2)
图书馆(OpenStreetMap)
#创建带有lat/lon点的示例data.frame
请阅读;共享dput(head(df))
您能给出data.csv的前几行吗?id lat lon A 52.49006 13.35491 B 52.49009 13.41953 C 52.4902 13.35637 D 52.51668 13.414048这是我的几行数据。