Power BI: Creating a TopoJSON file of Australian postcodes for use with Shape Map

In a recent consulting project, I needed to plot analytic values over postcodes. I couldn't just do it with the built-in maps control, mostly because the system that we're developing on doesn't have Internet connectivity. I was keen to upload the mapping data directly into the report, and the Shape Map control (while still in preview) seemed to fit what I needed exactly.

However, when you load custom maps into the control, they need to be in TopoJSON format. Now TopoJSON is a specific extension over GeoJSON which has been pretty common for a while. I tried just using a GeoJSON file with the control, to no luck.

What was successful was to download the postcode shapes from here:

https://www.abs.gov.au/AUSSTATS/abs@.nsf/DetailsPage/1270.0.55.003July%202016?OpenDocument

I downloaded the 2011 shape file for Australian postcode areas.

Next I used theĀ  website at https://mapshaper.org/ to do the following:

  • Loaded the shape file
  • Simplified the shape file (I reduced it to about 2% of the original size, while opting to keep any small areas)
  • Export the data as a TopoJSON file
  • (Optional) I then edited the TopoJSON file to rename my postcode column from POA_CODE to Postcode and from POA_NAME to PostcodeName.

What an awesome site mapshaper.org is !

Notes on Shape Map

To use the shape map control, you need to do this:

  • Make sure you have the Shape Map control (it's currently a preview feature that needs to be enabled)
  • Drag the column containing the postcode to the Location field.
  • Once you've done that, on the format page, you can choose to add a custom map. I imported my TopoJSON postcodes file
  • Drag the analytic value to the Color saturation field.
  • Set the background color and border color.

When I first did this, nothing worked for me. Eventually I worked out that my source data had integer postcodes but the ones in the file were just text fields. I added a computed column to my data, made sure I had text postcodes available, and used that column, then all was good.

I hope this helps someone.

 

 

16 thoughts on “Power BI: Creating a TopoJSON file of Australian postcodes for use with Shape Map”

  1. Have been trying on and off for weeks to get this right, after your nice simple post I've now got it working a treat. I'm going to attempt this down to suburb level now. Thanks very much Greg.

  2. Hi, I am totally new to this. I've followed the instructions but when i hover over the postcodes on the map it says postcodes undefined. Any idea what I'm doing wrong?

    1. Hi Jess, hard to tell from that description, but I suppose I'd start by asking if the postcode shapes appeared in your shape visual?

  3. Thanks Greg, works perfectly.

    I have previously only used a shape file of LGA's, but a new project required this as Postcodes. I followed your steps exactly and it all worked. I started at a 3% reduction but it was a little slow in Power BI so went down to your suggested 2% and that seems to works quite well.

    Shane

  4. Hey Greg,

    Thanks, this worked perfectly. Reducing the shapefile to 2% and making sure the postcode data were stored as text – both really good tips. Legend!

  5. hi Greg,

    Thanks for your guidance.

    I'm not sure which postcode shapes file you downloaded from ABS, I tried 'Postal Areas ASGS Edition 2016 in .csv Format ' but map shaper couldn't simplify it. Can you please clarify?

    Thank you!
    Miles

    1. The 2011 file that I used back then is no longer there.

      What I'd guess I'd do today, if I had a problem with file size, is to use a shapefile importer to pull the shapes into a SQL Server instance, then use the SQL CLR Reduce() method to reduce the size of the polygrams myself, then push them back out. Then it should be small enough. That would be my first attempt.

      What was the error when you tried to import them into the mapshaper tool?

Leave a Reply

Your email address will not be published. Required fields are marked *