Global Challenges Research Fund: sector meeting 29 October 2019 #GCRF

The Global Challenges Research Fund (GCRF) ‘is a £1.5 billion fund announced by the UK Government in late 2015 to support cutting-edge research that addresses the challenges faced by developing countries’. Its delivery partners include the Scottish Funding Council (SFC). Earlier this year, I was commissioned by the SFC to produce a web-map of the GCRF projects it funds.

I was invited to present about the map at the SFC’s GCRF sector meeting at the sector meeting on 29 October.

Hence a major part of this post is to record what Isaid about the map. The other major part is slightly edited versions of my live-tweets from the meeting. The rest of the post is Bruce-thoughts tweeted at the time, in (round brackets), and Bruce-thoughts that occurred while writing this post, in [square brackets].

My work was very well received, so I am very happy to have boosted my reputation (and that of Edinburgh Napier University), with representatives of the other Scottish universities, and with a significant research-funder.

All photos and information reported below are © the presenters and their relevant colleagues. Click the images to see the full-size versions. Continue reading

Edinburgh Apps competition: 6 February

(adapted from an email from OK Scotland)

The annual EdinburghApps event returns on  6 February 2016.

The ethos behind EdinburghApps is to run a unique civic challenge event for the City of Edinburgh that allows teams and individuals the opportunity to work with the City of Edinburgh Council and partners to provide fresh ideas and solutions to help improve the lives of those living, working and visiting the city.

EdinburghApps also supports the Council’s Open Data strategy, and opens up new data as part of the event to support participants. Continue reading

Wise words and mega maps

Leah Lockhart, social media advisor and all-round good egg, has been blogging about fears and barriers in public services on LinkedIn. Here are her thoughts on fears people have about being abused online, fears around negotiating online identity, fears digital champions have about inertia generally but especially in hierarchical leadership and finally about fears around BYOD.

Thanks also to ‘Lelil’ for drawing me to Leah’s tale of how to use topical hashtags to draw extra traffic to community council Tweets.

Well worth a read for any CC member (or any other elected member or public servant) involved in digital engagement with their citizens, in my opinion.

Continue reading

2014_04_06

So what’s happened over the last month?

Community council location finder project

The final community council location finder code has been submitted to the client. There were a few days delay waiting for up-to-date data to arrive at the client.

I look forward to the site going live. Meanwhile, here are screenshots of the final version:

Current project

I’m doing the literature review for the resurvey of Community Council online presences. This will update the summer 2012 report. To create connections with European research, it’s likely that I will examine how open-ness and transparency are supported by these presences.

Presentations

Peter Cruickshank and I have

I took part in the commission’s panel discussion around digital democracy. Here is the original submission. (Thanks as ever to Peter for making my prose legible.) Here is video of the discussion.

Yesterday, I was a note-taker at From Centre to Community – reclaiming local democracy in Scotland. My personal aim was to learn from others at this event, and this was more than fulfilled. I also met ‘Paddy’ Bort, co-author of The Silent Crisis, and Adam Stewart, secretary to the commission, among many others. Most people I spoke to were very well informed and had a lot to contribute. Others came simply to learn.

Many good points were raised – not just pie-in-the-sky schemes. I’m not optimistic that local democracy will be perfected in my lifetime. In fact, I am certain that nothing in this world can ever be perfect. But I am very optimistic that we can start to improve matters, right here, right now.

 

2014_03_11: it’s progress Jim, but not as we know it

So I spent most of yesterday trying to find what causes my work to crash Safari under iOS7: turns out it’s the gizmo that clusters the CC markers. Not going to cure that in a hurry!

Then I tried for several hours to add the info features from leaflet’s chloropleth/geoJSON example to my script. I got the LAs to highlight on mouseover, but not to de-highlight on mouseout. Nor could I get the data control to pick out data from the LA geoJSON file.

