-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ggmap does not work with plot_sf/geom_sf #336
Comments
The warning could have been a hint: plot(st_transform(nc, 3857)[1], col = 0, bgMap = nc_map) As you see, the background map is pretty much off; The issue of |
So the issue is that |
Oh, I see now. I'm sorry for misreading. I think this issue can be closed, I'll try to take it up with ggplot/ggmap. |
For posterity, I'm finding some success when I get the
Oddly, I sometimes get a I think the original error may be related to the |
Hi yeedle, I have the same issue as you did and I've read the conversation between you and edzer. However, I didn't get the meaning of " take it up with ggplot/ggmap". Could you please show the codes you ran when you solved the problem? Thanks! Student in anxious process of a capstones project |
https://github.com/dkahle/ggmap - note that ggmap now requires an API key to use the google API. An alternative would be not using google; I've seen good results from people using package ggspatial. Let us know what you end up doing. |
@edzer The need for API key for But, good news, the workaround of @mikoontz still works ! Just add Also, why not remove the obligation to name the bounding box vector in Here a working example : mespoints <- st_read('{ "type": "FeatureCollection", "features": [
{ "type": "Feature", "geometry": {
"coordinates": [9.007992484256647,46.0299246522398],
"type": "Point"
}},
{ "type": "Feature", "geometry": {
"coordinates": [8.9478934338552,45.977147786636834],
"type": "Point"
}},
{"type": "Feature", "geometry": {
"coordinates": [8.8329890317913,46.04030106008443],
"type": "Point"
}},
{"type": "Feature", "geometry": {
"coordinates": [8.950073186262301,45.913272474209464],
"type": "Point"
}}
]}')
library(ggmap)
fondsCarte <- st_bbox(mespoints) %>% setNames(c("left", "bottom", "right", "top")) %>% get_stamenmap(maptype = "terrain",zoom=13)
ggmap(fondsCarte) + geom_sf(data=mespoints, inherit.aes = FALSE) |
I'm getting an error when attempting to combine a ggmap object with an sf object in a plot
So far so good. But when I try to combine them with
geom_sf
:And similarly with
plot_sf
:(It should be noted that the same error occurs even when the zoom level in
get_map
is set so that all of North Carolina is included in theggmap
object)The text was updated successfully, but these errors were encountered: