Using special characters in QGIS expressions

QGIS special characters

This brief text explains how to use some custom symbols in QGIS expression. Obviously, it applies only to the quoted part, which represents the bits with string.
There are 2 ways of doing it.
The first method uses the char() element, which can give us the desired symbol, letter, or icon. In the case of degrees, it will be (Pic. 1):

18 || char(730)
QGIS Char(730) degree symbol

Pic.1 An example of using special characters in QGIS expression.

Special character usage QGIS

Pic. 2 The usage of special characters in QGIS.

Considering a few other examples, we could list:
char(730) – degree symbol
char(0176) – bigger degree symbol
char(0163) – the £ symbol
char(0169) – the copyright symbol
char(999999999) – 짿

In total, we have 65535 special characters available in QGIS! They include various symbols, letters in all languages, and emoticons. Indeed, you can feel seriously overwhelmed by it! It’s rather pointless to draw lots between such a massive list of characters. In fact, I’ve prepared some of them for you, which are available here, but for some of you, these lists might be still not sufficient. When you don’t know what number is assigned to the character you want to attach to your label in expression, then the second method will be tailor-made for you.
You will need to open MS Word and next: Main toolbar -> Insert -> Symbol -> More symbols where you will find the interesting one if not visible in the handy list (last used) appearing right under the Symbol (Pic. 3).

MS Word insert symbol

Pic. 3 Inserting symbol in MS Word application.

Once your symbol appears on the page, select it and copy (Ctrl + C), then paste it (Ctrl + V) between the quotes (‘ ‘) in your QGIS expression (Pic. 4).

Special character copy from Word and paste to QGIS

Pic. 3 Copying the special character from Word and pasting it in QGIS.

The result will be exactly the same! (Pic. 4).

QGIS special characters in label

Pic. 5 QGIS – special characters in the label.

Mariusz Krukar

 

Links:

  1. https://docs.qgis.org/2.18/en/docs/user_manual/working_with_vector/expression.html
  2. https://umar-yusuf.blogspot.com/2018/09/qgis-add-delimited-text-layer-with.html
  3. https://www.rapidtables.com/code/text/unicode-characters.html

 

Forums:

  1. https://gis.stackexchange.com/questions/80710/openlayers-how-to-display-the-character-degrees-in-the-label
  2. https://gis.stackexchange.com/questions/282386/adding-text-to-label-expression-in-qgis
  3. Github.com: Encoding issue for special chars in labels
  4. How to correctly replace a special character into an apostrophe using the replace function in QGIS Field Calculator? The expression below says it is invalid; what’s the correct syntax? Thanks!
  5. https://gis.stackexchange.com/questions/219643/special-characters-in-qgis-script-tools
  6. https://gis.stackexchange.com/questions/393519/how-to-get-a-text-character-based-on-a-number-position-in-the-alphabet-in-a-qgis
  7. https://gis.stackexchange.com/questions/90076/are-unicode-symbols-supported-in-qgis-labels
  8. https://gis.stackexchange.com/questions/31885/how-to-display-special-german-characters-%C3%84%C3%9C%C3%96%C3%9F-in-a-map
  9. QGIS displays all 65535 Unicode characters in Font Marker symbol selection window
  10. Github.com: QGIS displays all 65535 Unicode characters in Font Marker symbol selection window

Wiki:

  1. List of Unicode characters

Youtube:

You may also like...

1 Response

  1. Thank you I have just been searching for information approximately this topic for a while and yours is the best I have found out so far However what in regards to the bottom line Are you certain concerning the supply

Leave a Reply

Your email address will not be published. Required fields are marked *