Day Five

22nd June 2021

Sydney - Blacktown

The SA4 of Blacktown in Sydney, is made up of 19 smaller SA2 areas

Log

I need to out the accessible visualisation aside for a day or so and work on creating maps! I've been working on some maps for a client, and I need to get a bit of a template going, so that's what I am working on today

Steps I took are:

  1. Downladed files from ABS here
  2. I downloaded some files relating to SA2s for Australia, so download what you want, but make sure you have a *.shp and a *.dbf file.
  3. I used the "Command Line Cartography" series by Mike Bostock to understand what to download, and modified it based on some info from Stack Overflow. Make sure you have shp2json installed. Run:
    npm install -g shapefile
  4. Create a geoJson file using
    shp2json SA2_2016_AUST.shp -o SA2.json
  5. This file was huge - about 170mb so not very practical
  6. Then converted to topojson, which is what I really wanted to crack today - I played around last week with this, got the file nice and small, but I couldn;t draw the paths in D3...
  7. Run: geo2topo SA2.json > SA2_topo.json
  8. This reduces file down to 122mb - still too big
  9. Next ran: toposimplify -p 1 SA2_topo.json > SA2_simple.json
  10. This reduces to a very tiny 2mb! I'm not sure if I went too far, but this loads WAY faster than using the original geojson files that I was playng around with a few weeks ago.
  11. This simply was way too small originally and while it was a super-smalll file, it knocked out a ot of detail - which became apparent when I was working on the next day's stuff, so i re-wored it, and had a little more of a look at toposimplfy - I also had an error, so the version to use is:
    toposimplify -P .25 SA2_topo.json > SA2_simple.json
    Note the capital P instead of p, plus messing around with the value after can vary the size of the file. In future I can mess about with this - depending on the size and bounding box

The main thing I didn't do when I tried this last week, is that once you convert your file to a topoJson, you need to convert it back into a geoJson! AND you also need to include a reference to topojson in your scripts:

  1. SA2_topo = topojson.feature(SA2_map, SA2_map.objects.tracts)

  2. src="https://unpkg.com/topojson@3"

I also did some snazzy filtering. I'm only interested in looking at one particular SA4s so I filtered out the rest:
SA2_map.objects.tracts.geometries = SA2_map.objects.tracts.geometries.filter(d => d.properties.SA4_NAME16 == "Sydney - Blacktown")

Tomorrow - highlighting / filling in one statistical area, and adding labels to the other ones.