0

I tried to get Berlin map from OpenStreetMap and then plot some locations on it (they should look like points, not markers).

I got the map based on the data I have cause I don't want a whole map, but area where includes all locations. However when I plot the points on the map, it delivers an error message:

non-numeric argument to binary operator

My code:

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)
James Z
  • 12,209
  • 10
  • 24
  • 44
Anna
  • 101
  • 1
  • 12
  • 1
    please read [how to write a great R question](https://stackoverflow.com/q/5963269/3250126); share `dput(head(df))` – loki Jun 25 '17 at 13:02
  • 1
    could you give the first few lines of `data.csv`? – jmk Jun 25 '17 at 13:50
  • id lat lon A 52.49006 13.35491 B 52.49009 13.41953 C 52.4902 13.35637 D 52.51668 13.414048 Here is my few lines of data. – Anna Jun 26 '17 at 17:30

0 Answers0