Plot lat/lon points on OpenStreetMap Using R - r

I am trouble wrapping my head around projection. My points for a place in Northern Europe ends up in Mid Africa.
My code goes as follow.
#Loading packages
library(OpenStreetMap)
library(rgdal)
library(ggplot2)
#defining world map
map <- openmap(c(70,-179), c(-70,179))
plot(map)
#Finding my work place in Northern Europe (Ørbækvej 100, Odense, Denmark from here: https://www.latlong.net/convert-address-to-lat-long.html)
subscr<-data.frame(lat=c(55.381640),
lon=c(10.433600))
#I am not sure what this does, but found on the web for a map in Germany: (https://gis.stackexchange.com/questions/209166/plotting-bubbles-on-top-of-openstreetmap-in-r)
coordinates(subscr)<-~lat+lon
proj4string(subscr)<-CRS("+init=epsg:4326")
points(spTransform(subscr,osm()))
#as can be seen using this method the dot turns up in Eastern Africa
symbols(y = subscr$lon, x = subscr$lat, circles = 1, add = TRUE,
inches = 0.0001, bg = "darkgreen")
#as can be seen using the method the dot turns up in Western/Mid Africa
Can anyone explain or even help me to get the dot placed in Denmark, Northern Europe?

I do not know what kind of map you want, but for plotting lat-lon points, leaflet is my default weapon of choice..
library( leaflet )
library( magrittr )
subscr<-data.frame(lat=c(55.381640),
lon=c(10.433600))
leaflet() %>% addTiles() %>%
addCircleMarkers(data = subscr,
lat = ~lat, lng = ~lon,
color = "blue")

Are you bound to using open street maps? You might consider using the ggmap package which interacts pretty well with ggplot2. However, I sometimes have troubles with downloading an open street map with ggmap, but google-maps should work.
Consider the following example. Note that I removed unnecessary text in the map in the download command.
# download
map <- get_googlemap(center = "Europe", zoom = 3,
style = paste0("feature:administrative.country|",
"element:labels|visibility:off"),
filename = "Map",
language = "en-EN") # you might want to adjust the language settings
# see what you've got
ggmap(map)
# edit map
ggmap(map)+
# do some scaling (make it smaller)
scale_x_continuous(limits = c(-12, 42), expand = c(0, 0)) +
scale_y_continuous(limits = c(35, 70), expand = c(0, 0))+
# remove unwanted information
theme(axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.line = element_blank(),
axis.ticks = element_blank(),
axis.text = element_blank(),
plot.title = element_blank(),
plot.background = element_blank())+
# add whatever you like based on your coordinates using annotate()
annotate("text", x = 10.433600, y = 55.381640,
label = "You are here",
size = 2.4, color = "black", fontface = "bold",
na.rm = TRUE, hjust = 0.5)
Does this solve your problem?

Related

Limit Simple Features Plot based on geojson Polygon

I'd like to limit a plot based on a polygon defined in geojson, so that it only shows the area shaded blue here.
i.e. just plot the features inside and including the ring road.
The geojson is available here.
It would also be great to add a buffer around the edge to include the ring road.
My code to draw all the features (unlimited by the geojson is below).
library(tidyverse)
library(osmdata)
bounding_box <- getbb("Birmingham", featuretype = "city")
streets <- bounding_box %>%
opq()%>%
add_osm_feature(key = "highway",
value = c("motorway", "trunk", "primary", "secondary", "tertiary")) %>%
osmdata_sf()
ggplot() +
geom_sf(data = streets$osm_lines,
inherit.aes = FALSE,
color = "grey",
size = 1) +
theme_void() +
theme(
plot.background = element_rect(fill = "white"),
legend.position = "none"
) +
coord_sf(xlim = c(-1.933, -1.869),
ylim = c(52.46, 52.496),
expand = FALSE)
I assume in the following that the object streets has already been defined by running the first few lines of the code in the question. The next step is then to read the polygon using read_sf() from the sf package. The next line converts to a more suitable coordinate system (OSGB 1936 / British National Grid) because adding a buffer in meters is not possible in lon/lat-coordinates. A buffer of 40 meters is added using st_buffer() and finally the coordinates are transformed back to WGS84:
library(sf)
area <- read_sf("~/Birmingham CAZ 2020.GeoJSON") %>%
st_transform(27700) %>%
st_buffer(units::set_units(40, m)) %>%
st_transform(4326)
Of course, you need to adapt the path to where you have actually stored the file. Then I use st_intersection() to extract the part of streets$osm_lines that lies inside the polygon:
streets_area <- st_intersection(poly, streets$osm_lines)
And finally I produce the plot using the code from your question. Note that I have added a layer with the polygon in the second line in order to demonstrate that the streets indeed lie inside the polygon:
ggplot() +
geom_sf(data = area) +
geom_sf(data = streets_area,
inherit.aes = FALSE,
color = "grey",
size = 1) +
theme_void() +
theme(
plot.background = element_rect(fill = "white"),
legend.position = "none"
) +
coord_sf(xlim = c(-1.933, -1.869),
ylim = c(52.46, 52.496),
expand = FALSE)

