2

The numeric scalebar in the map composer shows too detailed information on the output. Moving the Map canvas changes the scale depending on the moved distance on the map.

We use EPSG 4258 (ETRS89)

How do I round the shown output by -2 digits? It should round to hundreds

7
  • 1
    Could you add a screenshot please? Because I haven't seen a scalebar with digits after the comma.
    – Erik
    Feb 5, 2019 at 8:25
  • It doesn't show commas. But we are using large maps and want even numbers like 10000 instead of 9999 or 10001. Depending on the coordinate reference system it changes either with horizontal or vertical movement of the map layout
    – Rubedo
    Feb 5, 2019 at 8:27
  • So, you're talking about the map composer?
    – Erik
    Feb 5, 2019 at 8:30
  • yes............
    – Rubedo
    Feb 6, 2019 at 9:48
  • And how does setting the map canvas scale to 1:10000 not suit your needs?
    – Erik
    Feb 6, 2019 at 10:04

1 Answer 1

6

For QGIS 3.x, in the layout :

  1. Draw a map item (Add item menu) and give an item ID

  2. Draw a label item and paste the following code :

    [% '1/' || round(map_get(item_variables('my_map_item_ID'), 'map_scale')/100) || '00' %]

Explanation of the code :

  • || : concatenate two strings, here the '1/' part and the other calculed one, and finally the '00' for lasts units
  • item_variables : access to variables of an item given its item ID, here 'my_map_item_ID'
  • map_get : get item of map item given its attribute, here 'map_scale'
  • /100 : to get hundreds
  • round : to get rid of the decimal part for the denominator
  • [% %] : enclose an expression in a label item
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.