Street Maps
Create street map art with R and road network files
Data
STATCAN road network files
Germany rail roads
My shape files
Prepare Data
# STATCAN file
roads <- st_read("lrnf000r16a_e.shp")
# Filter cities
roads_saskatoon <- roads[roads$CSDNAME_L == "Saskatoon",]
roads_regina <- roads[roads$CSDNAME_L == "Regina",]
# Save
st_write(roads_saskatoon, "roads_saskatoon.shp")
st_write(roads_regina, "roads_regina.shp")
#
s_roads <- st_read("railways.shp")
Maps
Saskatoon
# Read file
s_roads <- st_read("roads_saskatoon.shp", quiet = T)
# Crop
s_roads2 <- st_intersection(s_roads, st_buffer(st_centroid(st_union(s_roads)), 8500))
# Plot
mp <- ggplot(s_roads2) +
geom_sf(color = "black") +
coord_sf(crs = st_crs(4326)) +
theme_void() +
theme(panel.grid.major = element_line("transparent")) +
labs(caption = myCaption)
ggsave("roads_saskatoon.png", mp, bg = "transparent", width = 6, height = 6)
# Crop
s_roads2 <- st_intersection(s_roads, st_buffer(st_centroid(st_union(s_roads)), 4000))
# Plot
mp <- ggplot(s_roads2) +
geom_sf(color = "black") +
coord_sf(crs = st_crs(4326)) +
theme_void() +
theme(panel.grid.major = element_line("transparent")) +
labs(caption = myCaption)
ggsave("roads_saskatoon_zoom.png", mp, bg = "transparent", width = 6, height = 6)
Regina
# Read file
r_roads <- st_read("roads_regina.shp", quiet = T)
# Crop
r_roads2 <- st_intersection(r_roads, st_buffer(st_centroid(st_union(r_roads)), 5000))
# Plot
mp <- ggplot(r_roads2) +
geom_sf(color = "black") +
coord_sf(crs = st_crs(4326)) +
theme_void() +
theme(panel.grid.major = element_line("transparent")) +
labs(caption = myCaption)
ggsave(filename = "roads_regina.png", mp, bg = "transparent", width = 6, height = 6)
Germany Railroads
# Read file
rail_roads <- st_read("railways.shp", quiet = T)
# Plot
mp <- ggplot(rail_roads) +
geom_sf(color = "black") +
coord_sf(crs = st_crs(4326)) +
theme_void() +
theme(panel.grid.major = element_line("transparent")) +
labs(caption = myCaption)
ggsave("railroads_germany.png", mp, bg = "transparent", width = 6, height = 6)
rcityviews
https://koenderks.github.io/rcityviews/
Saskatoon
#
xx <- list_cities()
xx <- list_cities(match = "Saskatoon")
#
mp <- cityview(name = "Saskatoon", zoom = 0.5)
#
ggsave("Saskatoon.png", mp, height = 5, width = 5, dpi = 100)