R: Counting how many polygons between two

I was trying to recreate a map showing how many municipals are you away from Cracow:
and to change the city from Cracow to Wrocław. The map was done in GIMP.
I got a shapefile (available here: http://www.gis-support.pl/downloads/powiaty.zip). I read the shapefile documentation packages like maptools, rgdal or sf, but I couldn't find an automatic function to count it, because I wouldn't like to do that manually.
Is there a function to do that?
Credits: The map was done by Hubert Szotek on https://www.facebook.com/groups/mapawka/permalink/1850973851886654/
I am not that experienced at network analysis, so I must confess not to understand every single line of code as follows. But it works! A lot of the material was adapted from here: https://cran.r-project.org/web/packages/spdep/vignettes/nb_igraph.html
This is the final results:
Code
# Load packages
library(raster) # loads shapefile
library(igraph) # build network
library(spdep) # builds network
library(RColorBrewer) # for plot colour palette
library(ggplot2) # plots results
# Load Data
powiaty <- shapefile("powiaty/powiaty")
Firstly the poly2nb function is used to calculate neighbouring regions:
# Find neighbouring areas
nb_q <- poly2nb(powiaty)
This creates our spatial mesh, which we can see here:
# Plot original results
coords <- coordinates(powiaty)
plot(powiaty)
plot(nb_q, coords, col="grey", add = TRUE)
This is the bit where I am not 100% sure what is happening. Basically, it is working out the shortest distance between all the shapefiles in the network, and returns a matrix of these pairs.
# Sparse matrix
nb_B <- nb2listw(nb_q, style="B", zero.policy=TRUE)
B <- as(nb_B, "symmetricMatrix")
# Calculate shortest distance
g1 <- graph.adjacency(B, mode="undirected")
dg1 <- diameter(g1)
sp_mat <- shortest.paths(g1)
Having made the calculations, the data can now be formatted to get into plotting format, so the shortest path matrix is merged with the spatial dataframe.
I wasn't sure what would be best to use as the ID for referring to datasets so I chose the jpt_kod_je variable.
# Name used to identify data
referenceCol <- powiaty$jpt_kod_je
# Rename spatial matrix
sp_mat2 <- as.data.frame(sp_mat)
sp_mat2$id <- rownames(powiaty#data)
names(sp_mat2) <- paste0("Ref", referenceCol)
# Add distance to shapefile data
powiaty#data <- cbind(powiaty#data, sp_mat2)
powiaty#data$id <- rownames(powiaty#data)
The data is now in a suitable format to display. Using the basic function spplot we can get a graph quite quickly:
displaylayer <- "Ref1261" # id for Krakow
# Plot the results as a basic spplot
spplot(powiaty, displaylayer)
I prefer ggplot for plotting more complex graphs as you can control the styling easier. However it is a bit more picky about how the data is fed into it, so we need to reformat the data for it before we build the graph:
# Or if you want to do it in ggplot
filtered <- data.frame(id = sp_mat2[,ncol(sp_mat2)], dist = sp_mat2[[displaylayer]])
ggplot_powiaty$dist == 0
ggplot_powiaty <- powiaty %>% fortify()
ggplot_powiaty <- merge(x = ggplot_powiaty, y = filtered, by = "id")
names(ggplot_powiaty)
And the plot. I have customised it a bit by removing elements which aren't required and added a background. Also, to make the region at the centre of the search black, I subset the data using ggplot_powiaty[ggplot_powiaty$dist == 0, ], and then plot this as another polygon.
ggplot(ggplot_powiaty, aes(x = long, y = lat, group = group, fill = dist)) +
geom_polygon(colour = "black") +
geom_polygon(data =ggplot_powiaty[ggplot_powiaty$dist == 0, ],
fill = "grey60") +
labs(title = "Distance of Counties from Krakow", caption = "Mikey Harper") +
scale_fill_gradient2(low = "#d73027", mid = "#fee08b", high = "#1a9850", midpoint = 10) +
theme(
axis.line = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
plot.background = element_rect(fill = "#f5f5f2", color = NA),
panel.background = element_rect(fill = "#f5f5f2", color = NA),
legend.background = element_rect(fill = "#f5f5f2", color = NA),
panel.border = element_blank())
To plot for Wrocław as shown at the top of the post, just change displaylayer <- "Ref0264" and update the title.

Edit labels in tooltip for plotly maps using ggplot2 in r

I know this question has been asked a number of times but I think some of the underlying syntax for plotly has changed since those questions have been asked. Using ggplotly() to create a choropleth map gives the default tooltip of long, lat, group, and one of my variables from my aesthetics. I understand that tooltip maps only whats in the aesthetics. All I want to do is to customize the tooltip so it displays some of the variables in my dataset (including those not mapped to aesthetics) and not others (such as the coordinates). Below is a reproducible example and what I've tried so far. I followed the advice given in response to other questions to no avail.
#Load dependencies
library(rgeos)
library(stringr)
library(rgdal)
library(maptools)
library(ggplot2)
library(plotly)
#Function to read shapefile from website
dlshape=function(shploc, shpfile) {
temp=tempfile()
download.file(shploc, temp)
unzip(temp)
shp.data <- sapply(".", function(f) {
fp <- file.path(temp, f)
return(readOGR(".",shpfile))
})
}
austria <- dlshape(shploc="http://biogeo.ucdavis.edu/data/gadm2.8/shp/AUT_adm_shp.zip",
"AUT_adm1")[[1]]
#Create random data to add as variables
austria#data$example1<-sample(seq(from = 1, to = 100, by = 1), size = 11, replace = TRUE)
austria#data$example2<-sample(seq(from = 1, to = 100, by = 1), size = 11, replace = TRUE)
austria#data$example3<-sample(seq(from = 1, to = 100, by = 1), size = 11, replace = TRUE)
#Fortify shapefile to use w/ ggplot
austria.ft <- fortify(austria, region="ID_1")
data<-merge(austria.ft, austria, region="id", by.x = "id", by.y = "ID_1")
#Save as ggplot object
gg<-ggplot(data, aes(x = long, y = lat, fill = example1, group = group)) +
geom_polygon() + geom_path(color="black",linetype=1) +
coord_equal() +
scale_fill_gradient(low = "lightgrey", high = "darkred", name='Index') +xlab("")+ylab("") +
theme(axis.text = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank()) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))
#Plot using ggplotly
ggplotly(gg)
From here I've tried two different approaches. The most successful one of the approaches gets me there in part. I can add new variables to to the tooltip but I cannot do two things: 1) I cannot get rid of other variables already displayed by default (from the aesthetics) and 2) I cannot rename the variables something other than their column name from the dataset (for example I would like to label "example3 as "Example III"). Here is that approach:
#Save as a new ggplot object except this time add ``label = example3`` to the aesthetics
gg2<-ggplot(data, aes(x = long, y = lat, fill = example1, group = group, label = example3)) +
geom_polygon() + geom_path(color="black",linetype=1) +
coord_equal() +
scale_fill_gradient(low = "lightgrey", high = "darkred", name='Index') +xlab("")+ylab("") +
theme(axis.text = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank()) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))
#Save as plotly object then plot
gg2 <- plotly_build(gg2)
gg2
I also tried adding the following but it did nothing:
gg2$data[[1]]$text <- paste("Example I:", data$example1, "<br>",
"Example II:", data$example2, "<br>",
"Example III:", data$example3)
Any help is much appreciated!
UPDATE: I updated plotly by installing from github instead of CRAN. Using this updated version (4.0.0) I've made it apart of the way there.
gg2$x$data[[2]]$text <- paste("Example I:", data$example1, "<br>",
"Example II:", data$example2, "<br>",
"Example III:", data$example3)
gg2
What happens now simply baffles me. This adds an additional tooltip separate from the previous one. This new tooltip is exactly what I want however both of them appear -not at once but if I move my mouse around. See the two screenshots below:
Notice those tooltips are from the same unit (Tirol). Could this be a bug in the package? This does not occur when display other graphs such as a time-series instead of a map. Also note, that I assigned the label "Example I" (or II or III) and this does not show on the new tooltip I added.
UPDATE #2: I figured out that the old tooltip (with long and lat shown) only appears when hovering over the borders so I got rid of the geom_path(color="black",linetype=1) command (as to remove the borders) and now I've managed to successfully solve that problem. However, I'm still unable to modify the labels that appear in the tooltip.
UPDATE #3: I figured out how to edit the labels but FOR ONLY ONE VARIABLE. Which is nuts! Here's my workflow from start to finish:
#Load dependencies
library(rgeos)
library(stringr)
library(rgdal)
library(maptools)
library(ggplot2)
library(plotly)
#Function to read shapefile from website
dlshape=function(shploc, shpfile) {
temp=tempfile()
download.file(shploc, temp)
unzip(temp)
shp.data <- sapply(".", function(f) {
fp <- file.path(temp, f)
return(readOGR(".",shpfile))
})
}
austria <- dlshape(shploc="http://biogeo.ucdavis.edu/data/gadm2.8/shp/AUT_adm_shp.zip",
"AUT_adm1")[[1]]
#Create random data to add as variables
austria#data$example1<-sample(seq(from = 1, to = 100, by = 1), size = 11, replace = TRUE)
austria#data$example2<-sample(seq(from = 1, to = 100, by = 1), size = 11, replace = TRUE)
austria#data$example3<-sample(seq(from = 1, to = 100, by = 1), size = 11, replace = TRUE)
#Fortify shapefile to use w/ ggplot
austria.ft <- fortify(austria, region="ID_1")
data<-merge(austria.ft, austria, region="id", by.x = "id", by.y = "ID_1")
#Save as ggplot object
gg<-ggplot(data, aes(x = long, y = lat, fill = example1, group = group, text = paste("Province:", NAME_1))) +
geom_polygon(color="black", size=0.2) +
coord_equal() +
scale_fill_gradient(low = "lightgrey", high = "darkred", name='Index') +xlab("")+ylab("") +
theme(axis.text = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank()) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black")) +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"))
gg <- plotly_build(gg)
gg
That produces the following plot:
Notice that "Province" is now capitalized (it was not before). The trick was adding text = paste("Province:", NAME_1) to the aesthetics. HOWEVER, when I tried to add additional label changes using text2=paste("Example III:", example1), the following occurs:
Notice that it cannot render text2 the same way it renders text1. So instead I simply try adding a duplicate without the text2 like in the following: text=paste("Example III:", example1) -which produces the following odd result:
I'm beginning to think something as simple as toggling "legend" options in plotly's ggplot conversion is impossible.
UPDATE #4: So I decided to approach this another way. Instead, I decided to change the variable names themselves. I would have done this from the start, except I wasn't sure if/how ggplot2 accepts variables with spaces -i figured out `variable` that can work. So I went ahead and relabeled the variables. It works -KINDA. The problem is the text appears with the quotations marks around them. Now I need a way to get rid of these!!! Any ideas anyone? Thanks! Here is an image of what I mean by quotations in the text:
I am new to plotly too but have come across a similar problem for my ggplot2 bubble plots when using ggplotly(). I have finally found a solution that works for me and thought it might help you, too, although I haven't tried it for choropleth maps.
Your first question was to customize the tooltip so it displays some of the variables in the dataset (including those not mapped to aesthetics).
In your UPDATE#3 you introduce:text = paste("Province:", NAME_1) into your aes. If you want to add a second line of custom variables or text, just keep adding it into the brackets:text = paste("Province:", NAME_1, "Example III:", example1) To add a line break between both add <br> in the spot where you want the break to be, like:text = paste("Province:", NAME_1, "<br>", "Example III:", example1)
Your second question was to customize the tooltip so it does NOT display other (default) variables (that are mapped to aesthetics, such as the coordinates).
I found this very easy addition to the ggplotly() function that did the trick for me: ggplotly(gg, tooltip = c("text")) In my case, this removed ALL default variables that are shown in the tooltip and only showed those that are custom specified with text above. You can add other variables back in by doing ggplotly(gg, tooltip = c("text","x")) The order of the variables shown in the tooltip will be the same as the order specified in the tooltip argument. I found this documented here: https://github.com/ropensci/plotly/blob/master/R/ggplotly.R
This solution worked (in principle) for me using R 3.1.1 and plotly 3.4.13

