In the print composer, after having added a map and enable the grid display under
Draw coordinates, you can select the
custom option to specify the formatting. To enter your particular specifications for the coordinates, you need to click on the greek letter e symbol (epsilon) on the right.
You would then make use of the
@grid_axis variables. Let's remember that for each coordinate to be printed, the custom format function will be called.
@grid_number contains the value (number) to be printed while
@grid_axis indicates if it is on the x or y axis.
So, a negative value means South (for y) or West (for x). A positive means North or East.
The format function would start by displaying the absolute value with 2 decimals (it's up to you) - if any -, then adds the space and degree sign. It then forks it logic depending on whether the function is called for the X or Y axis (written as a
case statement for readability). For each case, it again forks it logic depending on whether it is a negative or positive value. Finally, for each of the 4 combination (axis + sign), it adds the N/S/E/W letter to the label to be returned.
abs(format_number( @grid_number ,2))
|| ' °'
WHEN @grid_axis = 'x'
IF (@grid_number > 0, 'E' , 'W')
IF (@grid_number > 0, 'N' , 'S')