QGIS Planet

Trace digitising in QGIS

Following the popularity of the AutoTrace plugin, we received a number of requests for additional features and to incorporate the tool into the main Advanced Digitising tools in QGIS.

Funding for the work was generously raised with the help of the community in 2015 and the feature landed in QGIS 2.14

How to use Trace Digitising

Check out the Trace Digitising in QGIS for detailed instructions on how to use the tool.

Key features

The trace tool:

  • uses Dijkstra’s shortest path algorithm to find traceable routes
  • can trace routes over multiple distinct features
  • can be used with Advanced Digitising tools (e.g. reshaping)
  • can be enabled and disabled by pressing T on your keyboard while digitising
  • is fast and easy to use

The following video demonstrates how to use the tracing tool:

This video shows how you can make use of tracing while reshaping a polygon:

Sponsors

The project was kindly sponsored by the QGIS community. Special thanks to all those who contributed towards the development of this tool:

  • The Royal Borough of Windsor and Maidenhead
  • Neath Port Talbot County Borough Council
  • Ujaval Gandhi
  • Surrey Heath Borough Council
  • Matias Arnold
  • Northumberland National Park Authority
  • Buccleuch Estates Limited
  • Countryscape

You may also like...

Mergin Maps, a field data collection app based on QGIS. Mergin Maps makes field work easy with its simple interface and cloud-based sync. Available on Android, iOS and Windows. Screenshots of the Mergin Maps mobile app for Field Data Collection
Get it on Google Play Get it on Apple store
Learn More

QGIS Features I long for while using ArcGIS

(aka Features that ArcGIS Desktop users might not know that exists)

EN | PT

From time to time, I read articles comparing ArcGIS vs QGIS. Since many of those articles are created from an ArcGIS user point of view, they invariably lead to biased observations on QGIS lack of features. It’s time for a QGIS user perspective, so bare with me on this (a bit) long, totally and openly biased post.

“Hello, my name is Alexandre, and I have been using… QGIS

This is something I would say at an anonymous QGIS user therapy group. I’m willing to attend one of those because being recently and temporally forced to use ArcGIS Desktop again (don’t ask!), I really really really miss QGIS in many ways.

There was a time when I have used ArcGIS on the regular basis. I used it until version 9.3.1 and then decided to move away (toward the light) into QGIS (1.7.4 I think). At that time, I missed some (or even many?) ArcGIS features, but I was willing to accept it in exchange for the freedom of the Open Source philosophy. Since then, a lot have happened in the QGIS world, and I have been watching it closely. I would expect the same have happened in ArcGIS side, but, as far I can see, it didn’t.

I’m using top shelf ArcGIS Desktop Advanced and I’m struggling to do very basic tasks that simply are nonexistent in ArcGIS. So here’s my short list of QGIS functionalities that I’m longing for. For those of you that use ArcGIS exclusively, some of this features may catch you by surprise.

Warning: For those of you that use ArcGIS exclusively, some of this features may catch you by surprise.

Transparency control

“ArcGIS have transparency! It’s in the Display tab, in the layer’s properties dialog!”

Yes, but… you can only set transparency at the layer level. That is, either it’s all transparent, or it’s not…

In QGIS on the other end, you can set transparency at layer level, feature/symbol level, and color level. You can say that this is being overrated, but check the differences in the following images.

Transparency_layer_levelTransparency_feature_symbol_levelTransparency_color_level

Notice that in QGIS you can set transparency at color level everywhere (or almost everywhere) there is a color to select. This includes annotations (like the ones in the image above), labels and composers items. You can even set transparency in colors by using the RGBA function in an expression! How sweet can that be? 🙂

Screenshot from 2016-01-27 14:12:34

Blending modes

This is one of QGIS’s pristine jewels. The ability to combine layers the way you would do in almost any design/photo editing software. At layer or at feature level, you can control how they will “interact” with other layers or features below. Besides the normal mode, QGIS offers 12 other blending modes:  Lighten, Screen, Dodge, Darken, Multiply, Burn, Overlay, Soft light, Hard light, Difference, and Subtract. Check this page to know more about the math behind each one and this image for some examples

It’s not easy to grasp how can this be of any use for cartography before you try it yourself. I had the chance to play around while trying to answer this question.

2wph4

A very common application for this functionality is when you want to add shadows to simulate the relief by putting a hill shade on top of other layers. In ArcGIS, you can only control the layer transparency, and the result is always a bit pale. But in QGIS, you can keep the strength of the original colors by using the multiply mode in the hill shade layer.

Screenshot from 2016-01-27 15:24:38
Hypsometry original colors

Screenshot from 2016-01-27 15:25:45
Hypsometry colors paled by transparent hill shade

Screenshot from 2016-01-27 15:24:45
Hypsometry original colors with the hill shade using QGIS multiply blending

You can also use blending modes in the print composer items, allowing you to combine them with other items and textures. This gives you the opportunity to make more “artistic” things without the need to go post-processing in a design software.

Colour Picker Menu

Controlling color is a very important deal for a cartographer and QGIS allow you to control it like the professional you are. You can select your colours using many different interfaces. Interfaces that you might recognize from software like Inkscape, Photoshop, Gimp and others alike.

My favorite one is the color picker. Using color picker, you can pick colors from anywhere on your screen, either from QGIS itself or outside. This is quite handy and productive when you are trying to use a color from your map, it’s legend, a COLOURlovers palette or a company logo.

