Select to view content in your preferred language

Arcade function to convert direction in DMS to Decimal degrees

7751
14
01-06-2021 03:14 PM
Status: Implemented
Labels (1)
IreneHwang
Emerging Contributor

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.

14 Comments
MehdiPira1

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

MehdiPira1_0-1609981816019.png

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")

 

AmirBar-Maor

@MehdiPira1 

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.

MehdiPira1

@AmirBar-Maor 

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

Cheers

Mehdi

AmirBar-Maor

@MehdiPira1 

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.

 

AmirBar-Maor_0-1610093613461.png

 

MattEitrem

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

JasonCamerano

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

IreneHwang

@MehdiPira1 

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

RichardShepherd

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
  {"angleType":"dms","directionType":"quadrant"},
  {"outputType":"value","angleType":"degrees","directionType":"polar"}
) //gives 271.75

(My thanks to @AmirBar-Maor for regularly reminding us how useful this function would be!)

Please let us know if you have any questions or comments.
KoryKramer
Status changed to: In Product Plan
 
IreneHwang1

Fantastic! This will be extremely helpful to a number of us😁

Thank you!