---
title: "OpenStreetMaps with {osmdata}"
output:
flexdashboard::flex_dashboard:
storyboard: true
orientation: columns
source_code: embed
vertical_layout: fill
theme: paper
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(osmdata)
options(scipen=10000)
```
Maps of Zaragoza
============================================================
Column
-----------------------------------------------------------
### Streets
```{r}
calles <- getbb("Zaragoza Spain")%>%
opq()%>%
add_osm_feature(key = "highway",
value = c("residential", "living_street",
"unclassified",
"service", "footway")) %>%
osmdata_sf()
ggplot() +
geom_sf(data = calles$osm_lines,
inherit.aes = FALSE,
color = "darkgrey",
size = .3,
alpha = .8)+
coord_sf(xlim = c(-0.98, -0.8),
ylim = c(41.6, 41.7),
expand = FALSE) +
theme_void() +
labs(title = "Zaragoza")
```
### Streets and highways / roads
```{r}
carreteras <- getbb("Zaragoza Spain")%>%
opq()%>%
add_osm_feature(key = "highway",
value = c("road", "motorway", "primary",
"secondary", "tertiary")) %>%
osmdata_sf()
ggplot() +
geom_sf(data = calles$osm_lines,
inherit.aes = FALSE,
color = "darkgrey",
size = .2,
alpha = .8)+
geom_sf(data = carreteras$osm_lines,
inherit.aes = FALSE,
color = "black",
size = .2,
alpha = .8)+
coord_sf(xlim = c(-0.98, -0.8),
ylim = c(41.6, 41.7),
expand = FALSE) +
theme_void() +
labs(title = "Zaragoza")
```
Column
------------------------------------------------------------------
### Rivers
```{r}
rios <- getbb("Zaragoza Spain")%>%
opq()%>%
add_osm_feature(key = "waterway",
value = c("river", "canal")) %>%
osmdata_sf()
ggplot() +
geom_sf(data = calles$osm_lines,
inherit.aes = FALSE,
color = "darkgrey",
size = .2,
alpha = .8)+
geom_sf(data = carreteras$osm_lines,
inherit.aes = FALSE,
color = "black",
size = .2,
alpha = .8)+
geom_sf(data = rios$osm_lines,
inherit.aes = FALSE,
color = "
size = .8,
alpha = .8) +
coord_sf(xlim = c(-0.98, -0.8),
ylim = c(41.6, 41.7),
expand = FALSE) +
theme_void() +
labs(title = "Zaragoza")
```
### Cycleway
```{r}
bici <- getbb("Zaragoza Spain")%>%
opq()%>%
add_osm_feature(key = "highway",
value = c("cycleway")) %>%
osmdata_sf()
ggplot() +
geom_sf(data = calles$osm_lines,
inherit.aes = FALSE,
color = "grey30",
size = .4,
alpha = .8) +
geom_sf(data = carreteras$osm_lines,
inherit.aes = FALSE,
color = "grey30",
size = .1,
alpha = .8) +
geom_sf(data = bici$osm_lines,
inherit.aes = FALSE,
color = "springgreen",
size = .4,
alpha = .6) +
geom_sf(data = rios$osm_lines,
inherit.aes = FALSE,
color = "lightblue",
size = .2,
alpha = .5) +
coord_sf(xlim = c(-0.98, -0.8),
ylim = c(41.6, 41.7),
expand = FALSE) +
theme_void() +
labs(title = "Zaragoza",
subtitle = "Cycle Network") +
theme(plot.background = element_rect(fill = "black"),
plot.title = element_text(colour = "white"),
plot.subtitle= element_text(colour = "white"))
```
Column
-----------------------------------------------------------
### BBVA Bank Branches
```{r}
bbva <- getbb("Zaragoza Spain")%>%
opq()%>%
add_osm_feature("name","BBVA")%>%
add_osm_feature("amenity","bank") %>%
osmdata_sf()
ggplot() +
geom_sf(data = calles$osm_lines,
inherit.aes = FALSE,
color = "grey30",
size = .4,
alpha = .8) +
geom_sf(data = carreteras$osm_lines,
inherit.aes = FALSE,
color = "grey30",
size = .1,
alpha = .8) +
geom_sf(data = bbva$osm_points,
colour = "red",
fill = "red",
alpha = .6,
size = 2,
shape = 21) +
geom_sf(data = rios$osm_lines,
inherit.aes = FALSE,
color = "lightblue",
size = .2,
alpha = .5) +
coord_sf(xlim = c(-0.98, -0.8),
ylim = c(41.6, 41.7),
expand = FALSE) +
theme_void() +
labs(title = "Zaragoza",
subtitle = "Branches of BBVA Bank") +
theme(plot.background = element_rect(fill = "black"),
plot.title = element_text(colour = "white"),
plot.subtitle= element_text(colour = "white"))
```
### Tobbaconist´s
```{r}
estancos <- getbb("Zaragoza Spain")%>%
opq()%>%
add_osm_feature(key = "shop",
value = "tobacco") %>%
osmdata_sf()
ggplot() +
geom_sf(data = calles$osm_lines,
inherit.aes = FALSE,
color = "grey30",
size = .4,
alpha = .8) +
geom_sf(data = carreteras$osm_lines,
inherit.aes = FALSE,
color = "grey30",
size = .1,
alpha = .8) +
geom_sf(data = estancos$osm_points,
colour="red",
fill="red",
alpha=.6,
size=2,
shape=21) +
geom_sf(data = rios$osm_lines,
inherit.aes = FALSE,
color = "lightblue",
size = .2,
alpha = .5) +
coord_sf(xlim = c(-0.98, -0.8),
ylim = c(41.6, 41.7),
expand = FALSE) +
theme_void() +
labs(title = "Zaragoza",
subtitle = "Tobacconist`s") +
theme(plot.background = element_rect(fill = "black"),
plot.title = element_text(colour = "white"),
plot.subtitle= element_text(colour = "white"))
```
Zaragoza
=======================================================
### Map of Zaragoza
```{r}
ggplot() +
geom_sf(data = calles$osm_lines,
inherit.aes = FALSE,
color = "orange",
size = .1,
alpha = .8)+
geom_sf(data = carreteras$osm_lines,
inherit.aes = FALSE,
color = "grey40",
size = .2,
alpha = .8)+
geom_sf(data = rios$osm_lines,
inherit.aes = FALSE,
color = "white",
size = .5,
alpha = .8) +
coord_sf(xlim = c(-0.98, -0.8),
ylim = c(41.6, 41.7),
expand = FALSE) +
theme_void() +
labs(title = " Zaragoza",
subtitle = " ") +
theme(plot.background = element_rect(fill = "black"),
plot.title = element_text(colour = "white", size = 16, hjust = 0.5))
```
London
=======================================================
### Cycleways in London
```{r}
min <- c(-0.1672, 51.4787)
max <- c(-0.0072, 51.5396)
lnd_df <- as.matrix(data.frame(min, max))
row.names(lnd_df) <- c("x","y")
bike_london_2 <- lnd_df %>%
opq()%>%
add_osm_feature(key = "highway",
value = c("cycleway")) %>%
osmdata_sf()
calles_london_2 <- lnd_df%>%
opq()%>%
add_osm_feature(key = "highway",
value = c("residential", "living_street",
"unclassified",
"service", "footway")) %>%
osmdata_sf()
ggplot(bike_london_2$osm_lines) +
geom_sf(colour="orange",
alpha=.5,
size=0.5,
shape=21)+
geom_sf(data = calles_london_2$osm_lines,
inherit.aes = F,
color = "grey40",
size = .2,
alpha = .5)+
theme_void() +
labs(title = "London") +
theme(plot.background = element_rect(fill = "black"),
plot.title = element_text(colour = "white", size = 16, hjust = 0.5))
```
Paris
===================================================================
### Cycleways in Paris
```{r}
min <- c(2.2680, 48.8281)
max <- c(2.4424, 48.8925)
paris_df <- as.matrix(data.frame(min, max))
row.names(paris_df) <- c("x","y")
bike_paris <- paris_df %>%
opq()%>%
add_osm_feature(key = "highway",
value = c("cycleway")) %>%
osmdata_sf()
calles_paris <- paris_df%>%
opq()%>%
add_osm_feature(key = "highway",
value = c("residential", "living_street",
"unclassified",
"service", "footway")) %>%
osmdata_sf()
ggplot(bike_paris$osm_lines) +
geom_sf(colour="orange",
alpha=.5,
size=0.5,
shape=21)+
geom_sf(data = calles_paris$osm_lines,
inherit.aes = F,
color = "grey40",
size = .2,
alpha = .5)+
theme_void() +
labs(title = "Paris") +
theme(plot.background = element_rect(fill = "black"),
plot.title = element_text(colour = "white", size = 16, hjust = 0.5))
```
Amsterdam
==========================================================================
### Cycleways in Amsterdam
```{r}
min <- c(4.8573, 52.3571)
max <- c(4.9445, 52.3870)
amst_df <- as.matrix(data.frame(min, max))
row.names(amst_df) <- c("x","y")
bike_amst <- amst_df %>%
opq()%>%
add_osm_feature(key = "highway",
value = c("cycleway")) %>%
osmdata_sf()
calles_amst <- amst_df%>%
opq()%>%
add_osm_feature(key = "highway",
value = c("residential", "living_street",
"unclassified",
"service", "footway")) %>%
osmdata_sf()
ggplot(bike_amst$osm_lines) +
geom_sf(colour="orange",
alpha=.5,
size=0.5,
shape=21)+
geom_sf(data = calles_amst$osm_lines,
inherit.aes = F,
color = "grey40",
size = .2,
alpha = .5)+
theme_void() +
labs(title = "Amsterdam") +
theme(plot.background = element_rect(fill = "black"),
plot.title = element_text(colour = "white", size = 16, hjust = 0.5))
```
México D.F.
==========================================================================
### México D.F.
```{r}
min <- c(-99.2282, 19.3822)
max <- c(-99.0538, 19.4745)
mex_df <- as.matrix(data.frame(min, max))
row.names(mex_df) <- c("x","y")
calles_mex <- mex_df%>%
opq()%>%
add_osm_feature(key = "highway",
value = c("residential", "living_street",
"unclassified",
"service", "footway")) %>%
osmdata_sf()
ggplot() +
geom_sf(data = calles_mex$osm_lines,
inherit.aes = F,
color = "plum",
size = .2,
alpha = .5)+
theme_void() +
labs(title = "México D.F.") +
theme(plot.background = element_rect(fill = "black"),
plot.title = element_text(colour = "white", size = 16, hjust = 0.5))
```