Category Archives: Uncategorized

Creating a vector profile in QGIS


This follows a presentation I gave in 2016 at the QGIS Southwest user group at Hertford University. Of course I was meant to write it up then but with moving jobs I forgot  until a fellow user was having trouble with profile outputs so here is the process I use.

There are a number of plugins required for this:

QProf (for creating the profile and output – you could also use the Profile plugin)

Points2One (to create the vector profiles)

I also had a DSM and DTM and the process I explain uses both.

The area for the example is the Humber Bridge (shown above) and the DSM and DTM are open data from the Environment Agency 1m LIDAR.


Load the DSM and DTM. Locate the area for your profile and either draw a line (I used a scratch layer) or use an existing line layer. I digitised a line along the centre of the bridge from one side to the other being careful not to stray either side – the white line in the figure below. The figure also shows the DSM layer with the DTM below it.


I don’t intend to go through the use of the QProf tool I figure you can do that yourselves but it is easy to use and has many options. Below is an image of the profiles from the line layer. You can see the bridge deck and piers quite clearly also the banks and water surface:


QProf allows you to export in many formats, I choose csv and I create a separate csv for both the DTM and DSM.

Once you have saved the csv files, open then up in a spreadsheet – I find it easier to do this than a text editor my preference being Libra Office Calc. You should see 7 columns of figures: the ID, X and Y (I’m doing this in BNG (EPSG:27700) I have not tried it in any other), cds2d (this will become our ‘row order’), z, cds3d and dirslop. Now here is the bit that you have to get right: we don’t want to use the ID, X & Y as this will put out profile over the map – we want to have a two dimensional view but in the map window so delete these.

We use the ‘cds2d’ values as our row order – change the column name to ‘ID’.

The ‘z’ column becomes our ‘Y’ coordinates – change the column name to ‘Y’.

The ‘cds3d’ column becomes our ‘X’ coordinates – change the column name to ‘X’.

Save the csv and open it in QGIS – you won’t see it in the window because we have transformed the coordinates so that it is in the very lower left corner of the BNG BBox.

Select the layer and zoom to it, you should see a series of points. Do the same process for both the DTM profile and DSM profile.

Creating the profile lines.

When you are zoomed to the point layer you can transform them into lines or polygons using the Points2One plugin which creates shp files, this process is self-explanatory. Keep the point files as the height data is not retained in the shp files and you can play about with the points to make them vertical lines based on the height value – have a go and see what you can do.

Below is the finished profiles for the Humber Bridge and water/banks, obviously I’ve coloured the water line to look a little more authentic.


Using QGIS Atlas to show single items

Don’t go away – this is not as boring as it seems!

I was asked the other day if I could provide a small overview map for each page of a document containing 30+ individual photos. But, the rub was, that each map had to have only the location symbol relating to that individual photo showing where it was taken from.  The answer was of course, yes.  Then I thought about it and, yes it could be done, with the Atlas feature of QGIS, but I wasn’t sure if I could get only the individual feature on the map, so like all these things the best place to start was a Google search and after a lot of digging I found a number of ideas.  It turned out to be very simple in the end!

Below is the process for achieving the desired result:

I’m using QGIS 2.12 Lyon but it should work in 2.10 Pisa not sure about previous versions – try it.

The map is a basic OS raster and I’ve just created 6 points, each has an ID and Direction attribute,  the direction is to the focal point – it doesn’t really matter for this exercise as the objective is to show how we can produce a map with individual objects, even when they are close together.

I want to produce each map at 1:10,000 scale but this means that all the points will show.

First I create the map in the Composer, add a table (just because I want the information for each point, it isn’t needed for the process though).

Fig1The first setting in the composer is for the map – make sure the ‘Controlled by Atlas’ is checked in the map Item Properties.

If you are using a table to sync data for each object then you need to set a filter ($id = $atlasfeatureid) on the table (see below)

Fig2This results in the appropriate record being shown for each map object.  You can click the ‘Attributes…’ button to restrict which fields are shown, change the header text or set the columns to a fixed size.

In the map, open the layer properties of the layer you are using for the Atlas and set the style to ‘Rule Based’ and set the rule to the same as the filter ($id = $atlasfeatureid).

Back to the composer and select the ‘Preview Atlas’ button on the toolbar – you should now have an individual symbol (works for any map object in fact) in the centre of your map.







QGIS Legend trick – polygon shapes

