Task
As part of Module 9 Creating Data Products for the Coursera Data Science Specialisation the following task was required to complete week 2: Create the web page feature an interactive map created with Leaflet.
Methodology
- Using the skillset obtained in Module 3 Getting and Cleaning Data data was obtained of the Twitter followers of the Agri-Food and Biosciences Institute account using the Twitter API.
- The location of users was obtained using the Google API based on the script from the blog https://www.r-bloggers.com/using-google-maps-api-and-r/.
- The Leaflet package was used to plot the points in an interactive map of the world using the addMarkers(…,clusterOptions = markerClusterOptions()) piece of code.
- A html file using R Markdown and published to RPubs.
Interactive_Map <- AFBI_TWITTER[,c("lat","lon")] %>%
leaflet() %>%
addTiles() %>%
addMarkers(clusterOptions = markerClusterOptions())
Discussion
- No quality assurance of the Google API was carried out and the location details are reliant of the accuracy of the individual twitter users.
- An example of an erroneous output from the Google API is from a Twitter user from a long time ago in a galaxy far, far away who lists their location as “Cloud City” - the gas mining colony where Lando Calrissian betrays Han Solo. The Google API returns a location of an ice-cream factory in Portland, USA.
- Many users list their location as generic places (e.g. Ireland). This leads to large aggregations of users in locations that may be a large distance from their real location. Depend on the spatial resolution required this may not be accurate. for other purposes.
- 381 of the AFBI Twitter followers did not include a location on the Twitter bio and therefore cannot be plotted on the map.
Disclaimer
The views and outputs of are that of the author.