/
atom.xml
347 lines (269 loc) · 30.9 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[DataSulis]]></title>
<link href="http://datasulis.github.com/atom.xml" rel="self"/>
<link href="http://datasulis.github.com/"/>
<updated>2012-03-29T18:35:26+01:00</updated>
<id>http://datasulis.github.com/</id>
<author>
<name><![CDATA[Leigh Dodds]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[How you can help. Yes, You!]]></title>
<link href="http://datasulis.github.com/blog/2012/03/29/how-you-can-help-yes/"/>
<updated>2012-03-29T16:32:00+01:00</updated>
<id>http://datasulis.github.com/blog/2012/03/29/how-you-can-help-yes</id>
<content type="html"><![CDATA[<p>After I posted a link to this project on Twitter last night, there was some really encouraging feedback from the local community. Looks like there’s some interest in a Bath based hackday and cider. Mainly cider in fact, but that’s all good :)</p>
<p>One question I got asked is: how do we move this forward? I thought I’d post some ideas about next steps, as well as some suggestions for how people can get involved.</p>
<!-- More -->
<p>First of all though lets consider why we might want to collate some local data. There are a number of good reasons. The primary reason is to have free, Open Data that can be used to create some useful applications. Those app can be useful not just for local people, but also for the thousands of tourists that visit the city each year.</p>
<p>Those applications could be built by local startups and provide a way for them to earn a few quid. The apps could also help local businesses increase their revenues, by driving attracting more customers. If we’re provided with better data from the local council, or central government, we can all be better engaged and help it deliver better services to us.</p>
<p>Open Data is pure win.</p>
<p>With these kinds of uses in mind, what kinds of data might we want to collect:</p>
<ul>
<li>Government data – There’s a whole range of potentially useful, interesting statistics published by central government, or by the likes of the <a href="http://www.dh.gov.uk/en/Publicationsandstatistics/Statistics/Performancedataandstatistics/">NHS</a>, that could be re-purposed for local use</li>
<li>Local Government data – Planning applications, health & safety inspections, etc.</li>
<li>Business listings – How about a free, locally maintained database of local businesses, with contact details, up to date information on opening-closing times, twitter accounts, blogs, and calenders?</li>
<li>Travel information – Bus and train times. Cycle paths</li>
<li>News – Searchable indexes of news sourced both locally as well as from national newspapers, e.g. the Guardian</li>
<li>Reviews – local restaurant, business, and event reviews</li>
<li>Jobs – local job adverts</li>
<li>Social Network – <a href="http://welovebath.co.uk">WeLoveBath</a> is becoming the focal point of Bath’s social network. Who is in it and how do they connect up? What about Facebook, Foursquare, etc?</li>
<li>Media – <a href="http://www.flickr.com/groups/bath/">Flickr</a> and <a href="http://www.geograph.org.uk">Geograph</a> are full of pictures of Bath. Wouldn’t it be nice to have a dataset of Creative Commons licensed photos for use in local applications? Maybe to power a new kind of tourist guide? What about sound and video? Music?</li>
<li>Events – There’s a lot going on in Bath for a relatively small city. I’d love to see a central database and calendar of events across the city, not just in the Theatre, or Komedia, but all of the pub nights, reading groups and other local events.</li>
</ul>
<p>…and there’s a whole lot more. Cultural heritage, local walking routes, weather, etc. I’ve even had crazy ideas about mapping out all the species of trees in the Arboretum in Victoria Bath. Maybe a school project?!</p>
<p>So how can you (yes, you!) get involved?</p>
<ul>
<li>Are you a geek? Yes? Then why not:
<ul>
<li>Share some code showing how to query, collect or scrape some data together for other developers to build on? A lot of data is out there already, we just need to make it easier to find and access</li>
<li>Use some of the data showcased here to create an useful application or visualisation?</li>
<li>Help build an application or service to help crowd-source some data?</li>
</ul>
</li>
<li>Are you a non-geek (aka Normal Person)? Then how about:
<ul>
<li>Sharing some thoughts on what kinds of local application or service you’d like to see?</li>
<li>Curating some data using a Google Spreadsheet? No coding required, but the data is still easy to share with others</li>
</ul>
</li>
<li>Are you a local business or firm? Then how about:
<ul>
<li>Getting in touch to see how you could help share some of you data for others to use?</li>
</ul>
</li>
</ul>
<p>I’ll happily point to whatever people hack, build, or share from this blog, just send in pointers. I’ll try and showcase as much as possible whilst continuing to add more content and collated data myself.</p>
<p>I’m keen to take a lo-fi approach and just do the simplest things necessary to help collect some data and make it easily accessible to whoever needs it. There are lots of useful free tools available. For example <a href="http://www.google.com/google-d-s/forms/">Google Spreadsheet Forms</a> are a quick and dirty way to crowdsource some basic information.</p>
<p>To really get things going I suggest we first try and collate some more data, and then maybe have a local hackday to try build something on what we’ve collected. And/or have a focused hacking session to collect together even more data. Or both.</p>
<p>Oh, and the cider. Don’t forget the cider.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[House Price Data from the Land Registry]]></title>
<link href="http://datasulis.github.com/blog/2012/03/28/house-price-data-from-the-land-registry/"/>
<updated>2012-03-28T20:15:00+01:00</updated>
<id>http://datasulis.github.com/blog/2012/03/28/house-price-data-from-the-land-registry</id>
<content type="html"><![CDATA[<p>Like the Ordnance Survey, the Land Registry have recently started to <a href="http://www1.landregistry.gov.uk/market-trend-data/public-data">publish some Open Data</a>. That data includes statistics on transactions made against the Land Registry database as well as “price paid” data.</p>
<p>As <a href="http://www1.landregistry.gov.uk/market-trend-data/price-paid-data">the Land Registry website explains</a>, this data relates to:</p>
<blockquote><p>residential property sales in England and Wales that are lodged with us for registration. The data includes:</p>
<ul>
<li>the full address of the property (Primary addressable object name (PAON), Secondary addressable object name (SAON), street, postcode, locality (if available), town, district, county)</li>
<li>the price paid for the property</li>
<li>the date of transfer</li>
<li>the property type (Detached, Semi, Terraced, Flat/Maisonette)</li>
<li>whether the property is new build or not</li>
<li>whether the property is freehold or leasehold.</li>
</ul>
</blockquote>
<p>We can filter their data to grab just the Bath prices.</p>
<!-- More -->
<p>There is a simple script in <a href="https://github.com/datasulis/bath-house-prices">this github project</a> which looks at the Land Registry website and grabs whatever CSV files are available. The CSV files are then read and filtered to just grab the data that relates to properties in the BA1 and BA2 area.</p>
<p>Currently the Land Registry are publishing this data on a monthly basis, so there is only a single month available currently. I expect that more data will appear over time. Here’s <a href="https://github.com/datasulis/bath-house-prices/blob/master/data/bath-house-prices.csv">how it looks today</a>.</p>
<p>For more background on the codes used in the data then <a href="http://www1.landregistry.gov.uk/market-trend-data/faqs#m18">read the Land Registry FAQ</a>.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[The NHS in Bath]]></title>
<link href="http://datasulis.github.com/blog/2012/03/28/the-nhs-in-bath/"/>
<updated>2012-03-28T19:20:00+01:00</updated>
<id>http://datasulis.github.com/blog/2012/03/28/the-nhs-in-bath</id>
<content type="html"><![CDATA[<p>The <a href="http://www.connectingforhealth.nhs.uk/systemsandservices/data/ods">NHS Organisation Data Service</a> has a responsibility to help various parts of the NHS, and affiliated organisations, exchange information as efficiently as possible. Part of that activity involves maintaining a database of organisations relevant to the NHS. That includes everything from NHS Primary Care Trusts through to individual Pharmacies.</p>
<p>Their data is published under the Open Government License so can be freely reused. Lets take a look at what it contains and how we can grab a local extract.</p>
<!-- More -->
<p>If you visit the <a href="http://www.connectingforhealth.nhs.uk/systemsandservices/data/ods">ODS Website</a> you can see that they publish a large number of CSV files that contain data about organisations and their relationships. The structure of the CSV files is well-documented and the files are well-normalised so they’re easy to process.</p>
<p>Some of the data is <a href="http://www.connectingforhealth.nhs.uk/systemsandservices/data/ods/datafiles">updated on a weekly basis</a>. This is the core NHS organisational data. Other data, such as that <a href="http://www.connectingforhealth.nhs.uk/systemsandservices/data/ods/genmedpracs">listing GPs and Branch Surgeries</a> is updated less frequently.</p>
<p>The data is useful for two reasons:</p>
<ul>
<li>If you want to draw maps showing, e.g. location of pharmacies then there’s well normalised address data that can be geocoded.</li>
<li>If you want to link up government statistics with individual medical practices or service providers, then you’ll need the unique identifiers</li>
</ul>
<p>I’ve previously taken all of the ODS data and <a href="http://kasabi.com/dataset/nhs-organization">loaded it into Kasabi</a>. Kasabi is my day job: its a data marketplace for hosting and publish data. If you want to query the data online then you could use any of the range of APIs available from there. Sign-up is free.</p>
<p>For the purposes of the DataSulis project we’re only really interested in the data about the NHS in Bath, i.e. BA1 and BA2. I wrote <a href="https://github.com/datasulis/bath-nhs">some Ruby scripts</a> to download the latest ODS files and then extract those organisations that have the relevant postcodes. The filtered CSV files are then cached locally. You could use them as the basis for further processing.</p>
<p>To illustrate the output I’ve put <a href="https://github.com/datasulis/bath-nhs/tree/master/data">a snapshot of the data into github too</a>. For example here’s a CSV file containing a list of the <a href="https://github.com/datasulis/bath-nhs/blob/master/data/nhs-ods-egdpprac.csv">Dental Practices in Bath</a></p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Bath Postcodes]]></title>
<link href="http://datasulis.github.com/blog/2012/03/27/bath-postcodes/"/>
<updated>2012-03-27T14:06:00+01:00</updated>
<id>http://datasulis.github.com/blog/2012/03/27/bath-postcodes</id>
<content type="html"><![CDATA[<p>If we’re going to be working with local data then it makes sense to have a list of local postcodes. There’s all kinds of data that can be usefully linked or combined based on postcode information. For example you could aggregate statistics on crime rates or house prices. Happily the Ordnance Survey now publish some useful Open Data about UK postcodes.</p>
<p>So lets look at how we can work with their data to query it and extract it for local use.</p>
<!--More-->
<p>Here’s a quick primer on postcodes. Postcodes have a structure to them. Each of the different parts of a postcode refer to a different area and those areas have a hierarchical relationship. Here are some examples along with the name that the Ordnance Survey (OS) uses to describe them:</p>
<ul>
<li><a href="http://data.ordnancesurvey.co.uk/id/postcodearea/BA">BA</a> = Post Code Area</li>
<li><a href="http://data.ordnancesurvey.co.uk/id/postcodedistrict/BA2">BA2</a> = Post Code District</li>
<li><a href="http://data.ordnancesurvey.co.uk/id/postcodesector/BA23">BA2 3</a> = Post Code Sector</li>
<li><a href="http://data.ordnancesurvey.co.uk/id/postcodeunit/BA23PL">BA2 3PL</a> = Post Code Unit</li>
</ul>
<p>So “BA2 3PL” is within a sector called “BA2 3”, and so on. The OS publish their data in various ways, including as <a href="http://en.wikipedia.org/Linked_Data">Linked Data</a>. Without going into details, Linked Data is just a way to publish data to the web by giving everything a unique URL.</p>
<p>So based on a postcode or part of a postcode you can build a URL to the OS website and use it to grab some data. For example here’s <a href="http://data.ordnancesurvey.co.uk/doc/postcodeunit/BA23PL.json">a JSON description of BA23PL</a>. That means that you can quickly lookup some useful data such as the lat/long which is the centre of a post code, or to discover in which electoral ward it lies. More on those alternate geographic regions in another post.</p>
<p>Sometimes though you just want a to grab some data for local processing. Having a list of local postcodes can help drive some address matching or other data processing task. So how can we get a complete list of local postcodes?</p>
<p>The OS allow you to <a href="http://www.ordnancesurvey.co.uk/oswebsite/products/os-opendata.html">download data from their site</a>, so you could grab all of the postcode dataset and process it to extract what you need. But there’s a simpler way. The OS also provide an API called a “SPARQL Endpoint” for their data. SPARQL is a query language for working with RDF, its basically a way to query a graph of Linked Data to extract the bits you need.</p>
<p>Here’s a SPARQL query that will fetch data about all of the Post Code Units that are within the BA1 or BA2 Post Code Districts:</p>
<div><script src='https://gist.github.com/2220182.js?file='></script>
<noscript><pre><code>PREFIX po: <http://data.ordnancesurvey.co.uk/ontology/postcode/>
PREFIX spatial: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?id ?code ?latitude ?longitude WHERE {
{
?id a po:PostcodeUnit;
spatial:within <http://data.ordnancesurvey.co.uk/id/postcodedistrict/BA1>;
geo:lat ?latitude;
geo:long ?longitude;
skos:notation ?code.
}
UNION
{
?id a po:PostcodeUnit;
spatial:within <http://data.ordnancesurvey.co.uk/id/postcodedistrict/BA2>;
geo:lat ?latitude;
geo:long ?longitude;
skos:notation ?code.
}
}</code></pre></noscript></div>
<p>If we submit that query to the <a href="http://api.talis.com/stores/ordnance-survey/services/sparql">OS SPARQL Endpoint</a> then extract just the data we need.</p>
<p>Here’s some simple Ruby code that does exactly that. It requests that the SPARQL API return the data as JSON and then spits it out as a simple CSV file.</p>
<figure class='code'><figcaption><span>Postcodes to CSV </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="nb">require</span> <span class="s1">'rubygems'</span>
</span><span class='line'><span class="nb">require</span> <span class="s1">'json'</span>
</span><span class='line'><span class="nb">require</span> <span class="s1">'net/http'</span>
</span><span class='line'><span class="nb">require</span> <span class="s1">'cgi'</span>
</span><span class='line'><span class="nb">require</span> <span class="s1">'csv'</span>
</span><span class='line'>
</span><span class='line'><span class="n">dir</span> <span class="o">=</span> <span class="no">File</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="bp">__FILE__</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'><span class="n">query</span> <span class="o">=</span> <span class="no">File</span><span class="o">.</span><span class="n">read</span><span class="p">(</span> <span class="no">File</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dir</span><span class="p">,</span> <span class="s2">".."</span><span class="p">,</span> <span class="s2">"rq"</span><span class="p">,</span> <span class="s2">"list-bath-postcode-units.rq"</span><span class="p">)</span> <span class="p">)</span>
</span><span class='line'>
</span><span class='line'><span class="no">Net</span><span class="o">::</span><span class="no">HTTP</span><span class="o">.</span><span class="n">start</span><span class="p">(</span><span class="s1">'api.talis.com'</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">http</span><span class="o">|</span>
</span><span class='line'> <span class="n">req</span> <span class="o">=</span> <span class="no">Net</span><span class="o">::</span><span class="no">HTTP</span><span class="o">::</span><span class="no">Get</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s2">"/stores/ordnance-survey/services/sparql?output=json&query=</span><span class="si">#{</span><span class="no">CGI</span><span class="o">.</span><span class="n">escape</span><span class="p">(</span><span class="n">query</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
</span><span class='line'> <span class="n">response</span> <span class="o">=</span> <span class="n">http</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="n">req</span><span class="p">)</span>
</span><span class='line'> <span class="n">postcodes</span> <span class="o">=</span> <span class="no">JSON</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span> <span class="n">response</span><span class="o">.</span><span class="n">body</span> <span class="p">)</span>
</span><span class='line'> <span class="no">CSV</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> <span class="no">File</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dir</span><span class="p">,</span> <span class="s2">".."</span><span class="p">,</span> <span class="s2">"data"</span><span class="p">,</span> <span class="s2">"bath-postcodes.csv"</span><span class="p">),</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">csv</span><span class="o">|</span>
</span><span class='line'> <span class="n">postcodes</span><span class="o">[</span><span class="s2">"results"</span><span class="o">][</span><span class="s2">"bindings"</span><span class="o">].</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">postcode</span><span class="o">|</span>
</span><span class='line'> <span class="n">csv</span> <span class="o"><<</span> <span class="o">[</span> <span class="n">postcode</span><span class="o">[</span><span class="s2">"id"</span><span class="o">][</span><span class="s2">"value"</span><span class="o">]</span><span class="p">,</span> <span class="n">postcode</span><span class="o">[</span><span class="s2">"code"</span><span class="o">][</span><span class="s2">"value"</span><span class="o">]</span><span class="p">,</span> <span class="n">postcode</span><span class="o">[</span><span class="s2">"latitude"</span><span class="o">][</span><span class="s2">"value"</span><span class="o">]</span><span class="p">,</span> <span class="n">postcode</span><span class="o">[</span><span class="s2">"longitude"</span><span class="o">][</span><span class="s2">"value"</span><span class="o">]</span> <span class="o">]</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>Here’s another version that generates a JSON description instead.</p>
<figure class='code'><figcaption><span>Postcodes to JSON </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="nb">require</span> <span class="s1">'rubygems'</span>
</span><span class='line'><span class="nb">require</span> <span class="s1">'json'</span>
</span><span class='line'><span class="nb">require</span> <span class="s1">'net/http'</span>
</span><span class='line'><span class="nb">require</span> <span class="s1">'cgi'</span>
</span><span class='line'>
</span><span class='line'><span class="n">dir</span> <span class="o">=</span> <span class="no">File</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="bp">__FILE__</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'><span class="n">query</span> <span class="o">=</span> <span class="no">File</span><span class="o">.</span><span class="n">read</span><span class="p">(</span> <span class="no">File</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dir</span><span class="p">,</span> <span class="s2">".."</span><span class="p">,</span> <span class="s2">"rq"</span><span class="p">,</span> <span class="s2">"list-bath-postcode-units.rq"</span><span class="p">)</span> <span class="p">)</span>
</span><span class='line'>
</span><span class='line'><span class="no">Net</span><span class="o">::</span><span class="no">HTTP</span><span class="o">.</span><span class="n">start</span><span class="p">(</span><span class="s1">'api.talis.com'</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">http</span><span class="o">|</span>
</span><span class='line'> <span class="n">req</span> <span class="o">=</span> <span class="no">Net</span><span class="o">::</span><span class="no">HTTP</span><span class="o">::</span><span class="no">Get</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="s2">"/stores/ordnance-survey/services/sparql?output=json&query=</span><span class="si">#{</span><span class="no">CGI</span><span class="o">.</span><span class="n">escape</span><span class="p">(</span><span class="n">query</span><span class="p">)</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
</span><span class='line'> <span class="n">response</span> <span class="o">=</span> <span class="n">http</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="n">req</span><span class="p">)</span>
</span><span class='line'> <span class="n">postcodes</span> <span class="o">=</span> <span class="no">JSON</span><span class="o">.</span><span class="n">parse</span><span class="p">(</span> <span class="n">response</span><span class="o">.</span><span class="n">body</span> <span class="p">)</span>
</span><span class='line'> <span class="n">output</span> <span class="o">=</span> <span class="p">{</span>
</span><span class='line'> <span class="s2">"postcodes"</span> <span class="o">=></span> <span class="p">{}</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="n">postcodes</span><span class="o">[</span><span class="s2">"results"</span><span class="o">][</span><span class="s2">"bindings"</span><span class="o">].</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">postcode</span><span class="o">|</span>
</span><span class='line'> <span class="n">output</span><span class="o">[</span><span class="s2">"postcodes"</span><span class="o">][</span> <span class="o">[</span> <span class="n">postcode</span><span class="o">[</span><span class="s2">"code"</span><span class="o">][</span><span class="s2">"value"</span><span class="o">]</span> <span class="o">]</span> <span class="o">]</span> <span class="o">=</span> <span class="p">{</span>
</span><span class='line'> <span class="s2">"id"</span> <span class="o">=></span> <span class="n">postcode</span><span class="o">[</span><span class="s2">"id"</span><span class="o">][</span><span class="s2">"value"</span><span class="o">]</span><span class="p">,</span>
</span><span class='line'> <span class="s2">"latitude"</span> <span class="o">=></span> <span class="n">postcode</span><span class="o">[</span><span class="s2">"latitude"</span><span class="o">][</span><span class="s2">"value"</span><span class="o">]</span><span class="p">,</span>
</span><span class='line'> <span class="s2">"longitude"</span> <span class="o">=></span> <span class="n">postcode</span><span class="o">[</span><span class="s2">"longitude"</span><span class="o">][</span><span class="s2">"value"</span><span class="o">]</span>
</span><span class='line'> <span class="p">}</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'> <span class="no">File</span><span class="o">.</span><span class="n">open</span><span class="p">(</span> <span class="no">File</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dir</span><span class="p">,</span> <span class="s2">".."</span><span class="p">,</span> <span class="s2">"data"</span><span class="p">,</span> <span class="s2">"bath-postcodes.json"</span><span class="p">),</span> <span class="s2">"w"</span><span class="p">)</span> <span class="k">do</span> <span class="o">|</span><span class="n">file</span><span class="o">|</span>
</span><span class='line'> <span class="n">file</span><span class="o">.</span><span class="n">puts</span> <span class="no">JSON</span><span class="o">.</span><span class="n">pretty_generate</span><span class="p">(</span><span class="n">output</span><span class="p">)</span>
</span><span class='line'> <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>
<p>And here are the generated files as both <a href="https://github.com/datasulis/bath-postcodes/raw/master/data/bath-postcodes.csv">CSV</a> and <a href="https://github.com/datasulis/bath-postcodes/raw/master/data/bath-postcodes.json">JSON</a>. Those files are provided to save you re-generating them yourself but you shouldn’t assume they’re always going to be up to date.</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[Hello Bath Hackers]]></title>
<link href="http://datasulis.github.com/blog/2012/03/27/hello-bath-hackers/"/>
<updated>2012-03-27T13:44:00+01:00</updated>
<id>http://datasulis.github.com/blog/2012/03/27/hello-bath-hackers</id>
<content type="html"><![CDATA[<p>First post!</p>
<p>This site is an experiment in creating a collection of useful pointers, blog posts, datasets and maybe even APIs for local hackers in Bath. As I’ve explained a little in the <a href="http://datasulis.org/about">about</a> page I’m interested in exploring how a more local, city level view of Open Data could help support some interesting innovative hacking amongst the local geek community.</p>
<p>As the recent [Bath Digital Festival] has shown Bath has developed a really amazing local tech community. [WeLoveBath] also shows that Bath has a great community of engaged citizens. But I’ve not seen any efforts to start curating local datasets that can help both of those communities do interesting, innovative things in our local area.</p>
<p>This site sets out to see if we can remedy that. Basically, I’ve spent a lot of time over the last few years doing data modelling and munging and I decided its time to use those skills for good :)</p>
<p>I expect this will be something of a journey and I’m hoping that some of you out there will want to join in and help out. I’m hoping that if its successful then maybe we can run a BathCamp or hackday dedicated to local data projects.</p>
<p>It doesn’t matter if your a geek or not I’m hoping that we can explore lots of ways to curate and collect local data. I’m as interested in running some local crowd-sourcing experiments as I am in wrangling data from various APIs.</p>
<p>The project is intended to be open from top to bottom, so all of the content, source code and data should be up for re-use.</p>
<p>Lets see what we can make.</p>
]]></content>
</entry>
</feed>