I'm trying to plot a static base map underneath my sf
object (for print). When using ggmap
I first get a lot of errors, then I can't seem to figure out how to chain the base map to my ggplot2
object with a geom_sf
.
library(sf)
# devtools::install_github("tidyverse/ggplot2")
library(ggplot2)
library(ggmap)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
nc_map <- get_map(location = "North Carolina, NC", zoom = 7)
ggmap(nc_map)
nc_centers <- st_centroid(nc)
nc_centers %>%
ggplot() +
geom_sf(aes(color = SID79, size = BIR74),
show.legend = "point") +
coord_sf(datum = NA) +
theme_minimal()
I also rather use the source = "osm"
as style but those will always return '400 Bad Request'
.
Is there maybe another good package for base maps?
leaflet
is a good package imo - don't know though if you'll be able to complete your task with it. – Pyrophosphateleaflet
for interactive maps right? I'm looking for static print solutions. – Flintlockmapview::mapshot
to save leaflet maps as a static file (jpeg, png etc.). Maybe that suits your needs – Gillian