Mark Lawson and his son Sam tried a novel way to visualise air quality in Bath.
The Air Quality Hack was originally just for me, a Saturday afternoon in Bath and an interesting problem. One evening the previous week, I was playing around with ideas, but not getting anywhere when my teenage son Sam asked me what I was doing. Now, he’d not shown a shred of interest in IT ever, but I explained the problem, the data I had and that I was looking for some fun way to visualise it. Half an hour later, he’d come up with the idea of a tree, he’d booked himself onto the hack, and we were a team. Well, he was there to make sure I stayed true to his “vision”, I was there to code.
Sam’s idea was simple but powerful, a map of Bath, with a tree ‘sort of’ covering it. The leaves of the tree would respond to two variables, a) NO2 and b) Particulates. The tree covered the area where the sensors were so a section of leaves could respond to each sensor.
The code was done using Processing, which is an excellent tool for visualisations and simple enough so I could explain the code to him. The background came courtesy of Open Streetmaps, the tree was drawn and I used an array of 250 Leaf objects to populate the tree, which was drawn with a tint() to make it slightly transparent.
I was originally going to use live data, but the collection period was too slow to see it in action. So I used the historical data, averaged it up into days and used that instead. Our resulting sketch simply loaded the data and ran through it assigning different colours depending on the range to leaves that were a given vector distance from the sensor. The sketch ran at 30fps, reading new data every tenth frame. Sam was pretty happy with the result and it’s always good if the client is satisfied. He even let me have a break for lunch.
Sadly, we couldn’t finish the sketch, but it looked promising. Given more time, I’d have altered the way the leaves changed to get a smoother transition. Also some of the colours in used by the Environment Agency really didn’t make a good leaf. On the way back Sam suggested that flowers might be better as you could ‘grow’ one at each sensor and a given set of petals could all be the same colour. That’s probably my next assignment.
All in all, it was a good day, and I’m hoping Sam sees code in a slightly better light, now it’s been used to turn an idea of his into reality.
- Map courtesy of OpenStreetMap
- Tree from http://www.dreamstime.com
- Code is on GitHub https://github.com/
- Made using Processing http://processing.
- Mark Lawson
- Sam Lawson