Cities need good data. I helped Breandán MacGabhann set up the software for his air quality monitors around the city (you can check the readings out on Twitter – mine is on the Dock Road). Councillor Brian Leddin recently asked at a council meeting how many traffic counters were around the city – the answer was only three. We’ve a transport strategy coming up, a controversial incinerator planned for the outskirts of the city: wouldn’t it be great if we had more data to back up our decisions?
I’ve been thinking about this for a while but I lack the time to put it together – I wanted to write it down in case someone else was inspired to put something similar together.
Enter the Smart Bird Box
I’ve been following various attempts to measure air quality and traffic using the Raspberry Pi hobbyist computer. I think with recent advances in machine learning and solar power that it’d be possible to deploy a network of smart sensing devices that could measure traffic flow and air quality at various points around the city. The cost would be a fraction what commercial sensors currently cost. The data that they produce could be open to the public.
I think a bird box would be perfect for this. They are cheaply available and designed to be weatherproof. And they would also be handy for birds to nest in!
A system would need to run without power. Solar panels on the roof of the bird box coupled with a battery pack would allow the system to run without mains power. The PiJuice project supplies panels and batteries that would be suitable for this.
Air quality sensors
Breandán has sourced relatively cheap sensors for temperature, humidity and particulate matter (). A NOx sensor could also be added.
Using a raspberry pi camera, machine learning could be used to detect how many cars, trucks, bicycles and pedestrians are passing. This article describes such an approach. Traffic counts could be recorded every five minutes. It’d make a great introductory machine learning project if someone was interested in messing around with TensorFlow.
The system could incorporate a GSM modem to upload the data it records every hour to a server. Or if there was a nearby wifi network with a friendly owner, our bird box could connect to that. A server script could dump the data into a database, and offer a way to request data for different time ranges. The system doesn’t need to be complicated.
Not forgetting the birds!
A second infrared camera could be added to record images of any nesting birds who chose to make our nesting boxes their home.
The bird box would be recording images but would not be storing them, the machine learning would be on the device and in real time. Source code could/should be open sourced and auditable.
I’m describing a complete, standalone, remotely monitorable system. But really the way to start would be to find a place where power and wifi could be delivered with a view onto a busy street. My balcony overlooks the Dock Road in Limerick and I’d be happy to open it up to hackers.
Here’s a rough estimate of the hardware cost per box.
Bird box: €5
Power management: €60 for controller, €30 for battery, €90 for solar panels
The preliminary Census 2016 results were released today. Exciting times for data nerds like me!
The CSO published changes showing population changes since the last census, showing that the population had grown everywhere in the country apart from small decreases in Mayo, Sligo and Donegal of -0.2%, -0.1% and -1.5% respectively. I thought it would be more interesting to look at population changes over two census periods, i.e. 2006-2016.
The table below shows population change in each area between 2006 and 2016. Limerick City was the only area to show a decrease, with the population changing by -2.5% compared to a national increase of 12.2%.
Table and CSV file link below. Note that the Limerick City boundaries correspond to the historical (pre-local authority merger) boundaries of the city, but includes the addition of the Limerick North Rural electoral division.
If you’re in a hurry, the answer is Liscannor, Co. Clare. 5 pubs for 129 people, or 1 pub for every 26 people. And on the other extreme, the town in Ireland with the fewest pubs is Greystones, with 4 pubs for 11,194 people, or 1 pub for every 2799 people.
The wonderful infographic was made by my friend Gimena who is an extremely talented interface designer – check out her portfolio.
There’s a lovely cycleway called the Great Southern Trail in County Limerick, and we cycled the western end of it a few weeks ago, ending in Abbeyfeale, a small town on the Limerick/Kerry border. Growing up down the road in Adare, I remember people claiming that Abbeyfeale had the most pubs per head in Ireland. Walking round in search of a pint to reward my cycling efforts I wondered, was this true? Barstool talk was all we had in the nineties, but surely someone had done a bit of a study since. A half an hour of web searching later, all I could come up with was a few forum posts essentially containing the same barstool talk as I’d come across before.
Cycling back I had a bit of time to think about this. I knew the Central Statistics Office (CSO) had the population of each town, but how to get a list of pubs? I had been looking for an excuse to fool around with a bit of Python, and this seemed like the perfect chance to write a small web scraper to get the data. There is a Vintner’s Association of pubs which had a membership list, and the Golden Pages (our equivalent of the Yellow Pages) had a pretty comprehensive list of businesses with a landline (every business with a landline gets a free listing).
I was all ready to write my little scraper when my friend Emmet pointed out that because running a pub is a licenced business, there was probably a public list, and there was, on the Revenue Commissioner’s site. It was even available as an Excel file, with the address lines in separate columns! My excitement quickly waned as I waded through the horrible morass that is Irish addresses. My original idea was to get the data into a database so I could do some fun analysis – now I was definitely stuck in Excel as this job was 95% cleaning data. Fortunately I managed to harangue Emmet into helping me with some Excel tips and tricks.
I was reminded why we have the most amazing national statistics office here in Ireland. Not only because they are unfailingly helpful whenever I have had cause to contact them over the years (not wanting to indulge in waste of taxpayer’s money I decided not to contact them asking for help with this particular project). But mostly because we in Ireland are an absolute mess when it comes to addresses. How the CSO manage to count anything in this country is a mystery. Not only until this year we were one of the only rich countries not to have a postcode system, but consider the following points when I was cleaning up the pub data:
Irish is our first official language, so every address has two completely separate legal forms, both of which are equally valid.
Either the Irish or the English name is picked as the ‘official name’, but this has little to do with what is used in reality.
Dingle is officially (and slightly controversially) ‘An Daingean’ because it is part of the Irish-speaking Gaeltacht. Yet all 38 pubs use ‘Dingle’ as their address. Maryborough is listed as the English language equivalent of Portlaoise (not in an Irish speaking area), yet all 34 pubs use the Irish form
Many places cannot even agree with themselves how they are spelt. There are 9 pubs in Louisburgh, Mayo, yet 4 spell it ‘Louisbourgh’ and one other spells it ‘Louisburg’
3 pubs in Co. Limerick are in ‘Dromcollogher, 2 are in ‘Drumcollogher’, yet some of the signs on the way in to town say ‘Dromcolliher’
Pubs in Roosky put their address down as Roosky, Carrick-on-Shannon, Co. Roscommon. No matter that Carrick-on-Shannon is in Co. Leitrim, that’s where their local post office is. But I was getting a few pubs in Carrick-on-Shannon, Co. Leitrim and a few in Carrick-on-Shannon, Co. Roscommon, and they all had to be cleaned up. This is surprisingly common.
Sometimes locals completely ignore the official spelling for their town, for example Pallas Grean in Co. Limerick vs. Pallasgreen.
Many of our towns have boundaries defined in Victorian times. For consistency, these populations are listed separately. So there are rows upon rows of separate population entries for ‘Loughrea Legal Town’ and ‘Loughrea Environs’
We don’t even have a good definition for what a town is. The CSO have their own definition, which must be a huge amount of work for them: a census town “is defined as being a cluster with a minimum of 50 occupied dwellings, with a maximum distance between any dwelling and the building closest to it of 100 metres, and where there was evidence of an urban centre (shop, school etc)”
After a large amount of address-wrangling, I got my data cleaned up somewhat. I discarded all the local authority subdivisions of Dublin to just cater for one county of Dublin. Out of 7,745 licenced pubs and hotels in Ireland, I managed to match up all but 990 of them to a census town, and many of these would not have a match anyway (e.g. if their address was listed as a suburb of a bigger town, like Mahon in Cork, or if they were in a settlement too small to be considered a census town)
The raw data gave the top 10 as follows:
Number of pubs
Number of people per pub
Yet it was ultimately Liscannor, and not Feakle, that I judged the winner of my ‘most pubs per capita’ award. The answer again comes down to post office locations: in rural Ireland the second-last line of your address is normally your local post office. So even though 7 pubs had Feakle as their address, at least 3 were a long way outside Feakle in another village. But second on my list was Liscannor: even though 2 of its 7 pubs were a small way outside near St. Bridget’s Well on the way to the Cliffs of Moher, 5 hostelries (4 pubs and 1 hotel) were definitely within the small village of 129 people, giving an incredible ratio of 1 pub for every 26 people.
I gave up at this point, satisfied that I had my winner. But I was a bit sorry I didn’t get the data cleaned up a bit more – in particular 3rd place Lifford with an incredible 55 pubs for under 1700 people sounded fascinating – but my lack of knowledge about Donegal local geography prevented me from cleaning the data much further (I suspect some of these 55 pubs were in villages outside of Lifford).
I’ve provided the cleaned data files for both towns by population and pubs by address in case anyone else wants to have a go. The two files can be joined in a spreadsheet with a simple COUNTIF statement or similar. I’m not sure about the copyright status of either file, the pubs file is based on publicly available data about commercial businesses, and equally the CSO data is publicly available, but I’m not sure under what licence. Any changes I have made to the original data you may use in the spirit of finding a good place to go boozing.