# Arcade function to convert direction in DMS to Decimal degrees

5096
14
01-06-2021 03:14 PM
Status: Implemented
Labels (1)
New Contributor II

I have data where direction for the line is in DMS north azimuth.

To convert this data to decimal degrees, you need to strip off the degree, minutes seconds characters and then convert it to decimal degrees.

It will be a time saver if arcade had a function that could strip off the characters and convert to decimal degrees. This function will be very useful when converting data to load into a parcel fabric.

The current label expression shipped with COGO enabled lines converts decimal degrees to DMS north azimuth. What I am looking for is the reverse function.

Tags (4)

Hi @IreneHwang ,

There's an easier way of converting DMS to DD without using Arcade, If you are after a quick solution in ArcGIS Pro.

1. Create two new fields (eg., Long_DD and Lat_DD)

2. Right click on Long_DD field > select Calculate Geometry

3. For the Property > select Point x-coordinate

4. For Coordinate Format, select Decimal Degrees > Ok

Do the same for Lat_DD, selecting Point y-coordinate.

and if you're looking into automating, you can use python:

``````arcpy.management.CalculateGeometryAttributes("GPS_data", "Long_DD POINT_X", '', '', None, "DD")

arcpy.management.CalculateGeometryAttributes("GPS_data", "Lat_DD POINT_Y", '', '', None, "DD")``````

Your suggestion would work if the direction is derived from the geoemtry.

I believe @IreneHwang  is using an attribute that originates from a legal document and is not guaranteed to match the feature geometry.

Common reasons for the mismatch are parcel misclose adjustment, least-square adjustment and ground to grid correction.

If that's the case, then Convert Coordinate Notation tool in ArcGIS Pro will do the job.

Cheers

Mehdi

Yes - this python method would work in ArcGIS Pro.

But @IreneHwang is asking for Arcade method. Arcade is a portable, lightweight expression language that is used with Attribute Rules, labeling, popups etc. on ALL ArcGIS clients.

Attribute Rules can be set to react to triggers (Insert, update, delete) on the geodatabase level, stored as part of the feature class definition (portable) and without the need to write python scripts that are project dependent.

I am also looking for something similar, where I have cogo values in quadrant bearings and need to convert them to the new Argis Pro cogo format of decimal degrees, preferably in the calculate field tool. An example would be converting S 1-45-0 E to  91.75

Hey @MattEitrem ,

I might have created the tool that you need!  https://community.esri.com/t5/arcgis-parcel-fabric-blog/migrate-arcmap-cogo-to-pro/ba-p/885059

This GP script tool will convert those pesky COGO string values to DOUBLE values.  It will create a full brand new feature class during the conversion.  None of your existing data will be effected.  Let me know if this works for you.

-Jason

Thank you for the great suggestions. The options you describe will help me out in the short-term. However, for the data that is from a legal document, I am looking to convert it and also validate it using attribute rules which makes the arcade method very attractive. In addition, I would like enable the other users in our organization to leverage this validation along with popups, labelling etc.

- Irene

Good news! Arcade1.13 has just been released and includes the ConvertDirection function (https://developers.arcgis.com/arcade/function-reference/geometry_functions/#convertdirection).
This allows users to translate angles between many text and value formats.

For the examples mentioned above you should be able to write Arcade script such as:

ConvertDirection(
myTextAngle1, //e.g. 78° 34' 25"
{"angleType":"dms","directionType":"north"},
{"outputType":"value","angleType":"degrees","directionType":"north"}
) //gives 78.5736

ConvertDirection(
myTextAngle2, //e.g. S 1-45-0 E