使用R中的OpenstreetMap绘制点

时间:2017-06-25 12:56:16

标签: r plot openstreetmap

我试图从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)

0 个答案:

没有答案