Created
January 5, 2021 17:57
-
-
Save jlopezper/8a10b0e51e944dd4423bba1db0bb33c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(osmdata) # package for working with streets | |
library(showtext) # for custom fonts | |
library(ggmap) | |
library(rvest) | |
big_streets <- getbb("Canarias") %>% | |
opq()%>% | |
add_osm_feature(key = "highway", | |
value = c("motorway", "primary", "motorway_link", "primary_link")) %>% | |
osmdata_sf() | |
med_streets <- getbb("Canarias")%>% | |
opq()%>% | |
add_osm_feature(key = "highway", | |
value = c("secondary", "tertiary", "secondary_link", "tertiary_link")) %>% | |
osmdata_sf() | |
small_streets <- getbb("Canarias")%>% | |
opq()%>% | |
add_osm_feature(key = "highway", | |
value = c("residential", "living_street", | |
"unclassified", | |
"service", "footway" | |
)) %>% | |
osmdata_sf() | |
boundaries <- getbb("Canarias")%>% | |
opq()%>% | |
add_osm_feature(key = "boundary", | |
value = c("political")) %>% | |
osmdata_sf() | |
font_add_google(name = "Lato", family = "lato") # add custom fonts | |
showtext_auto() | |
png("/home/jlopezper/Descargas/plot.png", width = 465, height = 225, units='mm', res = 300) | |
ggplot() + | |
geom_sf(data = med_streets$osm_lines, | |
inherit.aes = FALSE, | |
color = "black", | |
size = .3, | |
alpha = .5) + | |
geom_sf(data = small_streets$osm_lines, | |
inherit.aes = FALSE, | |
color = "#666666", | |
size = .2, | |
alpha = .3) + | |
geom_sf(data = big_streets$osm_lines, | |
inherit.aes = FALSE, | |
color = "black", | |
size = .5, | |
alpha = .6) + | |
geom_sf(data = boundaries$osm_lines, | |
inherit.aes = FALSE, | |
color = "black", | |
size = .5, | |
alpha = .6) + | |
theme_void() + # get rid of background color, grid lines, etc. | |
theme(plot.title = element_text(size = 65, family = "lato", face="bold", hjust=.5), | |
plot.subtitle = element_text(family = "lato", size = 50, hjust=.5, margin=margin(2, 0, 5, 0))) + | |
labs(title = "CANARIAS", subtitle = "28° 31' 34.896'' N / 15° 44' 52.656'' W") | |
dev.off() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment