I'm not sure if this is the right place to ask this question, but does anybody have suggestions for accessing different map styles that can be used for ggmap? CloudMade no longer gives API keys to accounts which are not 'enterprise accounts'.
From "ggmap: Spatial Visualization with ggplot2" (Kahle and Wickham), they suggest to either use Stamen or Google maps, but I'm looking for a different style than offered by these.
Can anybody suggest a repository of map styles that could be used for ggmap?
Cheers
You can get a simple land - water contrast using the maps
package:
Set the boundaries of the map with xlim and ylim.
library(maps)
library(ggplot2)
map <- fortify(map(fill = TRUE, plot = FALSE))
ggplot(data = map, aes(x=long, y=lat, group = group)) +
geom_polygon(fill = "ivory2") +
geom_path(colour = "black") +
coord_cartesian(xlim = c(137, 164), ylim = c(-14, 3.6)) +
theme(panel.background = element_rect(fill = "#F3FFFF"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
The map is a bit clunky, but high resolution maps are available in the mapdata
package>
library(mapdata)
map <- fortify(map("worldHires", fill = TRUE, plot = FALSE))
ggplot(data = map, aes(x=long, y=lat, group = group)) +
geom_polygon(fill = "ivory2") +
geom_path(colour = "black") +
coord_cartesian(xlim = c(135, 165), ylim = c(-15, 0)) + # Papua New Guinea
theme(panel.background = element_rect(fill = "#F3FFFF"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank()) # Be patient
Or a single country can be selected.
map <- fortify(map("worldHires", fill = TRUE, plot = FALSE))
ggplot(data = subset(map, region == "Papua New Guinea"), aes(x=long, y=lat, group = group)) +
geom_polygon(fill = "ivory2") +
geom_path(colour = "black") +
theme(panel.background = element_rect(fill = "#F3FFFF"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
Google maps has a little know style feature:
https://developers.google.com/maps/documentation/javascript/styling
As another comment noted, get_map is just a wrapper for get_googlemap, etc. And then get_googlemap is just a wrapper for a series of http calls to get map tiles, so it seems possible to hack up the code from get_googlemap a bit so instead of pointing at the basic google map style, it would grab styled tiles.
I may work on this approach over the next month as I have a need for a similar basemap as requested by OP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With