Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tjmgis/5851551 to your computer and use it in GitHub Desktop.
Save tjmgis/5851551 to your computer and use it in GitHub Desktop.
OS VectorMap District guide for cartographic rendering
Background
OS VectorMap District is made up of 23 layers of data ranging from woodland to tidal water to POI features.
Ordnance Survey released a number of Style Layer Descriptors (SLDs). These SLDs although they can be imported and used to style the data within QGIS several of the SLDs need editing. There also needs to be some post processing applied to the data in order to render as a cartographic product.
Firstly, I want to use the Dft NUmber and the Road name as a label so I added a new column and created a concatenated string using the SQL commands below.
ALTER TABLE vmd.road ADD COLUMN roadinfo VARCHAR;
COMMIT;
UPDATE vmd.road set roadinfo = ARRAY_TO_STRING(ARRAY[dftnumber, name], ' ');
COMMIT;
QGIS uses data drive styling, so I can create a new attribute that QGIS can use for the font colour and update that column based on the other attribute 'featcode'.
ALTER TABLE vmd.road ADD COLUMN fontcolour VARCHAR;
COMMIT;
UPDATE vmd.road set fontcolour = '#FFFFFF' where featcode = 25710;
UPDATE vmd.road set fontcolour = '#080707' where featcode = 25750;
UPDATE vmd.road set fontcolour = '#D68522' where featcode = 25743;
UPDATE vmd.road set fontcolour = '#D41C40' where featcode = 25729;
UPDATE vmd.road set fontcolour = '#00A629' where featcode = 25723;
COMMIT;
I can use the same technique for the Font Family.
ALTER TABLE vmd.road ADD COLUMN fontfamily VARCHAR;
COMMIT;
UPDATE vmd.road set fontfamily = 'Arial' where featcode = 25710;
UPDATE vmd.road set fontfamily = 'Arial' where featcode = 25750;
UPDATE vmd.road set fontfamily = 'Arial' where featcode = 25743;
UPDATE vmd.road set fontfamily = 'Arial' where featcode = 25729;
UPDATE vmd.road set fontfamily = 'Arial' where featcode = 25723;
COMMIT;
And similarly the Font Height which varies depending on the type of road.
ALTER TABLE vmd.road ADD COLUMN fontheight VARCHAR;
COMMIT;
UPDATE vmd.road set fontheight = 13 where featcode = 25710;
UPDATE vmd.road set fontheight = 11 where featcode = 25750;
UPDATE vmd.road set fontheight = 13 where featcode = 25743;
UPDATE vmd.road set fontheight = 14 where featcode = 25729;
UPDATE vmd.road set fontheight = 14 where featcode = 25723;
COMMIT;
Some of the styling also uses Bold text and we can create a new bold attribute and use a Boolean to populate it
0 = false
1 = true
ALTER TABLE vmd.road ADD COLUMN bold VARCHAR;
COMMIT;
UPDATE vmd.road set bold = 1 where featcode = 25710;
UPDATE vmd.road set bold = 0 where featcode = 25750;
UPDATE vmd.road set bold = 0 where featcode = 25743;
UPDATE vmd.road set bold = 1 where featcode = 25729;
UPDATE vmd.road set bold = 1 where featcode = 25723;
COMMIT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment