Home

Awesome

<img src="/src/icon.png" height="30px"> Australian Electorate information

Build status NuGet Status NuGet Status NuGet Status NuGet Status NuGet Status

All information about electorates is available at /Data/electorates.json.

See Milestones for release notes.

Electorates

Location: /Data/electorates.json

Sample:

<!-- snippet: Snippets.ElectoratesSampleJson.verified.txt -->

<a id='snippet-Snippets.ElectoratesSampleJson.verified.txt'></a>

[
  {
    "Name": "Bean",
    "ShortName": "bean",
    "State": "ACT",
    "Area": 1913.0,
    "Exist2019": true,
    "Exist2022": true,
    "Exist2025": true,
    "DateGazetted": "2018-07-13",
    "Description": "<p>The Division of Bean covers an area in the south of the ACT consisting of the Districts of:</p><ul><li>Booth,</li><li>Coree,</li><li>Cotter River,</li><li>Mount Clear,</li><li>Paddys River,</li><li>Rendezvous Creek,</li><li>Stromlo,</li><li>Tennent,</li><li>Tuggeranong,</li><li>part of Jerrabomberra,</li><li>part of Molonglo Valley,</li><li>part of Weston Creek, and</li><li>part of Woden Valley</li></ul><p>The Division of Bean also includes Norfolk Island.</p>",
    "DemographicRating": "<strong>Inner Metropolitan</strong> – situated in capital cities and consisting of well-established built-up suburbs",
    "NameDerivation": "Named after Charles Edwin Woodrow Bean, 1879–1968, Australia's official correspondent to the Australian Imperial Force in World War One, editor of the <em>Official History of Australia in the War of 1914–1918</em> and primary advocate to establish the Australian War Memorial.",
    "Enrollment": 109432,
    "TwoCandidatePreferred": {
      "Elected": {
        "FamilyName": "Smith",
        "GivenNames": "David",
        "PartyCode": "ALP",
        "Votes": 61935,
        "Swing": 5.43,
        "PartyId": 200
      },
      "Other": {
        "FamilyName": "Hiatt",
        "GivenNames": "Jane",
        "PartyCode": "LP",
        "Votes": 36459,
        "Swing": -5.43,
        "PartyId": 177
      }
    },
    "Locations": [
      {
        "Postcode": 2906,
        "Localities": [
          "Banks",
          "Conder",
          "Gordon"
        ]
      },
      {
        "Postcode": 2600,
        "Localities": [
          "Hmas Harman"
        ]
      },
      {
        "Postcode": 2617,
        "Localities": [

<sup><a href='/src/Tests/Snippets.ElectoratesSampleJson.verified.txt#L1-L50' title='Snippet source file'>snippet source</a> | <a href='#snippet-Snippets.ElectoratesSampleJson.verified.txt' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Localities

Location: /Data/Localities.json

Sample:

<!-- snippet: Snippets.LocalitiesSampleJson.verified.txt -->

<a id='snippet-Snippets.LocalitiesSampleJson.verified.txt'></a>

[
  {
    "Place": "Acton",
    "Postcode": 2601,
    "Electorate": "CANBERRA"
  },
  {
    "Place": "Canberra Central",
    "Postcode": 2601,
    "Electorate": "CANBERRA"
  },
  {
    "Place": "Canberra City",
    "Postcode": 2601,
    "Electorate": "CANBERRA"
  },
  {
    "Place": "Ainslie",
    "Postcode": 2602,
    "Electorate": "CANBERRA"
  },

<sup><a href='/src/Tests/Snippets.LocalitiesSampleJson.verified.txt#L1-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-Snippets.LocalitiesSampleJson.verified.txt' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Parties

Location: /Data/parties.json

Sample:

<!-- snippet: Snippets.PartiesSampleJson.verified.txt -->

<a id='snippet-Snippets.PartiesSampleJson.verified.txt'></a>

[
  {
    "Id": 1339,
    "Name": "Animal Justice Party",
    "Code": "AJP",
    "Abbreviation": "AJP",
    "RegisterDate": "3 May 2011",
    "AmendmentDate": "3 May 2011",
    "Address": "Ground Floor\n470 St Kilda Rd\nMELBOURNE VIC 3004",
    "Officer": {
      "Title": "Dr",
      "FamilyName": "Cheung",
      "GivenNames": "William",
      "Capacity": "Party Agent",
      "Address": {
        "Line1": "Ground Floor",
        "Line2": "470 St Kilda Road",
        "Suburb": "Melbourne",
        "State": "VIC",
        "Postcode": 3004
      }
    },
    "DeputyOfficers": [
      {
        "Title": "Ms",
        "FamilyName": "Sutton",
        "GivenNames": "Alicia",
        "Capacity": "Deputy Registered Officer",
        "Address": {
          "Line1": "24 Malvolio Road",
          "Suburb": "Coolbellup",
          "State": "WA",
          "Postcode": 6163
        }

<sup><a href='/src/Tests/Snippets.PartiesSampleJson.verified.txt#L1-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-Snippets.PartiesSampleJson.verified.txt' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Detail Maps

AEC publishes pdf electorate maps with some extra detail. eg:

The size of these pdfs is significant. The smaller file variants are approx 600MB in total.

To change these to a more manageable size and format, they have been converted to png and are now approx 30MB in total. Located in /Data/DetailMaps.

There are 3 variants of these files:

GeoJson Maps

Maps in geojson format.

The following grouping of maps exist:

Structure

Each of the above groupings have the following structure.

Map variants

Each maps has multiple variants based on simplification.

With the two options combined, there are 5 different options for each map.

Below is the combinations for Bass

SizeFile nameSimplification
2.8MBbass.geojsonnone
231KBbass_20.geojson20%
94KBbass_10.geojson10%
46KBbass_05.geojson5%
8KBbass_01.geojson1%

Simplification

Simplification uses MapShaper simplify option

Visvalingam simplification iteratively removes the least important point from a polyline. The importance of points is measured using a metric based on the geometry of the triangle formed by each non-endpoint vertex and the two neighboring vertices

The level of simplification is represented as a percent number. 20, 10, 5, and 1. representing 20%, 10%, 5%, and 1%. The smaller the number the smaller the file, but with the loss of some accuracy.

NuGets

The NuGets contain a static copy of the electorate data. This data is embedded as resources inside the assembly. No network calls are done.

To get the latests version of the data do a NuGet update. There are several options to help keep a NuGet update:

Usage

<!-- snippet: usage -->

<a id='snippet-usage'></a>

// get an electorate by name
var fenner = DataLoader.Fenner;
Debug.WriteLine(fenner.Description);

// get an electorate by string
var canberra = DataLoader.Electorates.Single(_ => _.Name == "Canberra");
Debug.WriteLine(canberra.Description);

// get an electorates maps (geojson) by string
var fennerGeoJson2019 = DataLoader.Fenner.Get2019Map();
Debug.WriteLine(fennerGeoJson2019);
var fennerGeoJson2022 = DataLoader.Fenner.Get2022Map();
Debug.WriteLine(fennerGeoJson2022);
var fennerGeoJson2025 = DataLoader.Fenner.Get2025Map();
Debug.WriteLine(fennerGeoJson2025);

// get an electorates maps (geojson) by string
var canberraGeoJson2019 = DataLoader.Maps2019.GetElectorate("Canberra");
Debug.WriteLine(canberraGeoJson2019);
var canberraGeoJson2022 = DataLoader.Maps2022.GetElectorate("Canberra");
Debug.WriteLine(canberraGeoJson2022);
var canberraGeoJson2025 = DataLoader.Maps2022.GetElectorate("Canberra");
Debug.WriteLine(canberraGeoJson2025);

// export all data to a directory
// structure will be
// /electorates.json
// /2019 (2019 states and australia geojson files)
// /2019/Electorates (2019 electorate geojson files)
// /2022 (202 states and australia geojson files)
// /2022/Electorates (2022 electorate geojson files)
var directory = Path.Combine(Environment.CurrentDirectory, "Maps");
Directory.CreateDirectory(directory);
return DataLoader.Export(directory);

<sup><a href='/src/Tests/Snippets.cs#L11-L48' title='Snippet source file'>snippet source</a> | <a href='#snippet-usage' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Bogus Usage

<!-- snippet: usagebogus -->

<a id='snippet-usagebogus'></a>

var faker = new Faker<Target>()
    .RuleFor(
        property: u => u.RandomElectorate,
        setter: (f, _) => f
            .AustralianElectorates()
            .Electorate())
    .RuleFor(
        property: u => u.RandomElectorateName,
        setter: (f, _) => f
            .AustralianElectorates()
            .Name());
var targetInstance = faker.Generate();

<sup><a href='/src/Tests/Snippets.cs#L82-L97' title='Snippet source file'>snippet source</a> | <a href='#snippet-usagebogus' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

DetailMaps Usage

<!-- snippet: usageDetailMaps -->

<a id='snippet-usageDetailMaps'></a>

var pathToPng = DetailMaps.MapForElectorate("Bass");

<sup><a href='/src/Tests/Snippets.cs#L54-L58' title='Snippet source file'>snippet source</a> | <a href='#snippet-usageDetailMaps' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Copyright

Code

The code in this repository is licensed under MIT.

Copyright © 2018 Commonwealth of Australia (Department of the Prime Minister and Cabinet)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Content/Data

The content/data that is rendered (all files under /Data/) is sourced from the Australian Electoral Commission (AEC) and remains under the AEC Copyright.

The content/data in this repository does not necessarily represent the latest data made available by the AEC. The Department of the Prime Minister and Cabinet gives no warranty regarding the accuracy, completeness, currency or suitability of the content/data for any particular purpose.

This product (AustralianElectorates) incorporates data that is:
© Commonwealth of Australia (Australian Electoral Commission) 2018

The Data (Commonwealth Electoral Boundaries (various years)) has been used in AustralianElectorates with the permission of the Australian Electoral Commission. The Australian Electoral Commission has not evaluated the Data as altered and incorporated within AustralianElectorates, and therefore gives no warranty regarding its accuracy, completeness, currency or suitability for any particular purpose.

Limited End-user licence provided by the Australian Electoral Commission:

You may use AustralianElectorates to load, display, print and reproduce views obtained from the Data, retaining this notice, for your personal use, or use within your organisation only.

Re-Generating the data

Note: The below are only required by the maintainers and contributors of this project. They are not required when consuming the NuGet package.

Some tools are required.

Adding new elections

Elections are currently added manually as they are declared.

<!-- snippet: elections -->

<a id='snippet-elections'></a>

[
    new()
    {
        Parliament = 46,
        Year = 2019,
        Date = new(2019, 05, 18),
        Electorates = Electorates
            .Where(_ => _.Exist2019)
            .ToList()
    },
    new()
    {
        Parliament = 47,
        Year = 2022,
        Date = new(2022, 05, 21),
        Electorates = Electorates
            .Where(_ => _.Exist2022)
            .ToList()
    }
];

<sup><a href='/src/AustralianElectorates/DataLoader.cs#L72-L94' title='Snippet source file'>snippet source</a> | <a href='#snippet-elections' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

ogr2ogr

Part of Geospatial Data Abstraction Library (GDAL)

Ensure in path

MapShaper

MapShaper

Installation:

https://github.com/mbloch/mapshaper/wiki/Command-Reference

GhostScript

C:\Program Files\gs\gs9.27\bin\

pngquant

https://pngquant.org/

Purge history

git checkout --orphan newBranch
# Add all files and commit them
git add -A
git commit -m "Initial commit"
# Delete the master branch
git branch -D master
# Rename the current branch to master
git branch -m master
# Force push master branch to github
git push -f origin master
# remove the old files
git gc --aggressive --prune=all

Notes

Media feed ftp://mediafeed.aec.gov.au/24310/Standard/Verbose/

Verbose Feed: Contains up-to-date election results and information. The feed contains static data, such as candidate names, and dynamic data such as votes. The verbose feed also contains calculated results like swings and aggregated results to the state and national level. This feed is suitable for users who have their own IT system and who may or may not have pre-loaded data and is also suitable for those users who do not have an IT system and simply wish to transform the XMLfile into another format.

From: https://www.aec.gov.au/media/mediafeed/files/media-feed-user-guide-v4.pdf

Icon

Icon designed by Iconathon from The Noun Project.