I was attempting to geomap a contour heatmap of my data on top of a google map. However, I find a persistent problem.
When I create the contour map without adding a geographic map, the function works fine and gives me the following graphic.
CODE
library(ggplot2)
library(ggmap)
latlonpostcandat<-data.frame(cbind(c(47.00735, 47.36228, 47.40399, 48.08666,47.57196,
47.63742),
c(-52.95892, -53.29399, -52.79987, -52.89429, -53.27813, -52.92653),
c(86301.14, 1017390.34, 2662332.67, 473139.73, 8251899.99, 167512.52)))
names(latlonpostcandat)<-c('Longitude','Latitude','Trans_Amt')
ggplot(latlonpostcandat,aes(x = Longitude, y = Latitude, z = Trans_Amt)) +
geom_contour()
Now, when I do the exact same thing but execute the following code:
map <- get_map(location='Canada', zoom=3, maptype = "terrain",
source='google',color='color')
ggmap(map)+
ggplot(latlonpostcandat, aes(x = Longitude, y = Latitude, z = Trans_Amt)) +
geom_contour()
I get the following error: Error: Don't know how to add o to a plot
I feel there is something subtly wrong here that is preventing me from getting the results I expect.
Thank you for your time.