QGIS Multi Ring Buffer Plugin Version 1

After about 3 years of existing. I am releasing version 1 of the Multi Ring Buffer Plugin.

QGIS plugin repository.

With version 1 comes a few new features:

  • Ability to choose the layer to buffer after launching the plugin
  • Ability to supply buffer distances as comma separated text string
  • Ability to make non-doughnut buffers
  • Doughnut buffer:

    Non-doughnut buffer (regular):

    Updating A Plugin From QGIS 2 to QGIS 3

    I have two plugins in the QGIS plugin repository, and with the release of QGIS 3 looming it was time to upgrade them for QGIS 3.

    There is a short guide by the QGIS dev team that is a good starting point at:

    But I had not done any development on these plugins for a while so a more step by step guide was useful, so hopefully, write the guide for the first plugin and follow it step by step for the second.

    I am working on Windows, with OSGeo4W.

    Before we start we will need to insure a couple of extras are installed through the OSGeo4w Installer:

    Assuming GitHUB is the repo.
    In git shell:

    There is a conversion script for QGIS plugins provided by the QGIS devs in the main repo.

    We can download just the scripts folder using the following link:

    Extract that into a location of your choice.

    Then we can run the 2to3 script from the OSGeo4W console (cd to the folder you extracted the script to):

    This will print out changes that need to be made to convert from QGIS2 to QGIS3.

    My first run resulted in many lines of:

    So my plugins line of:

    Was impossible to convert with the tool, since I was not 100% sure what I needed from the QtCore library (I was young when I wrote the plugin). I commented out the line for the plugin in QGIS 2.8, booted up QGIS 2.8 and tried running the plugin.

    So python errors:
    NameError: global name ‘QVariant’ is not defined
    NameError: global name ‘Qt’ is not defined
    Later. I ended up expanding my other import from QtCore to:

    Running the 2to3 script again looked ok, with a number of changes required. These changes can be applied with –w flag:

    For the next step I booted up my favourite IDE PyCharm. I created a bat file that launched PyCharm with the QGIS dev environmental variables. So copying the “python-qgis-dev.bat” file from:

    I changed the final line of:


    Then from File> Settings> Project:> Project Interpreter> Set to “C:OSGeo4W64appsPython36python.exe”

    It takes a while to update the interpreter.

    I only had 2 errors, both for:

    There is a list of API breaks between QGIS 2 and QGIS 3 at:

    Looks like QgsMapLayerRegistry was moved to QgsProject. So I edit it to:

    Then we can edit the metadata.txt to QGIS 3:

    And increase the version number.

    Then we need to recompile the icon and ui for Python3 and QT5.

    I was struggling a bit with the environmental variables to get it working, and ended up using a great batch script form StackExchange:

    So create the .bat file and run it in the folder of you plugin (editing where needed). Note: Your resources_rc may be called resource_rc or something slightly different.

    Move the plugin folder to:

    Boot up QGIS2.99/3.

    I had a few more issues.

    It seems QGIS 3 deals with the icon slightly differently.

    icon_rc.py is no longer needed, and it seems was not used on my other plugin either.

    So I removed the reference to it in the main python script:
    from . import icon_rc

    I still had some errors.

    AttributeError: module ‘qgis.PyQt.QtGui’ has no attribute ‘QDialog’

    It seems QDialog has moved to PyQt.QtWidgets.

    So in my multi_ring_buffer_dialog.py file I needed to change some lines:


    In the two instances in that file.

    Working plugin!

    Commit the changes back to the repo. Cd to the directory in git shell.

    Zip the plugin up.
    Upload to https://plugins.qgis.org/plugins/

    Second plugin:
    Same issue with import *
    1 error with QgsMapLayerRegistry
    My resources_rc file was called resource_rc so the batch script needed to be edited to:
    call pyrcc5 resources.qrc -o resource_rc.py
    Same issues with QtGui.QDialog

    Now time for some improvements.

    Finland 100 with 90 years of Finnish hockey

    Finland is 100 years old today.

    It has been a rich history. It is a young country, with myself being alive for almost a third of it.

    In honour of #Finland100. Here is 90 years of Finnish hockey champions:

    100 years of Finnish Hockey

    Starting with the 1927-1928 season with six teams the Finnish championship started with the SM-Sarja.
    “S” for Suomen meaning Finnish.
    “M” for Mestaruus meaning Championship
    “Sarja” meaning series

    The first year consisted of the following teams:
    Viipurin Reipas – Viipuri Swift
    HIFK – Sporting Society Comrades, Helsinki – Future 7 time champions
    HJK – Helsinki Football Club – Future 3 time champions
    KIF – Kruununhaka Sports Club (Helsinki) – Future 3 time champions
    Tapa – Tampere Ballers – Future champions
    HPS – Helsinki Ball Club

    With ice hockey still being a very new sport in 1927 the victory went to Viipurin Reipas, primarily a football and bandy club. Located in Viipuri, a city which was lost to Russia after the Winter War.

    At this stage ice hockey was purely an amateur sport, with sports clubs taking part in ice hockey as part of a larger program. Most often football in the summer and ice hockey in the winter, but also combined with other sports.

    After Viipuri the championship went to Helsinki, with their football club. While no longer active in ice hockey they are still active in the highest level of Finnish football.

    The Helsinki – Tampere fight for hockey championship was established early, with 1930-1930 seeing a standing of:
    Helsinki 1
    Tampere 1
    Viipuri 1

    The next few years also saw the Helsinki Figure Skating Club (HSK) win the championship, three times in total.

    1939 to 1945 were crucial years for Finnish history. The war with Russia was one for the survival of Finland as a whole.
    Some sacrifices had to be made.

    The 1939-1940 season was completely called of for the Winter War. During which the captain of Tampere Ilves (3 time champions at the time, and 16 time champions all time) Jussi Tiitola was killed, among others.

    The 1940–1941 season was played in between hostilities as an 8 team series.

    1941–1942 was cancelled for the Continuation War.

    1942–1943 was played as an 8 team series. With KIF winning their third championship in a row, discluding pauses for war.

    The 1943–1944 season was started but a mass bombing of the Helsinki Kaisaniemi stadium called the season short. It was agreed that if Tampere Ilves (who had 0 losses at the time) could beat Tarmo and KIF they would be awarded the championship. They beat Tarmo, but unfortunately the transport connections between Tampere and Helsinki were bombed the day before the Ilves – KIF match. Thus the championship was never awarded.

    The after war period saw a domination from the Tampere. With 18 championships in 24 years. With Ilves winning 11 and TBJ/Tappara winning 6 and KOO-VEE 1.

    But notably champions from other cities aside from Helsinki and Tampere emerged.

    Like TPS from Turku first champions in 1956, but future 11 time champions.

    Tarmo (no longer active) from Hämeenlinna winning two in a row.

    Lukko from Rauma winning their only championship so far in 1963, coming close in the future; with silver: 1961, 1966, 1988, and bronze: 1965, 1969, 1994, 1996, 2011, 2014.

    And Pori, with RU-38 in 1967, Porin Karhut in 1965, and together as Porin Ässät (Pori Aces) in 1971.

    While the SM-Series was mainly amateur it changed into the SM-Liiga in 1975, bringing with it a move to a professional sport.

    This also introduced the playoffs to determine the overall champions. Also a relegation system was introduced, with teams coming last in the SM-Liiga facing relegation to a lower division and giving lower teams and opportunity for promotion.

    The first championship outside of Southern Finland went to Oulu in 1981.

    1985 was the latest championship for Ilves, their 16th in total.

    Kärpät won again in 2004, and 2005 with back to back championships. With two more back to back championships to come.

    With JYP from Jyväskylä winning in 2008 the total of cities with victories comes to 9.

    The Ilves crown of 16 championships was met by Tappara (formerly TBK) in 2016, and beat in 2017 with back-to-back victories.

    Here’s to another 100 years and more of hockey in Finland.

    UK Postcode Breakdown RegEX

    UK postcodes are broken down/divided into 4 levels: Areas, Districts, Sectors, and Units.

    For G12 8QH the breakdown is:
    Area – G
    District – G12
    Sector – G12 8
    Unit – G12 8QH

    See my previous post:
    UK Postcode Format Breakdown/

    This is just a note of the RegEX strings to extract these, which can be used in QGIS, or PostgreSQL. These are a bit complex for most datasets, but should work independent on whether spaces and how many were used between the in and out codes. Should also work for London postcodes.

    Area: G
    RegEX: ^[a-zA-Z][a-zA-Z]?
    PostgreSQL: substring(postcode, '^[a-zA-Z][a-zA-Z]?')
    QGIS: regexp_substr("postcode" , '(^[a-zA-Z][a-zA-Z]?)')

    UK Postcode Area

    UK Postcode Area

    District: G12
    RegEX: ^[a-zA-Z]+\d\d?[a-zA-Z]?
    PostgreSQL: substring(postcode, '^[a-zA-Z]+\d\d?[a-zA-Z]?')
    QGIS: regexp_substr("postcode" , '(^[a-zA-Z]+\\d\\d?[a-zA-Z]?)')
    UK Postcode District

    UK Postcode District

    Sector: G12 8
    RegEX: ^[a-zA-Z]+dd?[a-zA-Z]?s*d+
    PostgreSQL: substring(postcode, '^[a-zA-Z]+\d\d?[a-zA-Z]?\s*\d+')
    QGIS: regexp_substr("postcode" , '(^[a-zA-Z]+\\d\\d?[a-zA-Z]?\\s*\\d+)')
    UK Postcode Sector

    UK Postcode Sector

    Unit: G12 8QH

    I’ll let you figure this one out.

    #Ireland 2023

    Ireland is bidding for the 2023 Rugby World Cup.

    They have submitted 12 stadiums in their bid. They cover all four provinces and the breadth of the island.

    Ranging from Europe’s third biggest stadium Croke Park in Dublin. Welcoming 1.5 million fans every year. Packing in 82,300 dedicated fans every year for the GAA (Gaelic Athletic Association) Hurling and Gaelic Football finals. An integral part of Ireland’s history through sweat, blood, and identity.

    The Aviva Stadium in Dublin, the worlds oldest international rugby stadium. Venue for the 2011 Europa League Final between Portuguese sides Porto and Braga.

    Ravenhill Stadium in Belfast. Home of Ulster Rugby and in 1991 venue for Japan’s first match victory in a Rugby World Cup.

    Thomond Park in Limerick. Heart of the community and host to a 12 year unbeaten run for Munster rugby. Winner of the ‘Best Rugby Stadium in the World’ vote in 2013.

    Ireland 2023 Stadiums

    Storm Harvey QGIS Geometry Generator

    Storm Harvey produced some extremely high levels of rainfall. Some areas of Texas received over 50 inches of rain over 9 days.

    The National Oceanic and Atmospheric Administration (NOAA) provided some really great real time datasets to map the progress of the storm.

    Among these were:
    Hourly Precipitation
    Hurricane Path

    From these we can produce a GIF of hourly precipitation:
    Harvey Hourly Precipitation GIF

    And total precipitation:
    Hurricane Harvey Total Precipitation

    Particularly the hurricane path was possible to create in QGIS using the Atlas Generator, and the excellent new:ish geometry generator. This can be found as an option for any layers symbology, as one of the renderers.

    For my map I had a non spatial table that drove my atlas. This was a log table of all of the hours of precipitation I had loaded into my database. So I looped through each entry and showed the corresponding points of hourly precipitation for the corresponding hour. I also had hurricane path data as points for every 6 hours. So I could use the geometry generator to interpolate points in between known points.

    While the query ended up being pretty long it is pretty straightforward.

    It only needs to be run when the hour being generated does not end with a 00, 06, 12, or 18, because those are the positions I already know.

    For the rest I need to generate two points. One for the previously known point, and one for the next known point.

    Then I would create a line between those two points, measure the line, and place a point on the line x times one sixth of the way for the start of the line depending on the hour from the last known point.

    Overall I am very impressed and happy with the result. With a bit of data defined rotation the storm progress looks great.

    Crowdsourced City Extents

    Following up from my Glasgow Regions Mapped Update.

    Alasdair Rae recently started a crowdsourcing project for four cities in the UK: London, Birmingham, Manchester, and Glasgow. Original page. Write up of the results. The post was however very popular and resulted in responses from around the world.

    Since the project was created with the excellent code from Nick Martinelli, the data can be downloaded by anyone.

    So I created a breakdown of the number of responses in 1 km grids for each city that received at least 5 responses.

    The full album, ordered by country name and then city name can be found:




    The west end is the true Glasgow.


    Very inclusive.


    Much larger and inclusive than Manchester.


    The M25 provides a very handy limiting barrier.


    Far reaching urban sprawl.

    New York

    Probably some selection bias, with crowd sourcing more popular in Brooklyn.



    All cities.

    Glasgow Regions Mapped – Progress Update 1

    You can map your response HERE.

    You can read the initial post at: Mapping Glasgow Districts

    We have had some great progress on the mapping so far. There have been 367 regions mapped to date. However, as mentioned in the original post, there are a huge number of regions in Glasgow so even with over 300 responses many regions have only one response and others are still unmapped. But in the hopes of encouraging some more responses I felt it would be nice to show what progress has been made to date.

    Statistics so far:
    Unique region names so far: 241

    Most mapped regions:
    City Centre – 10
    Finnieston – 9
    Merchant City – 9
    Dennistoun – 8
    Partick – 7
    West End – 7
    Garnethill – 6
    Hyndland – 6
    Woodlands – 5
    Hillhead – 5
    Mount Florida – 5

    Regions so far. Click for PDF version.

    We can see that there are still quite a few regions that have had the same number of responses with multiple region names.

    We can look at what these responses have been, in an interactive map:

    Full Screen.

    We can see that the West End in general has been the target of a large number of responses, so we can drill in a little further:


    Extent of the west end:

    West End

    Individual regions:





    Charing Cross









    Kelvingrove Park



    Not Partick

    Park Circus





    West Maryhill





    A final note, there have been some creative responses as well, as expected. But the flagging system on the mapping page has worked incredibly well.

    A huge thanks if you have responded already. I would be grateful if you could share this on either Facebook, Twitter, or anywhere else. The more responses that are submitted, the better the end result.

    Happy to take on suggestions as well.

    Map a region!

    Missing Maps Stirling

    Missing Maps is a great initiative which encourages the mapping of areas that are crucial to the efforts of humanitarian organisations. Maps help people on the ground to focus their efforts and simply find people in need.

    Isn’t everything mapped already?
    Is a question I hear often. While a valid one. Yes, all the streets that I use regularly are mapped on both Google Maps, and OpenStreetMap. But the case is not the same for the places where our efforts are really needed. For the undeveloped parts of the world, where Medecins Sans Frontieres are making a real impact, the case is not the same. We have aerial imagery, but we do not know where the towns are, where the roads go, or population estimates.

    Organisations rely on Missing Maps to deliver their life saving help. Not to deliver aide but to find people requiring it:

  • The American Red Cross
  • The British Red Cross
  • Humanitarian OpenStreetMap Team
  • Medicins Sans Frontieres

  • Come along:

    If you are in Stirling or in the area, please come along. The event is free, and being held at the Smith Museum, on the 27th April, 6pm onwards.

    If you are attending if you could sign up so we know attendee numbers:

    If you want to share the event we also have a FaceBook page:


    Hope to see you there.

    Mapping an Integer

    So just before Christmas I received my own “hand-crafted”, “unique”, and “hella-beautiful” integer. From Brooklyn Integers: 404578811.


    I was not initially sure what to do with it. But I had some time while waiting on points to appear in polygons so I though I would map my integer.

    So we have a few combinations for co-ordinates:

  • 0, 404578811
  • 4 , 04578811
  • 40 , 4578811
  • 404 , 578811
  • 4045 , 78811
  • 40457 , 8811
  • 404578 , 811
  • 4045788 , 11
  • 40457881 , 1
  • 404578811, 0
  • And of course:

  • 404578811, 404578811
  • I have to say these do not translate very well into my current de facto co-ordinate system of British National Grid (0, 404578811 and 404578811, 0 and 404578811, 404578811 not shown).


    Luckily we can try some alternatives. Smathermather had a great post about mapping Null Island/Archipelago, so we can re-use some code. To map our integers to a selection of CRSs.

    We use the EXCEPTION, because some of the more awkward co-ordinate combinations cannot be translated back to EPSG:4326 without causeing a SQL error.

    Then we can create our our tables.

    Replacing 404578811_404578811 as needed.



    By CRS:




    Album of the rest.

    It really shows how fragmented the EPSG codes are for New Zealand, and to a lesser extent the US.