2

In answer to this question Klas Karlsson puts forward a solution to the problem of formatting print composer grid labels for projected maps.

I'm very weak on scripting, but in QGIS 2.14 I've tried to enter the text as shown in Klas's illustration, which generates error messages. In my case I'm working with a coordinate system that has a six-digit Easting and a six-digit Northing and I'm trying to get a result similar to that shown in Klas's picture (but with a six-digit Northing). Can anyone help me with this?

2

Klas's answer seems correct to me but it does make some assumptions about the size of the coordinates that may fail.

I've created the same solution using the following expression:

CASE WHEN  @grid_axis = 'x' THEN 
' ' ||  left(lpad( @grid_number ,6,'0'), 2) ||'      '||right( @grid_number ,2)
ELSE
'  ' ||  left(lpad( @grid_number ,6,'0') ,2) ||'    '||right( @grid_number ,2)||' '
 END

I was unable to get the spacing quite right using a single line of text so I went for one line for the X axis (1st one) and one for the Y axis.

enter image description here

The main trick here that isn't spelt out in Klas's answer is that you need two grids - one at 1000m intervals with an expression

 substr(  lpad(  @grid_number,6 ,'0'), 3,2)

to draw the middle digits (at font size 9) and the second formatted as above with font size 7 to draw the beginning and end of the 10000m grid lines.

I suspect the true cartographers will spend more time with fonts and spacing to make it look even nicer than this.

Alternatively you could change the lower grid to not show anything at the 10000 lines by using:

CASE WHEN  @grid_number %10000 = 0 THEN
 '' 
 else 
 substr(  lpad(  @grid_number,6 ,'0'), 3,2) 
 END  

and print the whole grid number at those lines.

enter image description here

  • Many thanks Ian. I'm still having problems with spacing but with this lead I should be able to sort them out. – nhopton Mar 24 '16 at 17:12
  • 1
    that's why I tried the second solution, anything else is going to require custom python I suspect – Ian Turton Mar 24 '16 at 17:13

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.