library(tidyverse)
library(spData)
library(sf)
library(rgeos)
library(sp)
Overview
This map of Greater London
with cycle hire and borough boundaries is created using data from TidyTuesday
2021 week 45 - {spData}
.
Resources:
- https://osdatahub.os.uk/downloads/open#CODEPO
- https://datatricks.co.uk/london-map-in-3-easy-steps
- https://data.police.uk/data/statistical-data/
::cycle_hire_osm
spData::lnd spData
<- data.frame(st_coordinates(cycle_hire_osm$geometry))
coord_lnd_cycl
<- as.data.frame(cycle_hire_osm)
cycle_hire_osm
$X <- coord_lnd_cycl$X
cycle_hire_osm$Y <- coord_lnd_cycl$Y cycle_hire_osm
cycle_hire_osm
::lnd spData
plot(lnd)
<- lnd
london_data
<- data.frame(london_data$GSS_CODE,london_data$HECTARES,london_data$geometry)
lnd_geo
names(lnd_geo)[1]<- "GSS_CODE"
<- data.frame(st_coordinates(lnd_geo$geometry))
coord_london
<- merge.data.frame(lnd_geo,coord_london) lnd_geo_coord
%>%count(L3) lnd_geo_coord
LONDON MAP!!!!!!
ggplot() +
geom_polygon(data=lnd_geo_coord,
aes(x = X, y = Y,group=L3, fill = L3),
colour = "black")+
labs(x = "Longitude", y = "Latitude",
title = "Map of Greater London with the borough boundaries")
cycle_hire_osm
library(extrafont)
library(showtext)
fonts()
loadfonts()
font.families.google()
font_add_google("Mr Dafoe", "MrDafoe")
showtext_opts(dpi = 320)
showtext_auto(enable = T)
<- lnd_geo_coord%>%filter(X>c(-0.3) & X<0.0,
lnd_center>51.4 & Y<51.6)
Y
%>%count(name)
cycle_hire_osm
<-ggplot()+
final geom_polygon(data=lnd_geo_coord,
aes(x = X, y = Y,group=L3, fill = L3),
colour = "black")+
geom_point(data=cycle_hire_osm, mapping=aes(x=X,y=Y),
color = 'gold', size=0.2, alpha=0.5)+
coord_map()+
scale_fill_gradient(low = "honeydew2",high = "darkgreen")+
labs(x = "Longitude", y = "Latitude",
title = "Map of Greater London with cycle hire",
subtitle = "with the borough boundaries",
caption = "Datasource: #TidyTuesday week45 - {spData} package \n Infographics: Federica Gazzelloni")+
::theme_map()+
cowplottheme(panel.grid.major = element_blank(),
axis.title.x=element_blank(),
axis.text.y=element_blank(),
plot.background = element_rect(color="midnightblue",fill="midnightblue"),
panel.background=element_rect(color="midnightblue",fill="midnightblue"),
plot.title=element_text(color="honeydew2",size=33,family="Arial"),
plot.subtitle=element_text(color="honeydew2",size=24,family="Arial"),
plot.caption = element_text(family="Arial",color="honeydew2"),
legend.position = "none")
Save final plot
::agg_png("~/Documents/R/R_general_resources/30DayMapChallenge/day7_green/green.png",
raggres = 320, width = 11, height = 8, units = "in")
finaldev.off()