Related Plugins and Tags

QGIS Planet

QGIS Server Debug Tip

Sometimes is hard to debug segfaults appearing in QGIS Server when running in CGI mode. The classic approach is attaching a gdb to the running process. The problem is that there is not enough time to do it! A simple plugin filter, can provide you the time you need to attach the debugger:

from qgis.server import *
from qgis.core import *
import os
     
class DelayFilter(QgsServerFilter):
     
    def __init__(self, serverIface):
        super(DelayFilter, self).__init__(serverIface)    
     
    def responseComplete(self):        
        request = self.serverInterface().requestHandler()
        params = request.parameterMap()
        if params.get('DELAY', ''):
            QgsMessageLog.logMessage("PID: %s" % os.getpid())     
            import time
            time.sleep(30)
Calling the server with DELAY=1 will wait for 30 seconds and print the current PID in the server logs. This will give you enough time to fire gdb and attach it to the process.

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!

Crowd funding project for reading CAD documents in QGIS

Local governments on the municipality or provincial level often have to deal with DXF/DWG/DGN documents delivered from architects, urban planners or engineering companies. As an example, cadastral or utility offices or companies often have to import CAD documents to either check deliveries about correctness or import selected objects into their central database. Another requirement is being able to visualize planned objects, such as buildings or bridges alongside with the cadastral data.

QGIS lacks proper import of CAD data so far – DXF files can only be imported on very basic levels (without styling and labeling), DWG files can’t be imported at all.

A requirements document has been written to implement import of DXF/DWG (and potentially also DGN) files into QGIS, while maintaining styling, labeling, 3D, curves and blocks.

The company Norbit, with Jürgen Fischer, submitted an offer. Jürgen is a long-term QGIS developer and QGIS.ORG board member. Norbit has extensive experience with bridging GIS and CAD.

The plan is to use the Teigha library of the OpenDesign Alliance (ODA) to read the CAD documents. Either QGIS.ORG or OSGeo would become a member of the ODA, to get access to the source code and for distributing the Teigha libraries with QGIS binaries.

At this time we are looking for organisations or companies that help funding the effort. The offer from Norbit is over 32k €. We are looking for institutional crowd funders with minimum contributions of 1k Euros. If you are interested in contributing, please contact by mail at andreas (at) qgis (dot) org. We can send you an invoice for your contribution.

Addition: if you want to do smaller, targeted donations, please use the regular donation channels and mention “CAD import” in the payment instructions.

 


How to label only selected features in QGIS 2.8 and up

In 2011, I wrote “How to Label Only Selected Features in QGIS” which ends with the wish that

Another “data defined setting” like “show this label (true/false)” would be more intuitive.

… and now we have it!

It’s called Show label and you can find it in the Rendering section of the labeling dialog.

The following screenshot shows a quick example of how to label only airports starting with A by setting the expression

"NAME" LIKE 'A%'

labelselected

This post was motivated by a question by Eduardo here on this blog. Hope it helps!


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)

 

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)

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.

How to create connectivity-based line caps

It’s been a while since my last blog post mostly because I’ve been busy with some more long form writing. Most notably, I’ve been writing a paper on the QGIS Projcessing framework in the open access ISPRS International Journal of Geo-Information together with Victor Olaya and I’m still in the process of writing a new book titled “QGIS Map Design” together with Gretchen Peterson which is scheduled for early 2016.

Today’s post has been on my todo list for a while now. It’s inspired by a talk at a recent cartography conference I attended:

(For a summary of the whole event, check the storify I compiled.)

The idea of this slide and several more was to show all the attention to detail which goes into designing a good road map. One aspect seemed particularly interesting to me since I had never considered it before: what do we communicate by our choice of line caps? The speaker argued that we need different caps for different situations, such as closed square caps at the end of a road and open flat caps when a road turns into a narrower path.

I’ve been playing with this idea to see how to reproduce the effect in QGIS …

So first of all, I created a small test dataset with different types of road classes. The dataset is pretty simple but the key to recreating the style is in the attributes for the road’s end node degree values (degree_fro and degree_to), the link’s road class as well as the class of the adjacent roads (class_to and class_from). The degree value simply states how many lines connect to a certain network node. So a dead end as a degree of 1, a t-shaped intersection has a degree of 3, and so on. The adjacent class columns are only filled if the a neighbor is of class minor since I don’t have a use for any other values in this example. Filling the degree and adjacent class columns is something that certainly could be automated but I haven’t looked into that yet.

roadattributes

 

The layer is then styled using rules. There is one rule for each road class value. Rendering order is used to ensure that bridges are drawn on top of all other lines.

roadrules

Now for the juicy part: the caps are defined using a data-defined expression. The goal of the expression is to detect where a road turns into a narrow path and use a flat cap there. In all other cases, square cap should be used.

roadrule

