Error working with OpenStreetMap spatial Data

Oki, now I understand. The approach I suggested originally (the osmdata package) is not really appropriate for downloading map backgrounds. It works the best for getting vector representations of points of interest, administrative regions and so on.

For background maps you might get better results with the ggmap package. It should support Open Street Map, but the functionality is unfortunately defunct at the moment.

If you are not dead set on Open Street Map tiles, and can work with other providers - I propose Stamen - then this code might be of use to you. I have verified it on a RStudio server installation, so I expect it to work in your use case as well.

library(ggmap)

galapagos <- get_stamenmap(bbox = c(left = - 91, 
                                    bottom = -1.0, 
                                    right = -89.8, 
                                    top = -0.18),
                           zoom = 10, 
                           maptype = "terrain-background")

points <- data.frame(x = c(-90, -90.5, -90.25), # some random points...
                     y = c(-0.5, -0.8, -0.3))

ggmap(galapagos) + # the base map
  geom_point(data = points, aes(x = x, y = y), 
             color = "red") # standard ggplot2 syntax

1 Like