How do I display a numeric scale for a map in two units, for example 1 in = 1000 ft ?

I know it's possible to display a scale bar as "Numeric," which provides only a ratio, in this example 1:12,000.

It seems like it should be possible to insert an expression into a label, only I can't figure out how to reference a map item in the expression builder. The map item has a variable "map_scale" but when I put this variable into a text item, it just displays as a string. enter image description here


Use the custom python function provided in the answer to this question, then divide by 12 to get inch:feet ratio.

Step 1: Add a text label to the print composer

Step 2: Insert an expression into the label

enter image description here

Step 3: Create a custom function In the "Insert Expression" window, click the "Function Editor" tab. Click "New File," enter the file name get_composer_map_scale, click OK. Copy and paste the code on this page, then click "Load" to register the custom function. enter image description here

Step 4: Use the custom function to display the scale as the ratio [inches on the page]:[feet in real life]

enter image description here

Copy/paste into your label:

1 inch = [%round(get_composer_map_scale( 'Composer 1')/12, 0)%] feet

Substituting the name of your print composer where it says Composer 1.

Note: I added the function round(value, places) to round to an integer value of feet. To display more digits, substitute the number of digits for the zero.

EDIT: This answer only works for QGIS 2. For QGIS 3, see this answer: gis.stackexchange.com/a/332759/35561. Thanks to @MrChe for the suggestion.

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.