Like some of you noted on Twitter after I posted the first preview, there is one issue and that is that we can only set one cap style per line and it will affect both ends of the line in the same way. In practice though, I’m not sure this will actually cause any issues in the majority of cases.

I wonder if it would be possible to automate this style in a way such that it doesn’t require any precomputed attributes but instead uses some custom functions in the data-defined expressions which determine the correct style on the fly. Let me know if you try it!


A new QGIS plugin allows dynamic filtering of values in forms

   

This plugin has been partially funded (50%) by ARPA Piemonte.

Description

This is a core-enhancement QGIS plugin that makes the implementation of complex dynamic filters in QGIS attribute forms an easy task. For example, this widget can be used to implement drill-down forms, where the values available in one field depend on the values of other fields.

Download

The plugin is available on the official QGIS Python Plugin Repository and the source code is on GitHub QGIS Form Value Relation plugin repository

Implementation

The new “Form Value Relation” widget is essentially a clone of the core “Value Relation” widget with some important differences: When the widget is created:
  • the whole unfiltered features of the related layer are loaded and cached
  • the form values of all the attributes are added to the context (see below)
  • the filtering against the expression happens every time the widget is refreshed
  • a signal is bound to the form changes and if the changed field is present in the filter expression, the features are filtered against the expression and the widget is refreshed

Using form values in the expression

A new expression function is available (in the “Custom” section):
CurrentFormValue('FIELD_NAME')
This function returns the current value of a field in the editor form.

Note

  1. This function can only be used inside forms and it’s particularly useful when used together with the custom widget `Form Value Relation`
  2. If the field does not exists the function returns an empty string.

Visual guide

  Download the example project.   This is the new widget in action: changing the field FK_PROV, the ISTAT values are filtered according to the filter expression.
The new widget in action

The new widget drill-down in action

layer_config_fields

Choosing the new widget

Configuring the widget

Configuring the widget

Configuring the expression

Configuring the expression to read FK_PROV value from the form

GRASS GIS 7.0.2 released

What’s new in a nutshell

The new GRASS GIS 7.0.2 release provides 190 stability fixes and manual improvements.

About GRASS GIS 7: Its graphical user interface supports the user to make complex GIS operations as simple as possible. The updated Python interface to the C library permits users to create new GRASS GIS-Python modules in a simple way while yet obtaining powerful and fast modules. Furthermore, the libraries were significantly improved for speed and efficiency, along with support for huge files. A lot of effort has been invested to standardize parameter and flag names. Finally, GRASS GIS 7 comes with a series of new modules to analyse raster and vector data, along with a full temporal framework. For a detailed overview, see the list of new features. As a stable release series, 7.0.x enjoys long-term support.

Source code download:

Binaries download:

More details:

See also our detailed announcement:

  http://trac.osgeo.org/grass/wiki/Grass7/NewFeatures (overview of new 7.0 stable release series)First time users may explore the first steps tutorial after installation.

About GRASS GIS

