1

the following code automates the project CRS for display as text in my maps.

[% @project_crs %]

Can anyone provide me with something which will automate the scale of the map?

2
  • 3
    If you provide us with the software you're working with, we might be able.
    – Erik
    Jun 23, 2021 at 8:25
  • I made an answer assuming you are using QGIS. @crustygaz , let me know if it work for you. Jun 24, 2021 at 6:49

1 Answer 1

0

You need to access to the scale of your map that is in the same layout.

To do so there is a function called item_variable() that could access to all the variables for any item in your layout.

Take the name of your map in your layout. In my case it is Carte 1

enter image description here

Then add a text box with the expression below to get the format you prefer. Don't forget to change the text Carte 1 to the name of your map.

To get a format like "18836.438"

[%map_get( item_variables( 'Carte 1' ), 'map_scale' )%]

to get a "rounded" value like "19000"

[%round(map_get( item_variables( 'Carte 1' ), 'map_scale' ), -3)%]

to get a value like "1 : 18 836"

'1 : ' || format_number(map_get( item_variables( 'Carte 1' ), 'map_scale' ),0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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