anim
Picking a color from outside QGIS

You can also copy/paste colors between dialogs, save and import color palettes, and you can even name a color and use it in a variable. With all this available for free, it’s hard to swallow Windows color selector :(.

Vector symbols renderers “powertools”

In ArcGIS, you have a few fancy ways to symbol your vector layers. You got: Single symbol, Unique values, Unique values many fields… and so on. At the first glance, you may think that QGIS lacks some of them. Believe me, it doesn’t! In fact, QGIS offers much more flexibility when you need to symbol your layers.

For starters, it allows you to use fields or expressions on any of the symbols renderers, while ArcGIS only allows the use of fields. Powered by hundreds of functions and the ability to create your owns in python, what you can do with the expression builder has no limits. This means, for instance, that you can combine, select, recalculate, normalize an infinite number of fields to create your own “values” (not to mention that you can tweak your values labels, making it ideal to create the legend).

Screenshot from 2016-01-20 22:34:54
QGIS Graduated renderer using an expression to calculate population density

And then, in QGIS, you have the special (and kinda very specific) renderers, that make you say “wooooh”. Like the Inverted polygons that allow you to fill the the outside of polygons (nice to mask other features), the Point displacement to show points that are too close to each others, and the Heatmap that will transform, ON-THE-FLY, all your points in a layer into a nice heatmap without the need to convert them to raster (and that will update as soon as you, or anyone else, edits the point features).

Screenshot from 2016-01-20 22:58:44
Inverted Polygon Renderer masking the outside of an interest area

But I have left the best to the end. The “One rendered to Rule them all”, the Rule-based symbols. With the rule-based renderer, you can add several rules, group them in a tree structure, and set each one with a desired symbol. This gives QGIS users full control of their layer’s symbols, and, paired with expression builder and data-defined properties, opens the door to many wonderful applications.

rulesymbol_ng_line
Rule-based renderer

Atlas

One of my favorite (and missed) features in QGIS is the Map Composer’s Atlas. I know that ArcGIS has its own “Atlas”, the Data Driven Pages, but frankly, it’s simply not the same.

I believe you know the basic functionally that both software allow. You create a map layout and choose a vector layer as coverage, and it will create an output panned or zoomed for each of the layer’s feature. You can also add some labels that will change according to the layers attributes.

But in QGIS, things go a little bit further…

Basically, you can use coverage layer’s attributes and geometry anywhere you can use an expression. And, in QGIS, expressions are everywhere. That way, most layers and map composer items properties can be controlled by a single coverage layer.

With the right configuration, while iterating over the atlas coverage features, you can,  choose what feature to show and what features to hide, change a theme color for your map, rotate and resize your page acording to the feature sizechoose a specific logo to came along with your map, and much more. Once again, the sky is the limit.

mosaico_regioes_fixed
Auto-resized maps that fits the coverage features at specific scale using atlas

So, if you pair Atlas it with QGIS data-defined properties, rule-based symbols and expressions, ArcGIS Data Driven Pages are no match. You don’t think so? Try to answer this question then.

Tip: If you really want to leverage your map production, using Spatialite or Postgis databases you can create the perfect atlas coverage layers from views that fit your needs. No data redundancy and they are always updated.

Label and Style dialogs

This one is more of a User Experience thing than an actual feature, but you won’t imagine how refreshing it is to have all Style and Labels options in two single dialogs (with several tabs, of course).

Using the symbol menu in ArcGIS makes me feel like if I’m in the Inception movie, at some point in time, I no longer know where the hell am I. For example, to apply a dashed outline in a fill symbol I needed to open 5 different dialogs, and then go back clicking OK, OK, OK, OK …

Capture
ArcGIS “Inception” symbol settings

In QGIS, once in the properties menu, every setting is (almost) one click way. And you just need to press OK (or Apply ) once to see the result!

Screenshot from 2016-01-20 21:51:33
QGIS Style setting

As an extra, you can copy/paste styles from one layer to another, making styling several layers even faster. And now you say:

“Don’t be silly! In ArcGIS you can import symbols from other layers too.”

Symbols? yes. Labels? No! And if you had lots of work setting your fancy labels, having to do the exact same/similar thing in another layer, it will make you wanna cry… I did.

(I think I will leave the multiple styles per layer vs data frames comparison for another time)

WFS

“Say what?!!”

Yup, that’s it, ArcGIS Desktop lacks support for WFS OGC standard unless you buy an extra extension: The Data Interoperability Extention.

In a GIS world that, more and more, is evolving towards Open Data, Open Standards and OGC Web Services, this reveals a very mercantile approach by ESRI. If I were an ESRI customer, I would feel outraged. <sarcasm>Or maybe not… maybe I would thank the opportunity to yet invest some more money in it’s really advanced features…<\sarcasm>

In QGIS, like everything else, WFS is absolutely free (as in freedom, not free beer). All you need to do is add the WFS server’s URL, and you can add all the layers you want, with the absolute sure that they are as updated as you can get.

Screenshot from 2016-01-20 21:58:54

Fortunately for ArcGIS users with a low budget, they can easily make a request for a layer using the internet browser :-P.

http://giswebservices.massgis.state.ma.us/geoserver/wfs?request=GetFeature&service=wfs&version=1.0.0&typename=massgis:GISDATA.TOWNS_POLY&outputformat=SHAPE-ZIP

Or they can simply use QGIS to download it. But, in both cases, be aware that the layers won’t update themselves by magic.

Expression builder

I have already mentioned the use of expressions several times, but for those of you that do not know the expression Builder, I though I end my post with one of my all time favourite features in QGIS.

I do not know enough of ArcGIS expression builder to really criticize it. But, AFAIK, you can use it to create labels and to populate a field using the field calculator. I know that there are many functions that you can use (I have used just a few) but they are not visible to the common user (you probably need to consult the ArcGIS Desktop Help to know them all). And you can create your own functions in VBScript, Python, and JsScript.

Capture

On QGIS side, like I said before, the Expression Builder can be used almost everywhere, and this makes it very convenient for many different purposes. In terms of functions, you have hundreds of functions right there in the builder’s dialog, with the corresponding syntax help, and some examples. You also have the fields and values like in ArcGIS, and you even have a “recent expressions” group for re-using recent expressions with no the need to remember prior expression.

Capture

Besides, you can create your own functions using Python (no VBScript or JsScript). For this purpose, you have a separate tab with a function editor. The editor have code highlighting and save your functions in your user area, making it available for later use (even for other QGIS sessions).

Capture

Conclusion

These are certainly not the only QGIS features that I miss, and they are probably not the most limiting ones (for instance, not being able to fully work with Spatialite and Postgis databases will make, for sure, my life miserable in the near future), but they were the ones I noticed right away when I (re)open ArcGIS for the first time.

I also feel that, based on the QGIS current development momentum, with each QGIS Changelog, the list will grow very fast. And although I haven’t tested ArcGIS Pro, I don’t think ESRI will be able to keep the pace.

“Are there things I still miss from ArcGIS?” Sure. I miss CMYK color support while exporting maps, for instance. But not as much as I miss QGIS now. Besides, I know that those will be addressed sooner or later.

In the end, I kinda enjoyed the opportunity to go back to ArcGIS, as it reinforced the way I think about QGIS. It’s all about freedom! Not only the freedom to use the software (that I was already aware) but also the freedom to control software itself and it’s outputs. Maintaining the users friendliness for new users, a lot have been done to make power users life easier, and they feel very pleased with it (at least I am).

All this being said, the winner is… QGIS!!

The End

(of a very biased post)

Learn More

QGIS Top Features 2015

EN | PT

With the release of the first long term release (2.8 LTR), and two other stable versions (2.10 and 2.12), 2015 was a great (and busy) year for the QGIS community, with lots of improvements and new features landing on QGIS source code.

As a balance, I have asked users to choose wich were their favorite new features during 2015 (from the visual changelogs list). As a result I got the following Top 5 features list.

5 – Python console improvements (2.8)

Since QGIS 2.8, we can drag and drop python scripts into QGIS window and they will be executed automatically. There is also a new a toolbar icon in the plugins toolbar and a shortcut ( Ctrl-Alt-P) for quick access to the python console.

4 – Processing new algorithms (2.8)

Also in QGIS 2.8, there were introduced some new algorithms to the processing framework. If you are into spatial analysis this must have done your day (or year).

  • Regular points algorithm
  • Symmetrical difference algorithm
  • Vector split algorithm
  • Vector grid algorithm
  • Hypsometric curves calculation algorithm
  • Split lines with lines
  • Refactor fields attributes manipulation algorithm

3 – Show rule-based renderer’s legend as a tree (2.8)

There were introduced a few nice improvements to QGIS legend. Version 2.8 brought us a tree presentation for the rule-based renderer. Better still, each node in the tree can be toggled on/off individually providing for great flexibility in which sublayers get rendered in your map.

2 – Advanced digitizing tools (2.8)

If you ever wished you could digitize lines exactly parallel or at right angles, lock lines to specific angles and so on in QGIS? Since QGIS 2.8 you can! The advanced digitizing tools are a port of the CADinput plugin and adds a new panel to QGIS. The panel becomes active when capturing new geometries or geometry parts.

Untitled

1 – Rule-based labeling (2.12)

This was a very awaited feature (at least by me), and it was voted by the majority of users. Since 2.12, you can style features labels using rules. This gives us even more control over placement and styling of labels. Just like the rule based cartographic rendering, label rules can be nested to allow for extremely flexible styling options. For example, you can render labels differently based on the size of the feature they will be rendered into (as illustrated in the screenshot).

image25

There were other new features that also made the delight of many users. For example, the Improved/consistent projection selection (2.8), PostGIS provider improvements (2.12), Geometry Checker and Geometry Snapper plugins (2.12), and Multiple styles per layer (2.8).

Don’t agree with this list? You can still cast your votes. You can also check the complete results in here.

Obviously, this list means nothing at all. I was a mere exercise as with such a diverse QGIS crowd it would be impossible to build a list that would fit us all. Besides, there were many great enhancements, introduced during 2015, that might have fallen under the radar for most users. Check the visual changelogs for a full list of new features.

On my behalf, to all developers, sponsors and general QGIS contributors,

THANK YOU VERY MUCH FOR YOUR TREMENDOUS WORK!

I wish you a fantastic (and productive) 2016.

Learn More

Exploring variables in QGIS pt 3: layer level variables

In part 3 of my exploration of variables in QGIS 2.12, I’m going to dig into how variables are scoped in QGIS and what layer level variables are available (you can read parts 1 and 2 for a general introduction to variables).

Some background

Before we get to the good stuff, a bit of background in how variables work behind-the-scenes is important. Whenever an expression is evaluated in QGIS the context of the expression is considered. The context is built up from a set of scopes, which are all stacked on top of each other in order from least-specific to most-specific. It’s easier to explain with an example. Let’s take an expression used to set the source of a picture in a map composer. When this expression is evaluated, the context will consist of:

  1. The global scope, consisting of variables set in the QGIS options dialog, and other installation-wide properties
  2. The project scope, which includes variables set in the Project Properties dialog and the auto-generated project variables like @project_path, @project_title (you can read more about this in part 2)
  3. composer scope, with any variables set for the current composer, plus variables for @layout_pagewidth, @layout_pageheight, @layout_numpages, etc.
  4. composer item scope for the picture, with item-specific variables including @item_id

The more specific scopes will override any existing clashing variables from less specific scopes. So a global @my_var variable will be overridden by an @my_var variable set for the composer:

overridden

Another example. Let’s consider now an expression set for a data-defined label size. When this expression is evaluated the context will depend on where the map is being rendered. If it’s in the main map canvas then the context will be:

  1. The global scope
  2. The project scope
  3. map settings scope, with variables relating to how the map is being rendered. Eg @map_rotation, @map_scale, etc
  4. layer scope. More on this later, but the layer scope includes layer-level variables plus preset variables for @layer_name and @layer_id

If instead the map is being rendered inside a map item in a map composer, the context will be:

  1. The global scope
  2. The project scope
  3. The composer scope
  4. An atlas scope, if atlas is enabled. This contains variables like @atlas_pagename, @atlas_feature, @atlas_totalfeatures.
  5. composer item scope for the map item
  6. map settings scope (with scale and rotation determined by the map item’s settings)
  7. The layer scope

Using layer level variables

Ok, enough with the details. The reason I’ve explained all this is to help explain when layer level variables come into play. Basically, they’ll be available whenever an expression is evaluated inside of a particular layer. This includes data defined symbology and labeling, field calculator, and diagrams. You can’t use a layer-level variable inside a composer label, because there’s no layer scope used when evaluating this. Make sense? Great! To set a layer level variable, you use the Variables section in the Layer Properties dialog:

Setting a layer variablee

Setting a layer variable

Any layer level variables you set will be saved inside your current project, i.e. layer variables are per-layer and per-project. You can also see in the above screenshot that as well as the layer level variables QGIS also lists the existing variables from the Project and Global scopes. This helps show exactly what variables are accessible by the layer and whether they’ve been overridden by any scopes. You can also see that there’s two automatic variables, @layer_id and @layer_name, which contain the unique layer ID and user-set layer name too.

Potential use cases for layer-level variables

In the screenshot above I’ve set two variables, @class1_threshold and @class2_threshold. I’m going to use these to sync up some manual class breaks between rule based symbology and rule based labeling. Here’s how I’ve set up the rule-based symbols for the layer:

Rule based symbology using layer level variables

Rule based symbology using layer level variables

In a similar way, I’ve also created matching rule-based labeling (another new feature in QGIS 2.12):

Matching rule-based labels

Matching rule-based labels

Here’s what my map looks like now, with label and symbol colors matched:

*Map for illustrative purposes only... not for cartographic/visual design excellence!

*Map for illustrative purposes only… not for cartographic/visual design excellence!

If I’d hard-coded the manual class breaks, it would be a pain to keep the labeling and symbology in sync. I’d have to make sure that the breaks are updated everywhere I’ve used them in both the symbology and labeling settings. Aside from being boring, tedious work, this would also prevent immediate before/after comparisons. Using variables instead means that I can update the break value in a single place (the variables panel) and have all my labeling and symbols immediately reflect this change when I hit apply!

Another recent use case I had was teaming layer-level variables along with Time Manager. I wanted my points to falloff in both transparency and size with age, and this involved data defined symbol settings scattered all throughout my layer symbology. By storing the decay fall-off rate in a variable, I could again tweak this falloff by changing the value in a single place and immediately see the result. It also helps with readability of the data defined expressions. Instead of trying to decipher a random, hard-coded value, it’s instead immediately obvious that this value relates to a decay fall-off rate. Much nicer!

I’m sure there’s going to be hundreds of novel uses of layer-level variables which I never planned for when adding this feature. I’d love to hear about them though – leave a comment if you’d like to share your ideas!

One last thing – the new “layer_property” function

This isn’t strictly related to variables, but another new feature which was introduced in QGIS 2.12 was a new “layer_property” expression function. This function allows you to retrieve any one of a bunch of properties relating to a specific map layer, including the layer CRS, metadata, source path, etc.

This function can be used anywhere in QGIS. For instance, it allows you to insert dynamic metadata about layers into a print composer layout. In the screenshot below I’ve used expressions like layer_property(‘patron’,’crs’) and layer_property(‘patron’,’source’) to insert the CRS and source path of the “patron” layer into the label. If either the CRS or the file path ever changes, this label will be automatically updated to reflect the new values.

Inserting dynamic layer properties into a composer label

Inserting dynamic layer properties into a composer label

 

So there you go – layer level variables and the layer_property function – here in QGIS 2.12 and making your workflow in QGIS easier. In the final part of this series, we’ll explore the magical @value variable. Trust me, I’ve saved the best for last!

Learn More

Exploring variables in QGIS pt 2: project management

Following on from part 1 in which I introduced how variables can be used in map composers, I’d like to now explore how using variables can make it easier to manage your QGIS projects. As a quick refresher, variables are a new feature in QGIS 2.12 which allow you to create preset values for use anywhere you can use an expression in QGIS.

Let’s imagine a typical map project. You load up QGIS, throw a bunch of layers on your map, and then get stuck into styling and labelling them ‘just right’. Over time the project gets more and more complex, with a stack of layers all styled using different rendering and labelling rules. You keep tweaking settings until you’re almost happy with the result, but eventually realise that you made the wrong choice of font for the labelling and now need to go through all your layers and labelling rules and update each in turn to the new typeface. Ouch.

Variables to the rescue! As you may recall from part 1, you can reuse variables anywhere in QGIS where you can enter an expression. This includes using them for data defined overrides in symbology and labelling. So, lets imagine that way back at the beginning of our project we created a project level variable called @main_label_font:

Creating a variable for label font

Creating a variable for label font

Now, we can re-use that variable in a data defined override for the label font setting. In fact, QGIS makes this even easier for you by showing a “variables” sub-menu allowing easy access to all the currently defined variables accessible to the layer:

Binding the label font to the @main_label_font variable

Binding the label font to the @main_label_font variable

 

When we hit Apply all our labels will be updated to use the font face defined by the @main_label_font variable, so in this case ‘Courier New’:

courier_new

In a similar way we can bind all the other layer’s label fonts to the same variable, so @main_label_font will be reused by all the layers in the project. Then, when we later realise that Courier New was a horrible choice for labelling the map, it’s just a matter of opening up the Project Properties dialog and updating the value of the @main_label_font variable:

delicious

And now when we hit Apply the font for all our labelled layers will be updated all at once:

new_labels

It’s not only a huge time saver, it also makes changes like this easier because you can try out different font faces by updating the variable and hitting apply and seeing the effect that the changes have all at once. Updating multiple layers manually tends to have the consequence that you forget what the map looked like before you started making the change, making direct comparisons harder.

Of course, you could have multiple variables for other fonts used by your project too, eg @secondary_label_font and @highlighted_feature_font. Plus, this approach isn’t limited to just setting the label font. You could utilise project level variables for consolidating font sizes, symbol line thickness, marker rotation, in fact, ANYTHING that has one of those handy little data defined override buttons next to it:

See all those nice little yellow buttons? All those controls can be bound to variables...

See all those nice little yellow buttons? All those controls can be bound to variables…

One last thing before I wrap up part 2 of this series. The same underlying changes which introduced variables to QGIS also allows us to begin introducing a whole stack of new, useful functions to the expression engine. One of these which also helps with project management is the new project_color function. Just like how we can use project level variables throughout a project, project_color lets you reuse a color throughout your project. First, you need to create a named colour in the Default Styles group under the Project Properties dialog:

Define a colour in the project's colour scheme...

Define a colour in the project’s colour scheme…

Then, you can set a data defined override for a symbol or label colour to the expression “project_color(‘red alert!’)“:

bind_color

When you go back and change the corresponding colour in the Project Properties dialog, every symbol bound to this colour will also be updated!

blue_alert

So, there you have it. With a little bit of forward planning and by taking advantage of the power of expression variables in QGIS 2.12 you can help make your mapping projects much easier to manage and update!

That’s all for now, but we’re still only just getting started with variables. Part 3, coming soon!.. (Update: Part 3 is available now)

 

Learn More

Exploring variables in QGIS 2.12, part 1

It’s been quite some time since I last had a chance to blog and a lot has happened since then. Not least of which is that QGIS 2.12 has now been released with a ton of new features that I’ve neglected to write about! To try and get things moving along here again I’m planning on writing a short series exploring how variables work in QGIS 2.12 and the exciting possibilities they unlock. First, let’s look into how variables can be used with QGIS map composer…

So, let’s get started! A new concept introduced in QGIS 2.12 is the ability to set custom variables for use in QGIS’ expression engine. The easiest way to do this is through the “Project Properties” dialog, under the “Variables” section:

Default project variables

Default project variables

You’ll see in the screenshot above that a blank project includes a number of read-only preset variables, such as @project_path and @project_title. (All variables in QGIS are prefixed with an @ character to differentiate them from fields or functions). You can add your own variables to this list by clicking the + button, as shown below:

Adding new variables to a project

Adding new variables to a project

Here I’ve added some new variables, @project_version and @author. Now, any of these variables can be used anywhere that you can use expressions in QGIS, including the field calculator, data defined symbology, labelling, map composer text, etc. So, you could make a map composer template with a label that includes the @author, @project_version and @project_path variables:

Variables in a composer label

Variables in a composer label

Sure, you *could* also manually enter all these details directly into the label for the same result. But what happens when you have multiple composers in your project, and need to update the version number in all of them? Or you move your project to a new folder and need to make sure the path is updated accordingly? Manually updating multiple composers is a pain – make QGIS do the work for you and instead use variables! This would especially be helpful if you’re saving map composer templates for use across multiple projects or users. Using variables will ensure that the template is automatically updated with the right details for the current project.

Another neat thing about QGIS variables is that they can be inherited and overridden, just like CSS rules. Opening the options dialog will also show a Variables group for setting “Global” variables. These variables are always available for your QGIS installation, regardless of what project you’re working on at the time. If your workplace tends to reorganise a lot and constantly shuffle your department around, you could add a global variable for @work_department, so that changing the global variable value in one place will automatically filter through to any existing and future projects you have.

Global variables

Global variables

And like I mentioned earlier, these variables are inherited through various “contexts” within QGIS. If I reopen the Project Properties dialog, you’ll see that a project has access to all the global variables plus the variables set within that specific project. In addition, by adding a variable with the same name to the Project variables the value of the Global variable will be overridden:

Overridden variables

Overridden variables

There’s also a variable editor within each individual composer’s properties tab, so variables can also be set and overridden on a composer-by-composer basis within a project. It’s a really flexible and powerful approach which both simplifies workflows and also opens up lots of new possibilities.

Stay tuned for more on this topic – this topic has only just scratched the surface of how expression variables have changed QGIS! (You can also read part 2 and part 3)

Learn More

In brief: 4th QGIS user group in Scotland

Another sold-out event with a programme packed with useful, interesting and delightful talks. Fifty seven (57!) folk blew in from all over Scotland through a freezing rain but hot coffee and pastries were waiting in the Informatics Forum at the University of Edinburgh.

First up was an overview the current status of the QGIS project by Saber from Lutra Consulting. It was good for people new to QGIS and open-source to see how the project is organised and run and the direction it is taking. Pete, also from Lutra Consulting, then gave a quick summary of the bits of core functionality they have been working on including the new ruled based labelling system.
The group then split into two for 90 minute workshop sessions on cartographic labelling and advanced Atlas usage – a tough choice! Chris, from Ordnance Survey, presented a detailed how-to on the new ruled based labelling tools using some OS open data, interspersed with some slides on guidelines to good cartographic practices and labelling tips. The slides and material for this workshop are available here: https://dl.dropboxusercontent.com/u/185489368/QGIS-Scotland2015.pdf

Heikki, from thinkWhere, lead us through the process of using Atlas in Print Composer to automate map production for a series of maps containing a main context map and an inset overview map. Nothing better than doing something once and then being able to repeat it at the click of a button! The slides and material for this workshop are available here: https://github.com/HeikkiVesanto/Scottish_QGIS_User_Workshop

A break for lunch and a good hour of catching up with users from across all sectors – local government, central government, academia, forestry, planning consultancies, developers, student life and education. QGIS is popular and is obviously a flexible tool that meets many demands.

After lunch, Neil, from thinkWhere, organised a quick-fire “quirky QGIS quiz” with random questions from all aspects of FOSS4G demanding quick thinking for true/false answers. At least half the audience grabbed prizes courtesy of thinkWhere and Ordnance Survey.

What followed was a series of lightning talks on different aspects of using QGIS. Amy, from Cawdor Forestry, gave a brief overview of the plugins available in the QGIS plugin repository and highlighted some of her personal favourites. Paul, from Scottish Water, showcased some of the complex workflows created using SAGA, QGIS and the Processing Toolbox to model hydrological process. Ross, from Inverclyde Council, demonstrated the use of the QGIS Road Graph plugin to generate walking routes to school across a custom road and path network. Seb, from West Dunbartonshire Council, showed us how QGIS had put them in a happy place and showed how a “hearts and minds” campaign championing QGIS had changed the way they worked. Steve, fae Embra, gave some information on how to give back to the QGIS project through submitting Processing scripts and plugins to the repository. Don’t reinvent the wheel! Ross, from Angus Council, gave a quick demonstration of setting up a local plugin repository that could be used to share custom plugins or control access to plugins in an internet-less environment.

By this time, tea and cake was required and it gave everyone an opportunity to mix and ask questions of the speakers.

The last session was as series of longer talks started by Gemma, from Ordnance Survey, explaining how open-source software is used extensively at Ordnance Survey to underpin a lot of the cartographic processes and workflows. They use QGIS 2.8 LTR for stability and consistency across the business and a selection of plugins from both OS developers and the community. QGIS is used to generate all the cartographic styles sheets for the OS vector products: https://github.com/OrdnanceSurvey/OS-VectorMap-District-stylesheets

Tom, from EDINA, explained the processing of creating and delivering a QGIS training course to University staff and students. The first class sold out in next to no time and there is demand for more. Makes sense really, doesn’t it?

Steve, from GeoGeo, wrapped up the day with the kind of mapping we’d all like to be doing – high resolution elevation models, time series analysis of shadows, viewsheds across the Edinburgh skyline and analysis of rooftops for potential solar panels with sub 1m resolution LiDAR datasets. He uses a mix of QGIS, SAGA, Blender and other FOSS to inspiring effect. Check his Flickr stream: https://www.flickr.com/photos/stevefaeembra/

The day finished with Pete (Lutra Consulting) releasing into the open a new Search plugin for QGIS called Discovery (http://www.lutraconsulting.co.uk/products/discovery/) based on the PostGIS Search plugin from Tim Martin (Ordnance Survey). A very useful addition to any QGIS installation.

The day was sponsored by EDINA, thinkWhere and Ordnance Survey.

Links to slides will be coming shortly.

Learn More

Photos from QGIS Scotland

 

A full house of 57 Sponsors The QGIS road map Plugin Review Live Demo Road Graph Plugin Processing Scripts QGIS at Scottish Water QGIS to the rescue Water work flows Making them happy QGIS: the right stuff Can you believe it's not ArcGIS?! Open source at Ordnance Survey QGIS Training QGIS is AWESOME Amazing eye candy 4th QGIS user group in Scotland Custom QGIS installer Advanced Atlas usage Open source at Ordnance Survey how to build a plugin Hi-res LiDAR Neil Benny, inquizitor Quirky QGIS quiz
Learn More

Publish Image Tooltips with QGIS Cloud

A lot of people are using QGIS Cloud as a service with ready to use QGIS webclient. It’s very easy to publish data and share maps in this way. Publishing of georeferenced images can be done with QGIS Cloud in a few steps as well. But the main problems are: how to upload the images into the cloud database? how to manage them? how to display the results? QGIS and QGIS Cloud are offering all tools for this task.
Learn More

Using Presets, multiple styles, Atlas with overview map

Our training courses are structured to give trainees step-by-step guide using the latest QGIS features. Here is an example of one our practicals for creating professional maps.

Trainees will learn how to

  • Assign multiple style to a layer
  • Working with presets
  • Working QGIS print composer
  • Generating maps using Atlas

Creating professional maps with the Print Composer

QGIS’ Print Composer allows users to create professional maps for printing. It supports legends, frames, logos and all the other features you’d expect to see in a print quality map.

In this example, we’ll use some of the most common features required to generate a map for printing.

We’ll first load the electricity usage data created in another tutorial, style it using a simple colour ramp, then create a new map composer complete with title and legend.

Loading data in QGIS

The styling of a vector layer can be performed using a single style, or a varying style, based on the value of one or more attributes. We are going to first load the London energy usage layer prepared in an another tutorial by joining electricity usage with the LSOAs vector layer.

Start a new QGIS project

Add the MSOA_GL_ElecUsage.shp layer under extracted
downloaded folder

The vector layer should now look like the figure below.

Energy consumption in London Energy consumption in London

Next, we are going to add a shapefile of London Boroughs to identify areas of high and low usage.

Add London_boroughs.shp from extracted downloaded
folder

Open layer properties and under Style:

Set the style of the polygons to "No Brush" with a
"Dash Line".

Styles for London Boroughs vector layer (Click to enlarge)

Your map now should look like the figure below:

Energy consumption in London Energy consumption in London

In QGIS, you can apply multiple styles to a single layer. Using this method, we do not need to load the same layer multiple times. In this case, we need two styles for London boroughs layer:

  1. Without labels (as created above); to be used as an overview map

  2. With labels (next section); for the main map

We can save the current style (without label):

Right-click on London_boroughs layer from the layer
tree and select Styles > Add

For the new style, type 'no label' and click OK

We can save the new styles (with labels) for the layer:

Right-click on London_boroughs layer from the layer
tree and select Styles > Add

For the new style, type 'with label' and click OK

Changes in the next section (adding label) will be saved in with label style.

Labels

We’ll now add labels to each of the boroughs. The name of each borough is stored as the value of the NAME attribute.

Click on the London_boroughs layer in the ToC

Form the main menu, select Layer > Labelling

This window will allow us the set an attribute for label and also change font, size, rotation, buffer, etc.

Setting up labels on the London boroughs layer Setting up labels on the London boroughs layer

Enable the Label this layer with option

Set Field with labels to NAME

Under Text section, set the font to 7 pt

Under Buffer section:

  Enable Draw text buffer

  Set the Size to 0.5 mm

Click OK

You should now be able to see a label for each borough.

London boroughs with labels London boroughs with labels

Presets

In QGIS, you can create presets for layer visibility and styles. In this example we are going to create the following presets:

  • Map of LSOAs with the energy usage and borough boundaries

  • A separate preset for the London boroughs (without labels) which will be used as an “overview” for the print composer

To create the first preset:

Ensure both layers are visible

Right-click on London_boroughs and select
Style > with label

On top of the legend tree in QGIS, you can see the icon for Manage Layer Visibility image

Click on the Manage Layer Visibility icon

From the drop-down menu, select Add preset...

For the Name of the new preset insert Energy map

Click OK

To ensure the preset has been correctly set, you can change the visibility of the layer, or change the style, and select the preset from the Manage Layer Visibility menu.

To create the second preset:

Hide All Layers from Manage Layer Visibility or simply
press Ctrl+Shift+H

Turn on the visibility for London_boroughs

Right-click on London_boroughs and select
Style > no label

On top of the legend tree in QGIS, click on
Manage Layer Visibility

From the drop-down menu, select Add preset...

For the Name of the new preset insert overview map

London boroughs - without labels London boroughs

Now you should be able to switch between those two presets, and later use them as print composer frames.

Creating layout

The map is almost ready to be printed. Before printing, we’ll need to add a border, logos, legends, scale, etc.

There are quite a few steps involved in configuring the print composer so it’s recommended to regularly save your progress by saving the QGIS project.

From the main menu, select File > New Print Composer

A new window will appear for Composer title

Type Energy usage in London

The print composer title window The print composer title window

The print composer will appear. See Figure.

PrintComposerWindowEmpty The print composer window

The print composer is split into two sections. Section 1 shows the map to be outputted and section 2 shows the settings for selected items in section 1.

The map we are going to produce is an A4 landscape PNG file.

In section 2, under Composition, for Presets, select
A4(210 x 297 mm)

Now we need to add frames for the map extent and legend sections. You can add a rectangular shape by clicking on image from the main toolbar.

From the main toolbar, add a new rectangle

Click and drag a shape in section 1

Now let’s change the position and size of the rectangle:

Ensure the rectangle shape is selected in section 1

Click on Item properties in section 2

Under Shape, select Position and size

Set the option as shown in Figure

Shape options Shape options

Add second, third and fourth rectangles with the
following information

Rectangle 2:

  X: 270

  Y: 145

  Width: 43.5

  Height: 60

  Reference Point: Centre

Rectangle 3:

  X: 270

  Y: 95

  Width: 43.5

  Height: 60

  Reference Point: Centre

Rectangle 4:

  X: 270

  Y: 105

  Width: 43.5

  Height: 200

  Reference Point: Centre

Lock the position of each window by right-clicking
on each of them

Section 1 of the print composer should look like this:

The print composer with placeholders layout The print composer with placeholders layout

Adding image

Let’s add the logos.

From the main menu, select Layout > Add Image

Click within the middle rectangle on the right

An empty box will appear

In the right-hand panel (section 2), under the
Item properties tab,

	click on Main properties button

For Path, click on ... and browse to the folder where
your images are located.

Select an image

You should now see something similar to the image below.

Logos added to the composer Logos added to the composer

Adding text

Now we’ll add some text in the rectangle below the logos:

From the main menu, select Layout > Add Label  

Click somewhere within the lower right-hand box  

A new text box will appear, reading QGIS.

From the right-hand panel, click on Item properties

In Main properties, change the text to refer to the
source of the data and copyright notices.

Copyright notices Copyright notices

Adding map

Now we’ll add the map from the QGIS canvas.

From the main menu, select Layout > Add map

Drag a box in the main window

A map similar to the image below should now appear in the print composer.

To finalise the main map window, a few more changes will need to be made.

Adding map to the print composer Adding map to the print composer

From the right panel, click on the Item properties tab

  Under the Main properties, set the following values:

    Tick the box for Lock layers for map item see
image below

  Under Extents:

    Tick the box for Controlled by atlas

Adding a preset for map view Adding a preset for map view

Add scalebar

To add a scalebar:

From the main menu, select Layout > Add Scalebar

Adding a scalebar to the map Adding a scalebar to the map

A scalebar with default settings should appear on the map. See Figure [PrintComposerAddScalebar]. To change the scalebar:

Select the scalebar from the map

Click on Item Properties from the left-hand panel

Under Segments

   Set left 0 and right 2

   Set Size to 1000

   Set Height to 2 mm  

Adding legend

Next, we’ll add a legend:

From the main menu, select Layout > Add Legend

Click somewhere within the upper right-hand box

QGIS will automatically add a legend for all the layers loaded in the canvas. We can edit the legend’s settings and remove the legend entries that we do not want to show. Manual edits of the legend text can also be performed to make it more readable.

To be able to edit the legend items, you first need to untick the box for Auto update. Use icons under the Legend items to edit or change the order of the items.

The default legend The default legend

From the right-hand panel, click on the Item properties

  Under Legend items:

    Select London_boroughs and then click on the red
    minus sign


    Select MSOA_GL_ElecUsage and click on the edit
    sign, a new window will appear.

    Change the content of Item text to Electricity
	Usage

    Click on the first value 2576.2400 – 3000.0000
	and select edit sign to change the range to
	2000 – 3000   

    Repeat for the rest of the values to round them
	and remove any unwanted zeros.   

Editing legend values Editing legend values

Map with legend Map with legend

Add overview

To add an overview:

Add a new map (Map 1) to the place-holder between
the map legend and the logos

For Map 1, from the Item properties,

Under Main properties

   Select Lock layers for map item

   From the visibility preset, select overview map

Under Overviews tab  

   Click on the plus sign,
	Overview 1 should be added to the overview list

   Ensure Draw "Overview 1" overview is selected

   For Map frame, select Map 0

Setting the preset view for the overview map Setting the preset view for the overview map

The map is now almost ready. You can export it as PNG or a PDF. Or you can keep reading for even more excitement!

The completed map The completed map

Atlas generation

The map is now ready to be printed or outputted as an image. But, we are going to use this layout as a template and auto-generate energy consumption for each borough.

To set the coverage (this is already set, but make sure the option is enabled):

While Map 0 (the main map) item is selected, click on
Item properties from the right-hand panel

Select the option for Controlled by atlas generation

You can change the Margin around feature if you like, but we can keep at 10%. Further settings are also required:

Click on Atlas generation tab from the right-hand panel

Tick the box for Generate an atlas

Under Configuration, for Coverage layer select
	London_boroughs

Under Output, for Output filename expression type:
	'energy_'|| "NAME"  

The expression for output will set the name of each output file. In this example we are going to have a name with ‘energy_‘ combined with the value of NAME column (what do you think this value is?)

To generate the maps:

In the print composer, from the main menu, select
Atlas > Export Atlas as Images...

Select a folder to output maps and press Choose

The process may take a while but you will eventually have 33 maps of the energy consumption for each borough. Note the overview for the maps and also the naming of the output files. See Figure beloq as an example of the maps created.

Final energy map for Kingston upon Thames generated by the Atlas Final energy map for Kingston upon Thames generated by the Atlas

You may also like...

Mergin Maps, a field data collection app based on QGIS. Mergin Maps makes field work easy with its simple interface and cloud-based sync. Available on Android, iOS and Windows. Screenshots of the Mergin Maps mobile app for Field Data Collection
Get it on Google Play Get it on Apple store
Learn More