2

I am attempting to style Ordnance Survey Vectormap Local on QGIS 1.8.0 by using the styling sheets suplied by Ordnance Survey. The styling sheets are available from the OS website (http://www.ordnancesurvey.co.uk/business-and-government/help-and-support/products/vectormap-local.html). However when I load one of the Vector layers - take 'road centrelines' as an example and then load an SLD (OS VectorMap Local - Road_Centre_Lines.sld) in the style tab, it only displays two rules which don't style the layer.

It's as though QGIS doesn't read the SLD correctly or am I not loading/applying the SLD files the right way?

I was expecting the SLD to configure the symbology so that Motorways would be displayed as thick blue lines for example and minor roads to be displayed as small white lines.

I have 16 Vector layers in total and it would be a very long process to manually style all of them so I would rather avoid that approach at all cost.

enter image description here

0

2 Answers 2

7

The SLDs were originally created for our own use in GeoServer which supports several vendor specific options that we use for our OS OnDemand Web Services, so there are some edits that you need to manually make to the SLDs for them to work in QGIS.

The first is that in the SLDs we top and tail each rule with the

<FeatureTypeStyle>
</FeatureTypeStyle>

QGIS will only read this first one so what you need to do is find all instances of these and delete them and then add back in one at the top and then one at the bottom of the SLDs.

This should enable QGIS to understand the Areas, Lines, Points, RoadCline and Text SLDs.

However to make the text work I would advise the following

The following is a guide for post processing OS VectorMap Local so that it can be rendered within QGIS.

Firstly, we need to create a new anchor column which tells QGIS which position to locate the text.

ALTER TABLE vml_text ADD COLUMN anchor VARCHAR;
COMMIT;

update vml_text set anchor = 'Below Left' where anchorposition = 0;
update vml_text set anchor = 'Left' where anchorposition = 1;
update vml_text set anchor = 'Above Left' where anchorposition = 2;
update vml_text set anchor = 'Below' where anchorposition = 3;
update vml_text set anchor = 'Over' where anchorposition = 4;
update vml_text set anchor = 'Above' where anchorposition = 5;
update vml_text set anchor = 'Below Right' where anchorposition = 6;
update vml_text set anchor = 'Right' where anchorposition = 7;
update vml_text set anchor = 'Above Right' where anchorposition = 8;
COMMIT;

Next we need to add a new column to tell QGIS what colour the text should be.

ALTER TABLE vml_text ADD COLUMN fontcolour VARCHAR;
COMMIT;

update vml_text set fontcolour = '#646464';
COMMIT;
update vml_text set fontcolour = '#9E8F7C' where featurecode = 15404;
update vml_text set fontcolour = '#9E8F7C' where featurecode = 15407;
update vml_text set fontcolour = '#C47206' where featurecode = 15403;
update vml_text set fontcolour = '#C47206' where featurecode = 15402;
update vml_text set fontcolour = '#71B6D1' where featurecode = 15603;
COMMIT;

Next we add a new column for the font family name, this is based on the attribute 'font' already within the data.

ALTER TABLE vml_text ADD COLUMN fontname VARCHAR;
COMMIT;

update vml_text set fontname = 'Times New Roman' where font = 0;
update vml_text set fontname = 'Arial' where font = 1;
update vml_text set fontname = 'Arial' where font = 2;
update vml_text set fontname = 'Arial' where font = 3;
update vml_text set fontname = 'Arial' where font = 4;
COMMIT;

Next we add a new column for the text we actually want to render for only a specific number of features. The reason for this is we do not want to render the road text as this will be rendered from the roadclines.

ALTER TABLE vml_text ADD COLUMN rendertext VARCHAR;
COMMIT;

update vml_text set rendertext = textstring where featurecode = '15017';
update vml_text set rendertext = textstring where featurecode = '15015';
update vml_text set rendertext = textstring where featurecode = '15112';
update vml_text set rendertext = textstring where featurecode = '15121';
update vml_text set rendertext = textstring where featurecode = '15122';
update vml_text set rendertext = textstring where featurecode = '15210';
update vml_text set rendertext = textstring where featurecode = '15122';
update vml_text set rendertext = textstring where featurecode = '15403';
update vml_text set rendertext = textstring where featurecode = '15404';
update vml_text set rendertext = textstring where featurecode = '15407';
update vml_text set rendertext = textstring where featurecode = '15603';
COMMIT;

Next we create a new column roadinfo on the roadcline table which is a concatenated attributed based on the road number and road name. The code will concentenate the attributes and also deal with NULL values.

ALTER TABLE vml_roadcline ADD COLUMN roadinfo VARCHAR;
COMMIT;

update vml_roadcline set roadinfo = ARRAY_TO_STRING(ARRAY[roadnumber, roadname], ' ');
COMMIT;

After post processing the data can now be rendered in QGIS using the data drive styling functions. (if you dont know how to do this refer to the other questions here on GIS Stack Exchange like Data-defined Styles in QGIS)

After doing all of that I would save the styles as QML files so that you can use them regularly with QGIS

-1

You are loading the SLD correctly but you need to check that SLD matches your data: does it have the same field names? do you have separate datasets for all point, line and area features or are all line features grouped together.

Open the SLD in a text editor (notepad++ is good) and check the ogc:PropertyName. Have you got a field called "featurecode" in your data?

I loaded OS VectorMap Local using FME, GoLoader and Loader! and all three use a different data structure so I had to adjust the OS SLD files to match. It took some time but looks great when done.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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