So I reasoned ‘if I can’t add their stuff to mine, can I add my stuff to theirs?’ That is, could I swap in my LA and CC data sets and use leaflet’s code to colour them and pick out data to be displayed in their external control? This seemed to go OK until I added in the geocoder (the bit for entering an address to zoom to that area of the map. This code failed, so everything that should have been processed after it wasn’t even reached.

I went back to trying to add leaflet’s functions to my otherwise functional code. Still no joy.

I refactored my code so it was in a more logical order:

  1. preparatory functions,
  2. drawing basic map
  3. adding scale, geocoder, reset and help controls to map
  4. adding LA data layer
  5. adding CC data layer
  6. adding layers on/off control

and made the reset control call a URL from a simple configuration file, so that when the client actually puts this work online, they only need to update the configuration file, not hack around in the reset script.

I still couldn’t get the mouseout bit to work. I knew this code was being called: if I replaced it with document.write(“rude word”); then rude words were written.

So this evening I revisited leaflet’s example, determined to get it to work. This example has all the functionality built into a script in the html file, not a separate ‘external’ script. Not really the way I want but I’m running out of time…

I realised that the geocoder was being called but just failing somewhere. I’m not sure how I worked it out but the fail point was that geocoder calls a function in my main external script to limit its searches to Scotland – the same bounds as are applied to my map. (Without this search-area limiting, searching for EH10 postcodes shows Walthamstow.) But this script is never invoked, so the function isn’t callable. So instead of calling that function, I’ve copied it into the geocoder. Now that works! And so do all the other bits. I can make the reset script call the configuration file, so long as they are in the right order in the html header (i.e. configuration before the reset function that depends on it – so perhaps the issue was that the geocoder was calling the main script before it was available.

There was another wrinkle adding in the CC marker code. Something doesn’t like a variable called location. Changing that to ccLocation worked.

So here is the whole lot working – but with the javascript embedded in the HTML.

My task for tomorrow is to get the javascript into a separate file, so that this works, cos right now it doesn’t. Then write some documentation, then write a talk for the OKFN meet-up tomorrow.

2014_03_10

Added reset button

It’s another hack down of the OSMGeocoder control, mostly because I don’t have time to understand how to create a control from scratch. The main fault with it is that it relies on

inner.innerHTML = “<a href=\”http://localhost:8888/realISV22\”><img src = \”css/images/reset.png\”></a>”;

The bold bit will need to be replaced with the real URL for wherever the site will be used.

2014_03_04 progress re LA colours, calculating LA extrema and switching off unwanted polygons for markerClusterGroups

We’re into March! After meeting with the client, a few changes are needed.

Colouration

Working from the chloropleth example, I’ve chosen 5 colours (cyan = #0080ff, red = #ff0000′, yellow = #ffff00, blue = #0000ff’ and green = #00ff00). This choice was inspired by Education Scotland’s map.)

In the geoJSON file, each feature (i.e. each LA) has an extra line in the ‘properties’ piece: “colour_code”:3 //BMR 2014_02_21.

The code to decide colours is
function getLAcolour(d) {
  return d == 1  ? ‘#0080ff’:
            d == 2  ? ‘#ff0000’:
           d == 3  ? ‘#ffff00’:
           d == 4  ? ‘#0000ff’:
           ‘#00ff00’;
} // end getLAcolour()

Then there’s a function to create a style object:
function laStyle(feature) {
    return {
        fillColor: getLAcolour(feature.properties.colour_code),
       weight: 2,
       opacity: 1,
       color: ‘white’,
       dashArray: ‘3’,
       fillOpacity: 0.7,
       fillOpacity: 0.4
   };
} //end laStyle(feature)

Then the geoJSON function does the heavy lifting:
L.geoJson(laBoundaryData, {style: laStyle}).addTo(laLayerGroup);

So the whole effect looks like this:Screen Shot 2014-03-04 at 16.28.40It’s deliberately similar in look to this map of constituencies and MSP activities:Screen Shot 2014-03-04 at 16.29.32I’ve also moved the link to © data and acknowledgements to a second line in the acks piece at the bottom of the map, so far less screen area is taken up by non-map things. The instructions will go onto a pop-out pane access from a big ? on an edge of the map. Currently they clutter things:Screen Shot 2014-03-04 at 16.34.14

Calculating LA boundaries and extrema: how I did it

I do not claim this was the most efficient way! The following is an expanded write-up of a previous blog entry.

  1. Obtain up to date shape files from the Ordnance Survey (BoundaryLine is the relevant product.)
  2. Start a new project in QGIS.
  3. Do Layer > Add vector layer and select district_borough_unitary region.
  4. Make the layer editable.
  5. Select and cut out the non-Scottish features.
  6. Save the project as Scotland.
  7. Select each LA in turn, then do Vector > Geometry tools > Simplify geometries. The options I used were:Screen Shot 2014-03-04 at 17.07.58 but with a different file for each LA. For example, Shetland’s 160,883 vertices were reduced to 5416.
  8. Select the newly-created object, then do Layer > Save selection as vector file, with optionsScreen Shot 2014-03-04 at 17.09.30

So now I had 32 separate geoJSON files. To combine them, I used the process described here to make a single laBoundaryData.js file. That’s my geoJSON file on which the above styling magic works.

Finding LA extrema

In future versions of this map, I’ll want to zoom into individual LAs. The easy way to do this will be (I think) to find the furthest north, south, east, west points of each LA. So I adapted my code to find Scotland’s extrema to work on each LA:
function drawMap() {
    //BMR 2014_02_25
    //find extreme points
    var north = 0;
    var south = 90;
    var west = 90;
    var east = -90;
 
    for (var i = 0; i < coordinates.length; i++) {
        var laDatum = coordinates[i];
        // the other way round from the getScotlandBounds because geoJSON latlongs are in the opposite order to leaflet latlogns
        var longitude = laDatum[0];
        var latitude = laDatum[1];

        if (latitude > north) {
            north = latitude;
        //end if

        if (latitude < south) {
            south = latitude;
        //end if

        if (longitude < west) {
            west = longitude;
        //end if

        if (longitude > east) {
            east = longitude;
        //end if
    //end for

    document.write(“north = ” + north + “, south = ” + south + “, west = ” + west + “, east = ” + east);

}// end drawMap

It’s a complete hack but I copied, pasted and edited the results into my laData.js file to get line such as
    [“Angus”, “http://www.angus.gov.uk/commcouncil&#8221;, 
        56.986816427679120, 56.46164866362316, -3.407021822671358, -2.420365421269425],

If I’d been clever, I’d have made the script write the extrema data to the file. But this is a one-off and so it would have taken longer to write code to do it than to do it myself.

Switching off unwanted polygons for markerClusterGroups

Awe and respect to the leaflet programming folk. I feared I might need to dig into their actual code to switch off these unwanted polygons. But it’s as simple as adding an option object to the otherwise unoptioned code. That is, from this

L.markerClusterGroup();

to this

L.markerClusterGroup({showCoverageOnHover: false});

2014_02_21: even more LA boundary progress

So a good conversation with Napier’s visualisation expert and I’m now more aware of some of the ways to make my code more bombproof – too be implemented this weekend, if paper-writing and having a life allow.

Meanwhile I’ve completed colouring the LA boundaries. Here’s some pretty pictures:

Neither LAs nor CCs switched on

Neither LAs nor CCs switched on

CCs switched on

CCs switched on

LAs switched on

LAs switched on

both switched on

both switched on

I’m not too bothered that this uses 6 colours when there should be a four-colour solution. I’d be more picky about the actual colours used. Changing the colours is easy – just changing up to 6 values in a function in my main script. Changing which LAs each colour is applied to involves opening the huge geoJSON file full of LA data, then finding, say, East Ayrshire, then changing the value of colour_code immediately below it.

2014_02_21: more LA boundary progress

Manually copying and pasting 32 sets of bits of file is fraught with difficulty, as any fule kno.  So there had to be an easier way to assemble the individual LA geoJSON files into one javascript file. I did a lot of comparison of the brackets and guts of the working-so-far leaflet example and my geoJSON files. My file began with 

{
“type”: “FeatureCollection”,
“crs”: { “type”: “name”, “properties”: { “name”: “urn:ogc:def:crs:OGC:1.3:CRS84” } },
                                                                                

We only want one FeatureCollection, with 32 features for the 32 LA boundaries. So in a new laBoundaryData.js file, containing var laBoundaryData = { }; from the first LA file insert

      “type”: “FeatureCollection”,
      “crs”: {
            “type”: “name”,
            “properties”: {
                  “name”: “urn:ogc:def:crs:OGC:1.3:CRS84” } },
 
      “features”: [{
            “type”: “Feature”,
            “properties”: {
                  “NAME”: “Aberdeen City”,
                  “AREA_CODE”: “UTA”,
                  “DESCRIPTIO”: “Unitary Authority”,
                  “FILE_NAME”: “ABERDEEN_CITY”,
                  “NUMBER”: 7.0,
                  “NUMBER0”: 34.0,
                  “POLYGON_ID”: 122136.0,
                  “UNIT_ID”: 30421.0,
                  “CODE”: “S12000033”,
                  “HECTARES”: 20561.013,
                  “AREA”: 1990.394,
                  “TYPE_CODE”: “AA”,
                  “DESCRIPT0”: “CIVIL ADMINISTRATION AREA”,
                  “TYPE_COD0”: null,
                  “DESCRIPT1”: null,
                  “colour_code”:2         //BMR 2014_02_21
            },
            “geometry”: {
                  “type”: “MultiPolygon”,
                                    “coordinates”: [ [ [ [ -2.360870189456887, 57.10919031061777  ….]]]] } },

Note the comma. After it, paste { “type”: “Feature”, “properties”: ….]]]] } } from the next LA file, then add a comma. Then rinse and repeat.

Far from elegant but much easier than isolating wee bits from each file.