# Convert Coordinate Notation with specified number of decimals

I have two columns with decimal degrees: POINT_X POINT_Y.

I then use the tool Convert Coordinate Notation to convert from DD to DDM. But I get too many decimals, see picture. In the "Format Location Units" I have specified 3 decimals.

Is it possible to use this tool, and get 3 decimals in the output?

The Location Unit Format dialog you show in your question affects the display of coordinates in the status bar. The tool Convert Coordinate Notation has no parameter or environment setting that influences the number of decimal places in its output. Finally the output of the tool is a text field because the values it creates, as shown in your screen shot, contain spaces and letters.

So a simple calculate script manipulating the text could be used to truncate the coordinates as shown below:

Code block is:

``````def truncate(dms):
aL = dms.split(" ")
lat = aL[1]
lon = aL[3]
# find decimal point
lat_dp_idx =lat.find(".")
lon_dp_idx =lon.find(".")

# Truncate to 3 dp
new_lat = lat[:lat_dp_idx+4]
new_lon = lon[:lon_dp_idx+4]

# rebuild DMS
new = aL[0] + " " + new_lat + lat[-1] + " " + aL[2] + " " + new_lon + lon[-1]
return new
``````
• This is great! The only drawback is that the function doesnt round the values: 62 50.32799993N will be 62 50.327N, but should round to 62 50.328N Is that possible to include? Oct 6, 2022 at 11:58
• You could include a python round() function into this code if you want rounding, I leave that for to you to discover. Oct 6, 2022 at 14:59