Last active
June 30, 2019 01:55
-
-
Save fauxvalue/d362e0183614f649cf5acf0642445f2a to your computer and use it in GitHub Desktop.
Plot NSW AEC data on leaflet map
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
# how to draw a map -- and some geospatial points -- using R | |
require(data.table) | |
require(leaflet) | |
# get the data | |
pollingPlaces <- as.data.table(read.csv("https://tallyroom.aec.gov.au/Downloads/GeneralPollingPlacesDownload-24310.csv", skip = 1)) | |
nswReps <- as.data.table(read.csv("https://tallyroom.aec.gov.au/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-24310-NSW.csv", skip = 1)) | |
# inner join to add lat and longtitude data | |
nswReps[pollingPlaces[, list(PollingPlaceID, Latitude, Longitude)], | |
`:=` (lat = i.Latitude, long = i.Longitude), | |
on = 'PollingPlaceID'] | |
# part 1: out first map | |
# create a simple map -- show all pollling places in NSW | |
nswVotingPlaces <- leaflet(nswReps) %>% | |
addTiles() %>% | |
addCircleMarkers(lat = ~lat, lng = ~long, popup = ~DivisionNm, | |
col = 'red', stroke = FALSE, fillOpacity = 0.01) | |
print(nswVotingPlaces) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fixed a little big