TransWikia.com

Using Label Expression with multiple fields and assign different colors

Geographic Information Systems Asked by user2722043 on December 20, 2020

I’m trying to use an expression to label a layer by using multiple fields, and assign different colors using QGIS 2.16.

In ArcGIS I am able to achieve this using the following expression:

def FindLabel([DesceasedName], [ownerName], [all_spaceid]):  
  
  if [DesceasedName] = "":  
    return "<BOL><FNT size = '5'>" + [DesceasedName] + "</FNT></BOL>"+   'n' + "<CLR red='115' green='38' blue='0'><BOL>" + [all_spaceid] + "</BOL></CLR>" 
  elif [DesceasedName] == "":  
    return "<CLR blue='255'><FNT size = '5'>" + [ownerName] + "</FNT></CLR>"  + 'n' + "<CLR red='115' green='38' blue='0'><BOL>" + [all_spaceid] + "</BOL></CLR>"
  else:  
    return ""

How to achieve the same labeling in QGIS?

One Answer

You could try rule based labeling:

enter image description here

Answered by BERA on December 20, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP