15

I have a polygon feature dataset, and an attribute from a different table that I join (one-to-one) within QGIS in order to symbolise the attributes as a choropleth map. However, not all polygon fields have a matching field in the table of numerical attributes, so there are some null values when producing the graduated symbology.

From my research, the most common piece of advice in this situation is to include a copy of the polygon dataset (or some other background) that defines a default symbology. This works because the null values are not classified in the graduated symbology, so one can see "underneath" them. I have attached an image of exactly this. The dark grey features do not exist in the join table (mb_percentile_isochrones_all), but do exist in the boundary polygons table (mb2013_wgtn). So I need two instances of the mb2013_wgtn table in order to show the "no data" features.

enter image description here

However, this does not seem elegant to me. Much more intuitive would be to define a null value symbol. Perhaps this could be perfectly transparent to be consistent with what currently exists, or perhaps it would be some kind of muted grey—whatever the user wants. The point is, at present one needs two different layers in the contents in order to handle the symbology of null values. This means that to change the symbology of all your features at the same time (say, if you want to increase the width of all borders), this has to be handled twice: once in the properties for the feature with the graduated symbology, and once for the "background" layer that handles the null symbol.

Is it possible to define a "null" value symbol without using a "copy" of the same layer used for the graduated symbology, in QGIS (2.6.1)?

  • What's wrong with having the same layer twice with different symbology? Perhaps use attribute filtering so that no polygon appears in both layers if you're getting confusion in identify or geoprocessing. Are the unmatched features 'null' in their join value or do they have a value that doesn't appear in the table? – Michael Stimson Jan 7 '15 at 3:10
  • 1
    1. Problem: if I want to control the common properties of features with a value and with a null (e.g. border colour), it has be be performed twice. This makes it much easier to forget to change one of them, or to make a slight mistake (e.g. wrong shade of grey for the outline). 2. No problems regarding confusion for geoprocessing, just the symbology: I want to symbolise the null feature in the same layer. 3. Unmatched features are null in their join value (as seen in the QGIS attribute table post-join). – Richard Law Jan 7 '15 at 3:14
  • It also makes it more difficult when building a legend to include a "no data" sample, as this symbol would come from a different layer. – Richard Law Jan 7 '15 at 3:23
  • 2
    You're right. There is nowhere to select 'show NULL features like this' in the graduated symbol dialog, rows with NULL values are simply not shown. – Michael Stimson Jan 7 '15 at 3:23
17

As @MichaelMiles-Stimson already mentioned, there doesn't seem to be a way to symbolise NULL features. However, there is an alternative whereby you create a filter to force QGIS to treat NULL values as an integer such as 0. I've included an example where I created 3 simple polygons each with a certain value:

3 polygons

Attribute table

Here is the Graduated Symbology I used with the following command:

case when "Some_Value" IS NULL then 0 else "Some_Value" end

Graduated symbology

Hope this helps!

  • This is quite helpful and I'll probably put this into practice. The problem I anticipate is that 0 is a meaningful value in my dataset. I could probably use -1 or something. But in either case this would make the automatic identification of class breaks slightly unwieldy. Perhaps I should submit a feature request for this given it's now clear the workarounds are less than ideal. – Richard Law Jan 7 '15 at 19:16
  • Yes, including NULL values could be quite useful. It's not a pretty workaround but you can always submit a feature request and hope it becomes available in the next version :) – Joseph Jan 8 '15 at 10:10
6

I know it has been answered, but just to give another option:

You can just leave the field with no filter or value (I know it works for CATEGORIZED or RULE BASED):

http://docs.qgis.org/2.0/uk/docs/training_manual/vector_classification/classification.html

enter image description here

I'm using QGIS 2.10 and it works.

  • Always nice to know more methods in solving or working around a problem! +1 – Joseph Sep 21 '15 at 11:57
  • 1
    Encouraging to see this improvement since 2.6, right? Can you confirm that it works when the null values come from a joined table? – Richard Law Sep 21 '15 at 12:00
  • 1
    A couple of notes on this though. The blank or NULL symbology in a rule based symbology will be applied to ALL features. The rules are applied from the top down, so it may be overlayed by another rule, but the NULL will also be there. Important if it is a strong symbology. You can also "generate" you rules by first creating them in the Categorized or Graduated symbology and then switching to Rule Based/ – HeikkiVesanto Sep 21 '15 at 14:18
  • @Vesanto, I don't know if I got it, or if it is a problem. In my case, I'm adding Z values to a SHP made of contour lines, that originally had no Z values (Z = NULL). I've set the features with NULL values to red and the ones with any value to black. When editing, as soon as I set a Z value, the feature (the contour line) turns from red to black, this way I know the ones that I'm yet to set the Z value. – Marcos Saito Sep 21 '15 at 14:50
  • @Marcos it won't be an issue in your case. But lets say the line was red to begin with, and you wanted to turn it invisible once it was not null anymore. That would not work. – HeikkiVesanto Sep 21 '15 at 18:46
3

Similar to what other users have said, the best option is to use rule-based symbols. To avoid manually creating the rules:

  1. Change the symbol type to Graduated.
  2. Define the symbol column, colours, intervals etc. as per normal Graduated Symbols, with null values not shown
  3. Change the symbol type from Graduated to Rule-based. The symbols defined in the previous step will be carried over. Click the add symbol button, and select ELSE. Change the style as appropriate. This ELSE symbol class will catch any values that haven't been symbolised already, including null values. Adding ELSE catch-all symbol
  4. Click OK. Null values will now be symbolised. Graduated symbols, including null values

(Tested in QGIS 3.6.0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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