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
license: cc-by-4.0 | |
height: 500 | |
scrolling: no | |
border: yes |
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
license: cc-by-4.0 | |
height: 500 | |
scrolling: no | |
border: yes |
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
license: cc-by-4.0 | |
height: 500 | |
scrolling: no | |
border: yes |
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
ggplot() + # initialise a ggplot object | |
geom_sf(data = sf_gm_census, # add a simple features (sf) object | |
aes(fill = cut_number(percent, 5)), # group percent into equal intervals and use for fill | |
alpha = 0.8, # add transparency to the fill | |
colour = 'white', # make polygon boundaries white | |
size = 0.3) + # adjust width of polygon boundaries | |
scale_fill_brewer(palette = "PuBu", # choose a http://colorbrewer2.org/ palette | |
name = "No qualifications (%)") + # add legend title | |
labs(x = NULL, y = NULL, |
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
ggplot() + | |
geom_sf(data = sf_gm_census, | |
aes(fill = percent_class), | |
alpha = 0.8, | |
colour = 'white', | |
size = 0.3) + | |
scale_fill_brewer(palette = "PuBu", | |
name = "No qualifications (%)") + | |
labs(x = NULL, y = NULL, | |
title = "Residents with no qualifications in Greater Manchester, 2011", |
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
ggplot(sf_gm_census, aes(fill = percent)) + | |
geom_sf(alpha = 0.8, colour = 'white', size = 0.3) + | |
scale_fill_viridis(discrete = F, | |
name = "No qualifications (%)", | |
direction = -1, | |
guide = guide_colourbar( | |
direction = "horizontal", | |
barheight = unit(2, units = "mm"), | |
barwidth = unit(50, units = "mm"), | |
draw.ulim = F, |
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
## Let’s make a map in R ## | |
# Setup --------------------------- | |
install.packages("sf", "tidyverse", "classInt", "viridis") | |
library(sf) ; library(tidyverse) ; library(classInt) ; library(viridis) | |
# Reading spatial data --------------------------- | |
sf_gb <- st_read("https://opendata.arcgis.com/datasets/07194e4507ae491488471c84b23a90f2_3.geojson", quiet = TRUE) | |
glimpse(sf_gb) | |
st_geometry(sf_gb) |
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
## Euclidean versus network distance ## | |
# load libraries and ggplot2 theme | |
library(tidyverse) ; library(sf) ; library(openrouteservice) ; library(geojsonio) ; library(ggplot2) ; library(ggspatial) ; library(ggrepel) | |
source("https://github.com/traffordDataLab/assets/raw/master/theme/ggplot2/theme_lab.R") | |
# set openrouteservice API key | |
ors_api_key("") | |
# provide coordinates (Denmark/Sweden border on Øresund Bridge) |
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
license: cc-by-4.0 | |
height: 400 | |
scrolling: no | |
border: yes |
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
license: cc-by-4.0 | |
height: 400 | |
scrolling: no | |
border: yes |