]> git.vanrenterghem.biz Git - www2.vanrenterghem.biz.git/blob - source/posts/spatial_indexes_to_plot_income_per_postal_code_in_Australian_cities.org
48bfde17d604a1ec7c3d5cff3c90fa785ff9ad21
[www2.vanrenterghem.biz.git] / source / posts / spatial_indexes_to_plot_income_per_postal_code_in_Australian_cities.org
1 #+date: 2017-11-16 15:07:59 +0800
2 #+filetags: R spatial analysis visualisation Australia git
3 #+title: Spatial indexes to plot income per postal code in Australian cities.
5 Trying to plot the income per capita in Australia on a map, I came
6 across a perfectly good reason to make good use of [[http://r-spatial.org/r/2017/06/22/spatial-index.html][a spatial query]] in R.
8 I had to combine a shapefile of Australian SA3's, a concept used under
9 the Australian Statistical Geography Standard meaning Statistical Area
10 Level 3, with a dataset of income per postal code. I created a matrix of
11 intersecting postal codes and SA3's, and obtained the desired income per
12 capita by SA3 performing a matrix multiplication. If the geographical
13 areas were perfectly alignable, using a function like =st_contains=
14 would have been preferred. Now I fell back on using =st_intersects=,
15 which results in possibly assigning a postal code to 2 different
16 statistical areas. Alternative approaches are welcome in the comments!
18 As Australia is so vast, and the majority of its people are earning a
19 living in a big city, a full map does not show the difference in income
20 per area at this level of detail. Instead, I opted to map some of the
21 key cities in a single image.
23 #+CAPTION: Income distribution in major AU cities
24 #+ATTR_HTML: :class img-fluid :alt Income distribution in major AU cities
25 [[file:../assets/AUCitiesIncomeDistribution.gif]]
27 The full code is available on my git server for you to clone using
28 =git clone git://git.vanrenterghem.biz/R/project-au-taxstats.git=.