Monday, 7 October 2019

How to remove trailing zeros from QGIS Graduated Style Class labels?


I'm sure I've seen a solution to this before but now I can't find it.


When using the graduated fill style in QGIS I get lots of trailing zeros in the labels. This makes my legends look messy in the print composer.


Is there a way to automatically remove these?



Graduated fill style with trailing zeros



Answer



Here's the simplest method I've found so far:



  1. Open layer properties

  2. Save style as a QGIS Layer Style File

  3. Open the resulting .qml style file in your favourite text editor

  4. Use find and replace to identify trailing zeros and replace with a zero length string

  5. Apply the altered layer style in QGIS



Note: Be careful when doing the find and replace as the lower & upper values may have a different number of trailing zeros to the label value. If you're not careful you can accidentally increase the values by factors of ten!


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...