The Geographic Resources Analysis Support System (http://grass.osgeo.org/), commonly referred to as GRASS GIS, is an Open Source Geographic Information System providing powerful raster, vector and geospatial processing capabilities in a single integrated software suite. GRASS GIS includes tools for spatial modeling, visualization of raster and vector data, management and analysis of geospatial data, and the processing of satellite and aerial imagery. It also provides the capability to produce sophisticated presentation graphics and hardcopy maps. GRASS GIS has been translated into about twenty languages and supports a huge array of data formats. It can be used either as a stand-alone application or as backend for other software packages such as QGIS and R geostatistics. It is distributed freely under the terms of the GNU General Public License (GPL). GRASS GIS is a founding member of the Open Source Geospatial Foundation (OSGeo).

The GRASS Development Team, November 2015

The post GRASS GIS 7.0.2 released appeared first on GFOSS Blog | GRASS GIS Courses.

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.

Create a new spatialite layer with QGIS:

As the first step we need to create a point layer with some mandatory columns.

  • Open the New Spatialite Layer dialog with Layer -> Create Layer -> New Spatialite Layer
  • Create in minimum three columns :
    • name text
    • filename text
    • image text
  • name the new layer images

Create_Spatial_lite_Layer

Create a new dialog with QtDesigner which looks like in the image below.

For adding and managing the images a customized input GUI is needed.

  • add two QLineEdit Widgets and name them with the corret objectName
  • add two QTextEdit Widgets and name them with the corret objectName
  • add a QToolButton Widget with the corret objectName

  • or download the file attribute.ui

QtDesigner

  • Open the layer properties of layer images and open the section fields.
  • Select from “Attribute editor layout”: Provide ui-file
  • To get the custom UI select the path to attribute.ui in “Edit UI” and open the gui.
  • Click OK

Create a Python init function for handling the image data.

When you add a new feature to the layer images, the dialog opens but the tool button is not working. To get it working we need some Python code.

The idea behind that is to run some functionality to convert the binary image to text based base64 encoding. Let’s Python doing that job for us. QGIS offers the ability to define an init function when a custom dialog is opened. This offers a wide range of options.

  • create a new text file and call it encodeimage.py
  • add the following Python code (or download the Python script encodeimage.py):

Import all nesseccary Modules and Classes from PyQt4 and QGIS

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import QgsFeature,  QgsMapLayerRegistry
import base64

Define some global variables

filePathField = None
imageField = None
imagePreview = None
toolButton = None
fileName = None

This is the main function which will be connected with the QGIS layer dialog

def formOpen( dialog, layer, featureid ):

    global filePathField
    global imageField
    global imagePreview
    global toolButton
    
    filePathField = dialog.findChild(QLineEdit, "filename")
    imageField = dialog.findChild( QTextEdit, "image" )
    imagePreview = dialog.findChild( QTextEdit, "imagePreview" )

Find the QToolButton Object to connect the conversion function.

    toolButton = dialog.findChild( QToolButton, "toolButton" )

When the ToolButton is clicked run the method getFileName()

    toolButton.clicked.connect(getFileName)

set the imageField Widget invisible for a nicer GUI. It is not nesseccary to see the data

    imageField.setVisible(False)
    imagePreview.setText('<img width="300" src="data:image/jpg;base64,'+imageField.toPlainText()+'"/>')

Open FileDialog and convert the binary image to base64

def getFileName():
    filePath = QFileDialog.getOpenFileName(None,  'Open Image File',  '',  '(Images *.jpg *.png)')

    if len(filePath) > 0:
        filePathField.setText(filePath)
        encodedImage = ''

Read the image file and proceed the encoding

        encodedImage = base64.b64encode(open(filePath, 'rt').read())

Set the appropriate fields for storing in the QGIS layer

        imageField.setPlainText(encodedImage)

Set HTML img tag around the base64 image

        imagePreview.setText('<img width="300" src="data:image/jpg;base64,'+encodedImage+'"/>')

If you have finished editing, save this file in the same directory where your QGIS project file is stored. As the final step to connect the layer images with the Python module you have to define the Python init function in the layer properties of the layer images. Add encodeimage.formOpen to the Python init function definition. The Fields definition of the layer properties of layer “images” should look like

layer_properties

Now you are able to add images and photos to your spatialite database table. But be careful because the main disadvantage of this approach is the size of the image. The conversion of a 5Mb image produces a huge base64 string. As the result it will be very wise to reduce the size of the images you want to add to the layer. If you like, you can add a check of image size to the Python module.

A nice tool of the QGIS map canvas is the option to add maptips to a layer. When maptips are activated images should be visible when the mouse moves over a feature of the layer images in the map.

Create a maptip with image as content

  • open the layer properties of the layer images and jump to the Display section.
  • tick the HTML radio button.
  • add the HTML code to the Text field as you can see in the figure below:
  • close the dialog with OK
  • activate the maptip tool in QGIS and move over a feature of the layer images. The ame and the image are popped up.

layer_properties

Share your images with QGIS Cloud

What’s about to share the pictures and the geolocation of the pictures with others over the web. For this task QGIS Cloud is the right choice. QGIS Cloud is your personal spatial data infrastructure and offers OGC Web Services and ready preconfigured Web GIS clients.

  • save the project.
  • open the QGIS Cloud plugin (If you don’t have the QGIS Cloud plugin installed, than install it from the official QGIS Plugin Repository)
  • log in your QGIS Cloud account. (If you don’t have a QGIS Cloud account, sign up a new account).
  • upload the local data to your QGIS Cloud database (if you don’t have a QGIS Cloud database, create one from the QGIS Cloud plugin).
  • publish the project via QGIS Cloud plugin.
  • open the map in QGIS Cloud Web Client
  • activate the identify tool and move over a point with image
  • here you are, it works

result

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

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

A word of thanks to the hosts of the 14th QGIS Hackfest in Gran Canaria

Last weekend (November 5th – November 8th, 2015) was a special occasion for the QGIS Project – we convened the 14th our ‘hackfest’ meeting!

QGIS hackfests are events where an organiser provides a space for collaboration and members of the community converge and self-organise to improve the QGIS project. We are very much dependent on the good will of our hosts – typically universities – for providing these spaces and the logistics needed to manage the provision of accommodation, food, internet and other needs of our participants over the duration of the hackfest. For this event our gracious hosts were Universitas de Las Palmas de Gran Canaria. Our presence at the University was endorsed and facilitated by:

  •  Rector of ULPGC: José Regidor García
  •  ULPGC Manager: Conrado Domínguez Trujillo
  •  CIO of ULPGC and Director of OSL (“oficina de software libre”, or Free Software Office): Jose Pablo Suárez Rivero.
  •  Councilor of New Technologies Area, Public Administration and Sports at Las Palmas de Gran Canaria Town Hall:  Aridany Romero Vega
  •  Senior professor of computer Science: Agustín Trujillo Pino
The local coordination team was headed up by Pablo Fernández Moniz (CTO and GIS Analyst). Pablo did an amazing job in pulling all the strands together making the event happen! He was assisted by an awesome team of helpers, and participants:
  • Design: Ramsés Cabello Developer (staff at the event): Jaisiel Santana Almedia
  •  Developer (staff at the event): Alejandro Sánchez Medina
  •  Developer (staff at the event): Chano OrtegaTrujillo
  •  Developer (staff at the event): Moises Bonilla

Our heartfelt thanks to all of the people who worked so hard to make this event happen, and to the participants who travelled from far and wide to attend the event. These events are a significant factor in the success of the QGIS project – they allow our developers and contributors to meet face to face and delve deep into technical issues that would be impossible to do under the somewhat disconnected collaboration environment provided by the internet.

Key Activities

There were just under 30 people in attendance at the hackfest – here are just a few of the activities that they were busy with during the hackfest:
  • Qt5 / Python 3 proof of concept by Matthias Kuhn
  • Topological editing with GRASS plugin (Radim Blazek) – video (not from event)
  • Geoserver explorer plugin (Luigi Pirelli)
  • General discussion and planning for the improvement of contribution workflows (pull requests, tickets, QEPs) and infrastructure (Redmine)
  • Improvement of analysis tools (ftools, processing) and their documentation
  • General bug fixes (Jürgen Fischer)
  • Improvements to the QGIS.org website (Richard Duivenvoorde and Anita Graser)
  • Implementation of a GitHub webhook to insert a ‘[FEATURE] issue’ so that documenters know to document new features as they are added to QGIS (Richard Duivenvoorde and Raymond Nijssen)
  • Processing support for loading Oracle data via OGR (Giovanni Manghi)
  • Launched the Italian QGIS User Group, updates to the  documentation of Lizmap web client, managed the Italian translation, the python plugin queue (Paolo Cavallini)

QGIS Sponsorship

Many of the costs not covered by our hosts were covered from central QGIS.org funds including food and travel costs for a number of participants. These funds originate from our donors and sponsorships and are an invaluable resource for the project to allow us to facilitate these events and move the development of QGIS forward. We encourage you to donate to the QGIS or become a sponsor if you would like to foster further innovation and support the long terms goals of the project.

More Information

If you would like further information about what was covered in the event, and to get a feel of the general atmosphere of the event, check out some of these links:

I will update the list above as more reports backs become available.

Thanks

With thanks from your project chair and the whole QGIS community,

timsutton


QGIS Podcast Episode 12

In the 12th episode of the QGIS podcast, Tim Sutton and Victor Olaya talk about what they have been doing during the latest QGIS developer meeting, present the latest QGIS enhancement proposals (QEPs), chat about the Processing framework and much more!

Listen to or download it at http://qgispodcast.libsyn.com/qgis-podcast-episode-12-processing-with-victor-olaya


News from QGIS HackFest in Las Palmas

First I wish to thank Pablo & friends for the amazing organization, unfortunately I couldn’t spend more than two full days there, but those two days have been memorable! Here is a picture of one of the most interesting discussions (photo: courtesy of Pablo). QGIS discussion at the developer meeting in Las Palmas An hack fest is an event for writing good code but what it’s really good at is to establish and cultivate relations with other coders, to exchange opinions and ideas and last but not least to have some fun and make new friends.   This time, we have had many interesting presentations and a couple of meetings where we spoke about technical aspects of the project management and infrastructure and about some important challenges, both in terms of code size and economical implications for who relies on it, that a growing project must face.   The latter was something I’ve also been considering for a while: now that pull requests (PR) for new features are coming down the pipeline, we must find a better way to manage their queue by giving a clear and transparent approval path and deadline. This management and approval process cannot rely entirely on volunteer work, the main reason being that most of the times the PR proposers have been paid for that PR and it’s not fair (nor reliable) that the (sometimes hard) job of doing a code review is not rewarded. On the other end, an investor cannot waste its time and money on a project without having a reasonable good chance to see its work eventually land into the core of QGIS.   Hugo (thanks for that!) organized a meeting to discuss this topic, that crosses personal business interests, ethical considerations and personal beliefs to a point that it’s not really easy to discuss in a calm and objective way, despite the premises, the discussion was very interesting and constructive and a QEP that tries to address at least some of this problems is open for discussion right now: https://github.com/qgis/QGIS-Enhancement-Proposals/issues/52   Another topic we’ve been discussing was how to manage python plugin dependencies, we’ve decided to start by adding a new metadata tag called external_deps that’s supposed to contain the PIP install string for the required packages, since PIP will be a builtin in python 3.4, that will probably solve most of our problems when we’ll integrate that into the plugin manager. At the moment the metadata is not documented nor required, but it’s there to allow for experiments.   We didn’t miss the occasion to talk about the ugly bug that affects fTools, not something I’m going to dig into in this post though.   Of course an hack fest is still a good opportunity for squashing bugs and implement new cool features, I’ve been busy mainly on the following topics:

  1. HiDPI screen support for web view widgets (help and plugin manager/installer)
  2. Form relations editing longstanding bugs
  3. New feature to optionally enter, edit and store Python form init code into the project (and DB), see the picture below
  4. Plugins website maintenance (added new metadata and fixed a few bugs, added an RPC call to export author email for admins)
New QGIS feature to store form init code   Thanks to all participants, to the organizers and to all QGIS sponsors and donors that made this possible!  

Your donations/sponsorships help to maintain and improve the quality of QGIS

The QGIS project is growing in size, number of contributors/contributions and code complexity. This introduces challenges for the project, especially for maintaining quality. Maintaining and improving quality is one of the main concerns of the QGIS.ORG board and some core developers.

Past and current QA efforts

Tim Sutton introduced a first unit test framework several years ago. But it wasn’t very visible then and passing the tests as a prerequisite to make changes to master wasn’t enforced. About a year ago, Matthias Kuhn introduced automated unit testing for the Linux builds – using Travis continuous integration testing. At our github page you can always see whether the master version builds fine and whether the tests are passing – see the green “Build passing” button at the beginning of the Readme.md file.

Since then, OS X automated building/testing was added. Pull requests (new contributions from developers) can be tested prior to integration into the master branch. Another effort was to use coverity code scans to detect memory leaks. Nyall Dawson and others did a lot of improvements/fixes due to this automated code scans.

Upcoming challenges

There is still a lot to do regarding quality and automated testing. Because continuous integration tests were only introduced about a year ago, it means that still a lot of areas in the code base remain untested. Also, the current unit tests do not test GUI interactions. There is an ongoing discussion if critical classes should have unit tests enforced for any code changes. Finally, our bug queue at http://hub.qgis.org/projects/quantum-gis/issues is still quite long, with lots of bigger and minor issues.

Your financial support really matters!

This is where your donations and sponsorships come in. For the past 3-4 releases we were able to pay 2-4 developers who worked for several days concentrating on bug fixing. For QGIS 2.12 we had Nyall Dawson, Jürgen Fischer and Larry Shaffer working on bug fixing. We also financially support Giovanni Manghi for working on our bug tracker (e.g. classifying issues correctly, trying to reproduce the issue, ask bug reporters for more details).

Now – you may wonder why they didn’t fix all the “BLOCKER”s first and then continue on with “HIGH”, “NORMAL” “LOW”  issues – and why a lot of unreported issues and issues with label “LOW” were also fixed? The answer is that it is often more efficient for the developers to concentrate on a certain part of the code – e.g. concentrating on geometry, labeling and editing issues, as Nyall did for this round of bug fixing. This means that he would not only fix issues labeled as “BLOCKER” or “HIGH” but also other bugs that are in the same code. Finally, not all of the “Blocker” and “High” bugs are reproducable or the issue may be much too hard/time consuming to fix.

Due to your financial support, the 3 developers were able to fix the following list of issues for the QGIS 2.12 release – many of the fixes also get back-ported to QGIS 2.8 LTS release:

  • Sweep of all changed dialogs, ensuring tab order is correct
  • UNREPORTED: Only save effect element if it is non-default (decreases size of qgs project files)
  • HIGH: Fix map rotation not considered for ellipse marker data defined rotation (#13367)
  • HIGH: Maintain order of recent expressions (#13461)
  • NORMAL: Make sure recent expression group is always listed last (#13462)
  • NORMAL: [diagrams] Fix initial value of transparency slider not set (#13434)
  • UNREPORTED: Fix potential crashes in renderer widgets
  • NORMAL: Fix legends are empty if presets used with filtered legend (#13300)
  • UNREPORTED: Fix crashes and inconsistent ui when atlas is set to a geometryless layer
  • BLOCKER: Fix diagrams are always shown, regardless of setting (#13501)
  • BLOCKER: Fix fill ring tool used with advanced digitising crashes QGIS (#13355)
  • NORMAL: Fix add ring/fill ring tool works on first polygon (#13069)
  • BLOCKER: Fix missing sip bindings for renderers (#13545)
  • BLOCKER: Fix crash in label property dialog (#13543)
  • NORMAL: Fix hardcoded border for raster legend items (#13540)
  • BLOCKER: Fix symbols drawn multiple times in rule based renderer if symbol (#13220)
  • BLOCKER: Use a model for node editor table, fixed hang when node tool used on large feature (#13541)
  • BLOCKER: Fix node tool duplicates nodes when topological editing and snap are both enabled (#13466)
  • NORMAL: Fix broken data defined SVG marker outline width (#13423)
  • HIGH: Scale svg marker outline width to match context (#11522)
  • HIGH: Allow coloring of svg markers and svg fills when used with graduated/categorised renderers (#11658)
  • HIGH: Fix svg outline widths are incorrectly scaled (#11522)
  • UNREPORTED: Fix snapping options dialog not correctly initialised when loading projects
  • UNREPORTED: Fix uninitialized variables in advanced digitizing dock which meant that sometimes advanced digitising tools would be activated unexpectedly
  • NORMAL: Fix curved labels ignore line orientation placement flag (#5778)
  • UNREPORTED: [console] Move run button earlier in console editor toolbar (prevents it being hidden in overflow menu on small screens)
  • UNREPORTED: Fix fill and outline color for svg markers sometimes enabled even though SVG file does not support parameters
  • UNREPORTED: Fix svg marker colors not correctly restored from project
  • UNREPORTED: If svg files with params do not have a default value set, then don’t reset the fill/border color and border width when changing svg marker/svg fill SVG files (made the behaviour consistent between the svg marker and the other marker symbols)
  • NORMAL: Fix svg symbols are shown in white and hard to see in svg picker (#10908)
  • NORMAL: Fix refining rule based renderer using expression (#10815)
  • UNREPORTED: Fix crash when changing symbol types on windows
  • BLOCKER: Fix split parts tool only leaves one of the newly created parts (#13421)
  • BLOCKER: Fix using add part tool to add part to geometryless rows (#12885, #11319)
  • UNREPORTED: Fix some potential crashes with edit tools and null geometry
  • UNREPORTED (thought I’d submitted this years ago but can’t find the issue now): Allow adding features with empty geometry via attribute table
  • HIGH: Allow delete part tool to remove geometry from single type point and line layers (#13258)
  • LOW: Fix overview canvas background color not set (#11157)
  • Add some unit tests for QgsWKBTypes
  • NORMAL: When adding ring to a geometry, add z or m dimensions to the ring geometry if required (#7400, #7401)
  • NORMAL: Also show features with modified geometry when “show edited and new features” filter is active in attribute dialog (#11684)
  • BLOCKER: Fix broken apply button in label config dialog (#13543)
  • BLOCKER: Fix area calculation when OTF active and no ellipsoid, add unit test (#13601)
  • UNREPORTED: Fix exporting geometry collections to WKT would result in invalid WKT
  • UNREPORTED: Fix unable to import WKT using MultiPoint(1 1,2 2,…) format
  • UNREPORTED: Fix GeometryCollection WKT to support collections with multi* children and GeometryCollection children (allowed by spec)
  • Add a bunch of unit tests to geometry
    – UNREPORTED: Fix calculation of area and length of mixed geometry collections
  • UNREPORTED: Fix geometry casting in python bindings (missing MultiLineString and GeometryCollection casts)
  • UNREPORTED: Fix calculation of length/perimeter for geometry collections
  • UNREPORTED: when creating geometry from WKT, upgrade dimensionality of geometry if coordinates are 3/4 dimensional
  • UNREPORTED: match dimensionality of collections to child dimensionality
  • UNREPORTED: fix area of curves was non-zero if curve is closed
  • UNREPORTED: don’t consider m values when testing for curve closedness
  • NORMAL: Fix merge attributes tool sets skipped attributes to null (#13231)
  • NORMAL: Add skip all option to merge attributes dialog (#6958)
  • UNREPORTED: Fix QgsStatisticalSummary sometimes returning 0 for StDevSample stat
  • UNREPORTED: Fix storing string representations of doubles in an int field results in NULL rather than converting value to int
  • NORMAL: Fix merge attributes/features tool resets values to null for int fields and add a warning if merged attribute value is not compatible with field type (#12842)
  • Fix a LOT of leaks relating to geometry and GEOS operations, labeling
  • UNREPORTED: [pal] Fix regression in placement for free/horizontal polygon labels
  • Add tooltips to advanced digitizing dock
  • Fix a crash in filtered legends
  • Reviewed and merged several bug fix PRs
  • #13433: Help text for rpad and lpad in field calculator are mixed up
  • #13417: missing libqgis_app.so
  • #13420: Strange behaviour of newly ‘saved as’ project
  • #13463: Identify Results panel always show newly created features in the list
  • #13538: PostGIS tables containing MultiPolygonZ crash QGIS master
  • #13546: qgis trying to update first empty text row with null in db
  • #13027: Join by location does not work when layers have equivalent field names
  • #13032: Save as… fails to populate fields if layer has similar names only different by case
  • #13052: Problem with reshape
  • #10747: Cannot copy/paste points features
  • #13506: Processing help files for QGIS algs all dead now
  • #13274: API combine method for geometry
  • #11755: Real precision (Shapefile)
  • #9208: QGIS crashes when using addAttributes on any vector data provider
  • #13579: Crash Dump 2.11 with user defined expressions
  • #10515: QGIS Crash when trying to load a point layer to georss file
  • #11276: Setting radius units to meters produces incorrect results
  • #13641: editing a feature in a PostGIS layer does not work when the PK contains NULLs
  • #13631: when ELSE rule exists in Styling, all Labels are rendered regardless of styling groups being active/inactive
  • #13638: Cannot load emptry Postgis views
  • #8255: in edit mode changing primary key discards geometry modifications
  • #13594: DB Manager – unable to add a Postgres/PostGIS raster as layer
  • #13446: MYSQL Project File
  • #13310: nightly build packages failing to install with grass error
  • (PR#2378: Allow postgis layers from queries to have multiple column primary keys)
  • (PR#2376: the test for uniqueness now also works for multiple columns by SebDieBln)
  • (#13645: ftools “line intersection” crashes qgis)
  • (#13646: Merge shapefiles from fTools crashes QGIS)
  • transifex updates & german translation
  • attribute editing: don’t allow editing without ChangeAttributeValues capability
  • vector layer: avoid some crashs when methods are called on invalid layers
  • oracle provider: fix call of sdo_filter to verify a spatial index is present
  • #13641: postgres provider: verify unique constraint if NOT NULL is not set on key columns (shortly after release)
  • Commit 6a4544f fix fetching of redirected wms capabilities (followup e95bf6d)

Getting multipolygon vertexes using PostGIS

EN | PT

Today I needed to create a view in PostGIS that returned the vertexes of a multi-polygon layer. Besides, I needed that they were numerically ordered starting in 1, and with the respective XY coordinates.

Screenshot from 2015-11-05 23:58:19

It seemed to be a trivial task – all I would need was to use the ST_DumpPoints() function to get all vertexes – if it wasn’t for the fact that PostGIS polygons have a duplicate vertex (the last vertex must be equal to the first one) that I have no interess in showing.

After some try-and-fail, I came up with the following query:

CREATE OR REPLACE VIEW public.my_polygons_vertexes AS
WITH t AS -- Transfor polygons in sets of points
    (SELECT id_polygon,
            st_dumppoints(geom) AS dump
     FROM public.my_polygons),
f AS -- Get the geometry and the indexes from the sets of points 
    (SELECT t.id_polygon,
           (t.dump).path[1] AS part,
           (t.dump).path[3] AS vertex,
           (t.dump).geom AS geom
     FROM t)
-- Get all points filtering the last point for each geometry part
SELECT row_number() OVER () AS gid, -- Creating a unique id
       f.id_polygon,
       f.part,
       f.vertex,
       ST_X(f.geom) as x, -- Get point's X coordinate
       ST_Y(f.geom) as y, -- Get point's Y coordinate
       f.geom::geometry('POINT',4326) as geom -- make sure of the resulting geometry type
FROM f 
WHERE (f.id_polygon, f.part, f.vertex) NOT IN
      (SELECT f.id_polygon,
              f.part,
              max(f.vertex) AS max
       FROM f
       GROUP BY f.id_polygon,
                f.part);

The interesting part occurs in the WHERE clause, basically, from the list of all vertexes, only the ones not included in the list of vertexes with the maximum index by polygon part are showed, that is, the last vertex of each polygon part.

Here’s the result:

Screenshot from 2015-11-05 23:58:40

The advantage of this approach (using PostGIS) instead of using “Polygons to Lines” and “Lines to points” processing tools is that we just need to change the polygons layer, and save it, to see our vertexes get updated automatically. It’s because of this kind of stuff that I love PostGIS.

Creating a Tissot’s Indicatrix in QGIS

The task of projecting, or unfolding the spherical Earth onto a flat map, is an age old problem in cartography. Projection almost always introduces distortion, most projections cannot preserve angles, areas and distances at the same time, they may be conformal (angle-preserving), equal-area (area-preserving) or equidistant (distance preserving) but not all at once. The only exception is a Globe, which preserves angles, areas and distances perfectly. Thus a projection is a compromise.

The choice of projection depends on a map’s use, scale and audience. Conformal projections, for example, are preferred for nautical charts or small scale maps because they locally preserve angles necessary for navigation and survey drawings. Equal-area projections are best suited for maps of broad continental region as they preserve the relative sizes of countries, seas and oceans and allow comparison between regions. Finally, there are hybrid projections that minimise the distortion by merging conformal and equal-area projections, these can be used to create visually pleasing maps of the entire Earth (for a guide to selecting a map projection see Fig. 9 in Jenny (2011), link below).

But how does one measure the degree and type of distortion in a map projection?

One elegant method was developed in the 1880s century by the French cartographer Monsieur Nicolas Auguste Tissot, the Tissot’s Indicatrix (or Tissot’s Ellipse). This mathematical contrivance consists of a grid of infinitely small circles that measures the degree and type of distortion caused by projection. While Monsieur Tissot’s approach is mathematical, involving infinity small circles, his technique can be approximated overlaying a regular grid of large circles and crosses to a map.

The Indicatrix Mapper plugin for QGIS by Ervin Wirth and Peter Kun creates a Tissot’s Indicatrix by adding a vector layer of circles and crosses in a gridded pattern on a map. The degree and type of distortion of the Tissot’s Indicatrix reveals the class of map projection as follows: –

  • If a projection is conformal, the area of circles and sizes of the crosses will change while the shapes of circles remain the same and intersection angle of the crosses will always meet at 90 degrees e.g. Mercator projection
  • If a projection is equal-area, the area of the circles will remain the same while the shape of the circles change and intersection angle of the crosses will not always meet at 90 degrees e.g. Mollweide projection or Hammer projection
  • If a projection preserves neither property, the area of the circles and their shape will change, and the intersection angle of the crosses will not always meet at 90 degrees e.g. Robinson

After adding the Indicatrix Mapper plugin to QGIS (menu Plugins – Manage and Install Plugins) first add a basemap using the OpenLayers plugin e.g. Bing Aerial layer, then click the Indicatrix Mapper icon and run the plugin using default settings. You can then select different projections (lower right in world icon QGIS) to see the effects of various protections on the Tissot Indicatrix. If the circles appear as squares after selecting a different projection, right click the Circles layer in the layers panel, then select the Rendering tab and deselect the Simplify geometry check box. Also, turn off the basemap layer when using different projections, unfortunately the OpenLayers plugin only supports Google Mercator projection (EPSG 3857). To create the basemap below, that can be displayed using different projections, I styled vector data downloaded from Natural Earth and OpenStreetMap.

Mercator

Mercator Projection – the area of the circles and size of the crosses increase towards the poles but their shape remains the same.

Mollweide

Mollweide Projection – the area of the circles remain the same but their shapes are distorted, the crosses do not always intersect at 90 degrees.

Robinson

Robinson Projection – both the area of the circles and intersection angle of the crosses circles vary.

It is important to note that a Tissot’s Indicatrix generated in QGIS is an approximation of mathematical ideal, we are not no longer dealing with infinity small circles. As a result, here will be some minor distortion visible towards the edge of a map independent of the projection used; notice that the circles in the Mercator projection nearest the poles are not quite symmetrical or the circles at the edge of the Mollweide projection do not appear to preserve area as they should. This anomalous distortion can be minimised by reducing the size and spacing of the circles and crosses created by the Indicatrix Mapper plugin. However, despite these limitations a Tissot’s Indicatrix elegantly reveals the distortion present. This is something to important to understand when when choosing a map projection.

References:

Jenny, B., 2012. Adaptive composite map projections [PDF]. Visualization and Computer Graphics, IEEE Transactions on, 18, 2575–2582.

Open Source, why?

EN | PT

During my professional and personal life, I have worked with much different software, with all kinds of licenses. Most of them would be proprietary, closed and / or commercial code. So why devote my time and learning “exclusively” to Open Source?

Without going into detail about the differences between open source software and free software, there are several reasons why FOSS (Free and Open Source Software) interest me.

The first is obviously freedom. Be free to use the software in any context and for any purpose, without being limited by the costs of software acquisition and / or the rules and conditions imposed by the manufacturer (as many said free (as beer) software do). That allows me to, for example, familiarize myself with its features without having to use piracy, or, as a freelancer worker, develop my work based on my technical capacities rather than my financial ones.

Second, the community and collaborative factor. The fact that open source software is built by user and for users, where the main goal is to enhance the software functionality (and not just raise the number of sales), and wherein each enhancement introduced by an individual or company is subsequently shared for the benefit of the whole community, avoiding duplication and “reinventing the wheel”. This is done in part through a lot of volunteer work and constant sharing of knowledge, either by the programmers or users. Thus, together, we all evolve at the same time as the software itself. In addition, everyone can contribute in some way, by producing code, writing and preparing supporting documentation, translating them into other languages or just by reporting bugs.

Finally, the “costs“. The adoption of open source software in enterprises (including the public ones), allow them to focus their investments in training of the human resources and the possible (and desirable) sponsoring of new features that are essential for their workflow, usually for a small portion of the values to spend on the acquisition of commercial software (that usually “forces” the purchase of features that may never be used).


  • <<
  • Page 62 of 141 ( 2820 posts )
  • >>

Back to Top

Sustaining Members