Plotting Airbnb data over NASA's "black marble" geotiff

I am trying to create an image similar to that presented by Ricardo Bion of Airbnb but I would like to plot the visualization over the NASA "black marble" image to give more context as I don't have nearly the data density of the Airbnb dataset.
I downloaded the Nasa black marble image here using the global map 13500x6750 (3km) GeoTIFF 39 MB option.
This issue I keep running into is most of the options and explanations available online have been depreciated in the past few years. I tried using EBImage as shown here but ebimageGrob has been removed from gridExtra. I also tried to use the rasterVis package as shown here but the code breaks at the colorable step.
Here is as far as I have made it trying to layer the tiff behind the plot using the ggplot2 annotation_raster option (this gives the lines between the destinations but only a white background):
library(ggplot2)
library(ggmap)
library(sp)
library(grid)
library(geosphere)
library(plyr)
library(tiff)
# source the theme_map for ggplot2
# source("https://dl.dropboxusercontent.com/u/2364714/theme_map.R")
# in the original post I had a data.frame with 500k rows of top origin destination pairs
trips <- data.frame(origin = c("San Francisco", "Sydney", "Chicago"),
destination = c("Paris", "Tokyo", "Boston"),
stringsAsFactors = FALSE)
# get lat and lon of cities
trips$geocode_origin <- suppressMessages(geocode(trips$origin))
trips$geocode_destination <- suppressMessages(geocode(trips$destination))
# get intermediate points between the two locations
arch <- gcIntermediate(trips$geocode_origin,
trips$geocode_destination,
n=100,
breakAtDateLine=FALSE,
addStartEnd=TRUE, sp=TRUE)
# http://docs.ggplot2.org/0.9.3.1/fortify.map.html
arch_fortified <- ldply(arch#lines, fortify)
earth <- readTIFF("~/Downloads/dnb_land_ocean_ice.2012.13500x6750_geo.tif")
theme_map <- function(base_size = 12) {
require(grid)
theme_grey(base_size) %+replace%
theme(
axis.title = element_blank(),
axis.text = element_blank(),
panel.grid = element_blank(),
axis.ticks.length = unit(0,"cm"),
panel.margin = unit(0,"lines"),
plot.margin = unit(c(0,0,0,0),"lines"),
complete = TRUE,
panel.background = element_rect(fill = NA, colour=NA)
)
}
# a few lines of ggplot2 code
ggplot() +
geom_line(aes(long,lat,group=group), data=arch_fortified, alpha=0.1,size=1, colour="skyblue1") +
coord_cartesian(ylim =c(-45, 70), xlim=c(-165, 165)) +
theme_map() +
geom_point(aes(lon, lat),data=trips$geocode_origin, alpha = 0.8, size = 1, colour = "white") +
geom_point(aes(lon, lat),data=trips$geocode_destination, alpha = 0.8, size = 1, colour = "white") +
annotation_raster(earth, -180, 180, -90, 90)
Thanks!
I just had to slightly modify your plotting code to get it work:
ggplot(arch_fortified) +
coord_cartesian(ylim =c(-45, 70), xlim=c(-165, 165)) +
theme_map() +
annotation_raster(earth, -180, 180, -90, 90) +
geom_line(aes(long,lat,group=group), alpha=0.1,size=1, colour="skyblue1") +
geom_point(aes(lon, lat),data=trips$geocode_origin, alpha = 0.8, size = 1, colour = "white") +
geom_point(aes(lon, lat),data=trips$geocode_destination, alpha = 0.8, size = 1, colour = "white")
Note that you should first draw the background and only then the lines and points, otherwise the image will cover other plot elements.

ggmap map style repository? Now that CloudMade no longer gives out APIs

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.
This currently works best with the development version of ggmap. To use this you need to run devtools::install_github("dkahle/ggmap")
I have developed a new package ggmapstyles, which should help with this problem: https://github.com/mikey-harper/ggmapstyles . It provides an easy way of selecting themes from Snazzy Maps, which has over 16,000 different styles premade and allows you to create custom designs.
To use a design, go to Snazzymaps and find a style you like, and then copy the URL into the function get_snazzymap() using the mapRef argument:
devtools::install_github("dr-harper/ggmapstyles")
library(ggmapstyles)
map <- get_snazzymap(center = 'Southampton, UK',
mapRef = "https://snazzymaps.com/style/72543/assassins-creed-iv")
ggmap(map)
Will plan on developing this further, and potentially merge it with ggmap in the future :)
This is the function definition for get_map:
function (location = c(lon = -95.3632715, lat = 29.7632836),
zoom = "auto", scale = "auto", maptype = c("terrain", "satellite",
"roadmap", "hybrid", "toner", "watercolor"), messaging = FALSE,
urlonly = FALSE, filename = "ggmapTemp", crop = TRUE, color = c("color",
"bw"), source = c("google", "osm", "stamen", "cloudmade"),
api_key)
and, there's a series of if statements in it that limit it to the source = … options.
You can combine them with the various maptype = … options to try to get something that works for you.

Resources