Download a list of football stadiums and their coordinates from Chris Bell’s ‘doogal.co.uk’ website.
url <- "https://www.doogal.co.uk/FootballStadiumsCSV.ashx"
download.file(url,destfile = "stadiums.csv")
Map the locations of football stadiums in England, Scotland and Wales, along with the name of the team that plays there, and the stadium capacity. Click on a marker to identify the data.
# load libraries
library(leaflet)
library(dplyr)
# read the csv file and select just the required data
stads <- read.csv("stadiums.csv",stringsAsFactors = FALSE)
stads <- select(stads,Name,Team,Capacity,Latitude,Longitude)
# Use leaflet to plot the locations
stads %>%
leaflet() %>%
addTiles() %>%
addMarkers(popup = paste("Team: ",stads$Team,"<br>",
"Stadium: ",stads$Name,"<br>",
"Capacity: ",format(stads$Capacity,big.mark = ","))
,clusterOptions=markerClusterOptions())