openaustralia / aec_electorate_postcodes

Australian Electoral Commission Postcode Data


AEC electorate postcodes

Which federal electorate(s) each Australian locality and postcode is in, scraped from the Australian Electoral Commission's locality search.

It replaces drzax/morph-division-postcode-correspondence as the source for parse-postcodes.rb in openaustralia-parser, which loads the postcode lookup used by OpenAustralia.org.au and They Vote for You. See openaustralia/openaustralia#1060.

Data

The data table has one row for each locality and electorate. A locality split between electorates has a row for each of them.

| Column | Example | Notes | |---|---|---| | state | NSW | | | locality | CAMMERAY | | | postcode | 2062 | | | other_localities | ST LEONARDS | Blank for most localities | | electorate | Bradfield | | | electorate_type | current | redistributed for the electorate a locality moves to at the next federal election, after a redistribution |

Each run replaces all the data, so abolished electorates don't linger. The run stops without saving if the data looks incomplete, for example when an electorate has no localities, keeping the previous run's data.

To get the postcode to electorate mapping that parse-postcodes.rb expects:

sql SELECT DISTINCT postcode, electorate FROM data WHERE electorate_type = 'current' ORDER BY postcode, electorate

Running

bundle config set --local path vendor/bundle bundle install bundle exec ruby scraper.rb

A full run makes about 1,000 requests to electorate.aec.gov.au, one at a time, and takes about 5 minutes. Set MORPH_AUSTRALIAN_PROXY to send them through the Australian proxy.

Testing

bundle exec rake bundle exec rubocop

The specs use the saved AEC pages in spec/fixtures/ and don't contact any site.

This is a scraper that runs on morph.io. To get started see the documentation.

Contributors benrfairless

Last run completed successfully .

Console output of last run

Injecting configuration and compiling... Injecting scraper and running... Running ruby 3.2.2 Found 151 electorates Adelaide: 166 records Aston: 31 records Ballarat: 232 records Banks: 37 records Barker: 971 records Barton: 40 records Bass: 376 records Bean: 141 records Bendigo: 191 records Bennelong: 44 records Berowra: 64 records Blair: 165 records Blaxland: 34 records Bonner: 43 records Boothby: 162 records Bowman: 24 records Braddon: 394 records Bradfield: 38 records Brand: 30 records Brisbane: 57 records Bruce: 32 records Bullwinkel: 126 records Burt: 27 records Calare: 402 records Calwell: 23 records Canberra: 117 records Canning: 66 records Capricornia: 197 records Casey: 91 records Chifley: 40 records Chisholm: 48 records Clark: 249 records Cook: 35 records Cooper: 36 records Corangamite: 40 records Corio: 57 records Cowan: 28 records Cowper: 183 records Cunningham: 58 records Curtin: 31 records Dawson: 182 records Deakin: 42 records Dickson: 52 records Dobell: 73 records Dunkley: 19 records Durack: 535 records Eden-Monaro: 348 records Fadden: 35 records Fairfax: 67 records Farrer: 256 records Fenner: 81 records Fisher: 75 records Flinders: 47 records Flynn: 426 records Forde: 56 records Forrest: 130 records Fowler: 34 records Franklin: 371 records Fraser: 26 records Fremantle: 34 records Gellibrand: 22 records Gilmore: 193 records Gippsland: 288 records Goldstein: 30 records Gorton: 35 records Grayndler: 35 records Greenway: 32 records Grey: 1591 records Griffith: 32 records Groom: 164 records Hasluck: 47 records Hawke: 76 records Herbert: 81 records Hindmarsh: 134 records Hinkler: 102 records Holt: 26 records Hotham: 54 records Hughes: 47 records Hume: 64 records Hunter: 178 records Indi: 324 records Isaacs: 42 records Jagajaga: 33 records Kennedy: 415 records Kingsford Smith: 43 records Kingston: 76 records Kooyong: 35 records La Trobe: 59 records Lalor: 18 records Leichhardt: 166 records Lilley: 35 records Lindsay: 38 records Lingiari: 1540 records Longman: 55 records Lyne: 332 records Lyons: 681 records Macarthur: 44 records Mackellar: 51 records Macnamara: 25 records Macquarie: 108 records Makin: 103 records Mallee: 598 records Maranoa: 564 records Maribyrnong: 35 records Mayo: 511 records McEwen: 81 records McMahon: 45 records McPherson: 26 records Melbourne: 20 records Menzies: 37 records Mitchell: 19 records Monash: 230 records Moncrieff: 35 records Moore: 26 records Moreton: 33 records New England: 422 records Newcastle: 58 records Nicholls: 218 records O'Connor: 544 records O'Donoghue: 1590 records Oxley: 39 records Page: 442 records Parkes: 376 records Parramatta: 44 records Paterson: 86 records Pearce: 31 records Perth: 36 records Petrie: 26 records Rankin: 29 records Reid: 39 records Richmond: 167 records Riverina: 411 records Robertson: 80 records Ryan: 49 records Scullin: 23 records Shortland: 67 records Solomon: 86 records Spence: 139 records Sturt: 148 records Swan: 30 records Sydney: 53 records Tangney: 28 records Wannon: 461 records Warringah: 43 records Watson: 30 records Wentworth: 43 records Werriwa: 36 records Whitlam: 97 records Wide Bay: 222 records Wills: 30 records Wright: 262 records Finished - saved 20609 records from 1020 requests

Data

Downloaded 5 times by benrfairless

To download data sign in with GitHub

Download table (as CSV) Download SQLite database (1.85 MB) Use the API

rows 10 / 20609

state locality postcode other_localities electorate electorate_type
SA
ADELAIDE
5000
Adelaide
current
SA
ADELAIDE
5000
Adelaide
redistributed
SA
ALLENBY GARDENS
5009
Adelaide
current
SA
ALLENBY GARDENS
5009
Adelaide
redistributed
SA
ANGLE PARK
5010
Adelaide
current
SA
ANGLE PARK
5010
Adelaide
redistributed
SA
ASHFORD
5035
Adelaide
current
SA
ASHFORD
5035
Adelaide
redistributed
SA
BLAIR ATHOL
5084
Adelaide
current
SA
BLAIR ATHOL
5084
Adelaide
redistributed

Statistics

Average successful run time: 10 minutes

Total run time: 20 minutes

Total cpu time used: half a minute

Total disk space used: 2.08 MB

History

  • Auto ran revision 285c971f and completed successfully .
    nothing changed in the database
  • Manually ran revision 3a542d0b and completed successfully .
    20609 records added in the database
  • Created on morph.io