OpenStreetMaps autoplot error in RStudio Server and Shiny Server in R4.0.0

Viewed 685

I am getting a error when trying to plot OpenStreetMaps using autoplot in both RStudio Server and Shiny Server.

require(maps)
require(ggplot2)
require(OpenStreetMap)
mp <- openmap(c(53.38332836757155,-130.517578125),
c(15.792253570362446,-67.939453125),4,'stamen-watercolor')
mp_bing <- openmap(c(53.38332836757155,-130.517578125),
c(15.792253570362446,-67.939453125),4,'bing')
states_map <- map_data("state")
states_map_merc <- as.data.frame(
projectMercator(states_map$lat,states_map$long))
states_map_merc$region <- states_map$region
states_map_merc$group <- states_map$group
autoplot.osmtile 3
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
p <- autoplot(mp,expand=FALSE) + geom_polygon(aes(x=x,y=y,group=group),
data=states_map_merc,fill="black",colour="black",alpha=.1) + theme_bw()

The error is:

Error: Objects of type OpenStreetMap not supported by autoplot.

I'm using version R 4.0.0.

Any insight would be great since this worked fine on R version 3.5.2 just fine on a different Shiny server.

1 Answers

I had the same problem, too. Using OpenStreetMap::autoplot.OpenStreetMap() instead of ggplot2::autoplot(), I managed to obtain an attached image:

Attached image

Related