0

I am making a map with a "EPSG:25832 - ETRS89 / UTM zone 32 N" grid. I've added 1,000 meter grid lines and need the coordinates on the side of the map to appear in two digits.

The challenge is that the vertical coordinates look like this: 6160000 (seven digits) and the horizontal like this: 678000 (six digits). To get my grid right I need to get rid of the trailing zeros. I have figured out how to do this using substr() or left().

However, since the vertical coordinates have an extra digit in front I can't get my custom format to work. I need to strip the first digit off the horizontal grid and the two first digits off the vertical grid.

Using the picture below as an example I would need the end result to be [64,63] horizontal and [78,79,80,81] vertical.

Anyone know how to do this?enter image description here

1
  • 1
    Why on earth would you wanna do that? Also, substr("text",0,2) resp. substr("text",1,2) should be fine.
    – Erik
    Mar 8, 2023 at 13:01

2 Answers 2

2

You can use an expression in the custom format to account for the digit number and use two different formatting for the 6 and 7 digit number :

CASE
WHEN length( @grid_number )=6 then "formatting for 6 digit"
WHEN length( @grid_number )=7 then "formatting for 7 digit"
END

Just remplace the "formatting for 6 digit" and "formatting for 7 digit" by the appropriate expression to get your two digit result in each case (that should be substr(@grid_number,2,2) for 6 and substr(@grid_number,3,2) for 7)

2

I guess I have starred myself blind in trying to get it done. I have a fix on the right side of the number as both coordinates are 5 digits from the right side. I can get what I need simply using left/right:

left(right(@grid_number,5),2)

Here's the result:

enter image description here

1
  • Sometime it's too simple to be obvious....
    – J.R
    Mar 8, 2023 at 14:09

Your Answer

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

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