Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Plot NSW AEC data on leaflet map
# 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)
@fauxvalue

This comment has been minimized.

Copy link
Owner Author

@fauxvalue fauxvalue commented Jun 30, 2019

fixed a little big

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment