In this article i'll describe how I coded a map of all the postoffices in australia. Really this technique could be used to map anything you want, such as the location of all sales made in the last month, or the location of all your offices/stores/franchises/whatever.
Download the code / executable here
In a previous article
I wrote about how to get the latitude and longitude of all the postcodes in australia into a CSV file called 'PostcodeLatLng.csv', with the contents something like this:
Next up you'll need a map of australia. I took some screenshots of google maps and pasted them together using Paint.net. After that, i converted it to black and white and darkened it a bit, so that the 'blobs' would stand out better. Here's my resultant 'map.jpg':
Then you'll need some way of mapping longitude and latitude to pixel x,y on the map. To do this, i got the x,y coordinates of each of the capitals and wrote it in a 'map.txt' file, along with their postcode:
So now you've got enough information to convert a postcode into an X,Y location on the given map. The general idea is to convert the postcode into a longitude/latitude; then find the X/Y of the nearest 2 capital cities, and interpolate the long/lat values to create X/Y values.
Finally, you'll need an input file with a list of postcodes of interest that you wish to plot, and the colour you wish to plot them. I'm using the following format for this in a file named 'PlotData.csv' (Postcode, Hex-RGB):
The full source code is available below. This code also contains a plotting function that generates a heatmap rather than points for each selected postcode. Note that in this article, i've supplied the map as a JPG for the sake of my bandwidth, whereas the code expects a PNG, which you can create using Paint.Net or photoshop.