# QGIS: Custom formatting coordinate grid to reduce number of decimals

I am making a coordinate grid system of a map I have made, but now I would like to reduce the number of decimals of the seconds (of the latitude and longitude).

So instead of 36°54'0.000"E -> 36°54'0"E

I think this is done using the custom function: "round", but I do not know which formula I should use.

If you scroll further down the grid properties panel you come to `Coordinate Precision` reducing the `3` to `0` with give the result you want.

• Thank you so so much! I'm just a beginner in QGIS and I did not see this option. Thank you :) – user178341 Mar 3 at 11:23
• if this answer helped please up vote it and / or accept it. The tour provides more detail on how the site works. – Ian Turton Mar 3 at 11:27

You don't need to use `round` in particular but just read again the expression manual for `to_dms` (https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/functions_list.html#to-dms).

For x coordinates, replace the `36.90` with your `x` column name

``````with_variable('your_coord', 36.90,
if (
@your_coord < 0,
to_dms(@your_coord, 'x', 0) || 'W',
to_dms(@your_coord, 'x', 0) || 'E'
)
)
``````

For y coordinates, replace the `18.90` with your `y` column name

``````
with_variable('your_coord', 18.90,
if (
@your_coord < 0,
to_dms(@your_coord, 'y', 0) || 'S',
to_dms(@your_coord, 'y', 0) || 'N'
)
)
``````

PS: There is an option `aligned` in `to_dms` but it does not fit exacty your requirements, hence the "bastard" version above

• Thank you for your answer!! – user178341 Mar 3 at 11:24