Whilst doing some work on a plan which involved many layers of information, actually I was trying to replicate the plan created in another mapping system, and part of this process involved making it look exactly like the original as it was part of the planning process documents already accepted and therefore, couldn’t be changed (I would have liked to do it differently from the original but this wasn’t an option).

Getting all the mp layers looking like they should was no problem because using the styling capabilities of QGIS, being so extensive, this was a breeze!  Many layers were brought in from MapInfo (opening the native TAB format) and then styled by attributes using the categorized classification method.

A number of layers were polygons either squares, circles or triangles and although they looked OK on the map the shapes are not replicated in the legend in composer, they appear as a normal (usually) rectangle symbols.  This was seen to be confusing but I didn’t know how to sort it.  Below is a picture of three basic shapes classified by their attribute:

As you can see, it doesn’t matter what the shape is, the legend shows rectangles – this is not helpful especially if there are other map items with the same colour.


Now look at the legend below: it is using the same map items and colours but the legend shows the shape also.  To do this you need to style the polygons as ‘centroid fill’ and select your marker symbol size accordingly This will show your polygon as the selected shape and reflect this in the legend.  The down-side is that the symbol size in the legend can be very much larger than other, normal rectangle symbols (if you’ve set the symbol size in the map to be quite large) so you have to adjust the marker size in both the map and composer legend to get things looking right.


Below are the settings as an example:


I hope you find this usful.

Styling with QGIS

This post is written in response to a question from a QGIS beginner (+Jamal Almuallem) about how I styled some freedata (, he was looking for a tutorial but I didn’t know of one so said I would blog about it.  The picture below is the output and as you can see I’ve applied a style to make some of the features appear as if they are in 3D.



The start of this process is to get some data, I used Ordnance Survey Open Data, Vector Map District, load into QGIS, select the layer and either double-click or right click and select ‘properties’, go to ‘Styles’.  The Settlement layer are all polygons but whether it is line work, points or polygons, the process is the same.

The Layer Properties dialog looks like this:



In the ‘Symbol layers’ section there will be a ‘simple fill’ representing the default colour applied to the layer on loading. You can change this to whatever you like.  The trick to making the buildings look 3D is to add another fill – select the ‘Fill’ at the top of the tree and use the + button to add another fill.  Set the colour, type of fill and an offset see the dialog below for extra options when one of the fills on the tree is chosen:



You can see on the right of the dialog that I have offset the lower fill by 0.5 on both axis. This has the effect of moving the lower fill down and to the left of the top fill.  As a rule I always have the lower fill a darker shade than the top as this imitates shadow.

Click OK and you will see the effect on the map – play around until you find something that you like.  You can save this style to a file for reusing in other projects by using the ‘Save Style’ button.

QGIS Time Manager 2

So I’ve been promising an update to my Timemap series so here is the next stage of tinkering.

This is based on a live demo I did at the first UK QGIS User Group a few weeks ago and is a result of looking at multi-level data within the same time period.  Again, I’ve used railways as the basis, simply because I love railways and loving a subject spurs you on when you’re completing what can be, repetitive tasks.

So the first thing is to set up your basic route [or series], mine is the line between Bletchley and Bedford St. Johns.


©Crown Copyright & Database rights 2012

First thing to mention is that this is created in QGIS 1.8 as the plugin for version 2.0 wasn’t ready.

The line was split into 32 sections (see picture), as it takes 32 minutes to travel between the stations, but you will determine the frequency based on your own time requirements.

  • It is important to make sure you create your records in a sequential manner as the plugin goes through record by record.
  • Each record is given a start and end time (end time not required) – the format of the date/time is important, look at the plugin to determine how you want to format this but make sure you change it in the settings within the plugin else it just won’t work!  I tend to keep to the default setting yyyy-mm-dd hh:mm:ss (you can see how the table is made up from my previous post).
  • I also created a table of points for the stations, with the same structure as the route but a column added which holds the name of the station.  This column is used to label the station.  The point symbols were made to be 100% transparent so they don’t show but were set to be labelled with their name – you don’t have to do this but I only wanted the names to show as the train went by (as it were).
  • Set the start time for each station to correspond with the line segment just preceding it and the end time to however long you want the label to appear (no end time will result in the label staying visible until the end of the whole animation).
  • In the plugin add all the tables you require and run it!

That’s it really, simple to do but attention to the detail and format are key to making it work.

You can see the finished video here:

You are not bound by lines, any object can be made to appear/disappear if it has a date/time – I showed an example of random circles with labels containing information so as long as there’s a temporal aspect to data it will work but better still, it will impress in terms of communicating information.

Have fun!