I'm trying to apply the OS QML (Full Colour) styles to OS Vector Map District shapefiles in QGIS 2.18.0 . Mostly, it works OK sometimes but I am having problems styling the roads.

Roads are styled using a number of different layers as shown in the guidance image provided by OS. enter image description here

Some road layers are styled by categories ('Fill' layers) and some layers (the 'Casing' layers) are styled using rules. Initially, none of the road layers display, and I believe this is because the qml file is based on an attribute called 'featureCode' and the equivalent map attribute is called 'FEATCODE'.

For the categorised layers this is easily fixed by selecting the 'FEATCODE' as the column in the Layer Styling tab. But this is not easily fixed for rule-based styling.

I have looked at a number of ways to rectify this:

  1. Edit the map attribute table name to match the qml file (but this is not allowed as 'featureCode' is too long to be an attribute name)

  2. Edit the rules once applied in QGIS, changing 'featureCode' to
    'FEATCODE' in the Layer styling tab for each occurence in each rule (this is time-consuming and has to be repeated for each rule and for each layer)

  3. Edit the qml file, changing 'featureCode' to 'FEATCODE' (I have confirmed this works but again is a bit time consuming).

My question is, am I missing some obvious way of mapping the qml attribute name to the shapefile attribute name without having to do lots of editing? This seems a pretty fundamental problem with these files (I downloaded both shapefile and QML file at the same time and have double checked they are for the same data set - Vector Map District) - unless I have overlooked something. The same issue is likely to affect a number of the other layers as well.

  • 1
    Check these issues "(shapefile truncates field names) but if change to CLASSIFICA it will work. See this screenshot." in this blog back in 2014 mapperz.blogspot.ca/2014/06/qgis-ordnance-survey-opendata.html – Mapperz Mar 16 '17 at 14:42
  • 1
    Have you tried the GML download and associated QML files instead? That might get round the shapefile fieldname issues, but not tried this – Steven Kay Mar 16 '17 at 22:09
  • Thanks for your suggestions. @Mapperz - I didn't have any success using truncated fieldnames , I wonder if this is due to using later QGIS version? – B_Dabbler Mar 17 '17 at 12:56
  • @StevenKay - using the GML files works perfectly, until I want to save it as a shapefile, but I guess that is another problem! – B_Dabbler Mar 17 '17 at 13:49

Just downloaded a fresh copy of the OS Vector Map District from here and new stylesheets from here. I've checked the naming convention in both shapfile and qml for the road stylesheets and it appears they've fixed any naming mishaps there may have been. I'd suggest re-downloading the data and stylesheets and you shouldn't have any further trouble.

The only bit of work I had to do was rename the shapefiles to remove the OS reference grid code from the start of the name so it matched the qml file and create several copies of the road shapefile (6 in total) to match the number of style files.

As an added bonus to make it easier/faster for you:

The OS provide a Stylesheet User Guide which explains how to apply the styles. For QML they give 2 methods but it's the second one that good be a big help. Rename the the the shapefiles to the same name as the qml files, then move the qml files to the same folder as the shapefiles. When you load the shapefiles into QGIS they styles are automatically applied. (Didn't know about this one, but it works like a dream)

  • I am baffled. This is exactly the process I followed initially (I tried both methods provided by the OS). I have repeated the process using the links in your reply - still, with no success. The only step that was different to my previous attempts is that this time I downloaded the qml files from GitHub. I am clearly missing something fundamental... Could I have inadvertently changed a setting somewhere? – B_Dabbler Mar 20 '17 at 13:57
  • Sorry but I have no idea how a change could be introduced. You say you use 2.18.0. I used 2.18.4 to check but I can't see how that could be the difference. – Knightshound Mar 20 '17 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.