1

When I run the code from the accepted answer (Plot coordinates on map), I get the following error message on the first run after installing ggmap:

# loading the required packages
library(ggplot2)
library(ggmap)

# creating a sample data.frame with your lat/lon points
lon <- c(-38.31,-35.5)
lat <- c(40.96, 37.5)
df <- as.data.frame(cbind(lon,lat))

# getting the map
mapgilbert <- get_map(location = c(lon = mean(df$lon), lat = mean(df$lat)), zoom = 4,
                      maptype = "satellite", scale = 2)

# plotting the map with some points on it
ggmap(mapgilbert) +
  geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8), size = 5, shape = 21) +
  guides(fill=FALSE, alpha=FALSE, size=FALSE)

which gives the error:

Error: GeomRasterAnn was built with an incompatible version of ggproto. Please reinstall the package that provides this extension.

I tried installing ggproto, but the error is:

> Warning in install.packages :
  package ‘ggproto’ is not available (for R version 3.3.2)

On subsequent attempts the error is:

Error: ggplot2 doesn't know how to deal with data of class ggmap/raster

I can plot the image using:

plot(mapgilbert)

I tried:

map2 <- get_map("Rotorua", zoom = 16)
ggmap(data = map2)

which returned the follow error message:

Error: ggplot2 doesn't know how to deal with data of class ggmap/raster

I just don't know R well enough to know where to look next for a solution -- have ensured all packages updated.

Mike Wise
  • 22,131
  • 8
  • 81
  • 104
Time Lord
  • 331
  • 2
  • 5
  • 12
  • 1st map: `ggmap(mapgilbert) + ...` 2nd map: `ggmap(map2)` – Sandy Muspratt Jan 17 '17 at 03:41
  • What is `mapgilbert`? ggmap does not take a data argument – Richard Telford Jan 17 '17 at 13:26
  • @RichardTelford, mapgilbert is a plot of the Gilbert Islands area. I have added the full code block for completeness. I have also tried the same code from scratch on another machine, adding the errors around version incompatibility. I hope this provides more clarity. I wondered if some of the error is around API keys, but this seems not to impact on the simple plot(mapgilbert) call, so perhaps not. – Time Lord Jan 17 '17 at 19:41
  • 1
    The question regarding `mapgilbert`, had been answered [here](http://stackoverflow.com/questions/40642850/ggmap-error-geomrasterann-was-built-with-an-incompatible-version-of-ggproto). That is, are you using the latest versions of ggplot2 and ggmap? The question regarding the Rotorua map, see my earlier comment. What do you get with `ggmap (map2)`? – Sandy Muspratt Jan 17 '17 at 20:47
  • mapgilbert code works on my computer (R version 3.3.2). – Richard Telford Jan 17 '17 at 20:56
  • @SandyMuspratt, I followed the link you provided. I reinstalled all of the packages (ggplot2, ggforce, ggmap ggrepel) using devtools versions. Restarted R-Studio and re-ran the code. Thankyou for you comments on this -- I assume that the tips to reinstall and use devtools were the solution. If you want to post an answer I would be happy to accept it. Thanks again. – Time Lord Jan 17 '17 at 21:49
  • Good to hear that it worked. But I don't think you need to install the github versions. That advice was relevant back in Nov 2016. In Jan 2017, the CRAN versions should have been sufficient. – Sandy Muspratt Jan 17 '17 at 22:22
  • @SandyMuspratt. On my other machine I reinstalled the four packages above, restarted R and same error. I then installed devtools of ggplot2 and ggmap, restarted and the code worked. For what it is worth in response to your comment. Thanks. – Time Lord Jan 17 '17 at 23:41

1 Answers1

1

This is probably the version error because your code runs perfectly on my machine (R 3.3.2). devtools::install_github("dkahle/ggmap") devtools::install_github("hadley/ggplot2")

You can download packages "devtools" and install ggmap and ggplot2 from github again.

Frankie
  • 61
  • 3