How To: Convert Decimal Degree values to Degree Minute Seconds values using the Field Calculator is pretty handy, so is Convert Coordinate Notation—Data Management toolbox | ArcGIS Desktop , but what I need is for a display/label expression to take attributes from a feature class (lat/lon in decimal degress) and display them as Deg, Min, Sec. Seems like Arcade would be handy for this sort of thing, but not finding any thing to start with.
Hi tpcolson ,
You can find an example here: Converting geometry($feature) coordinates in a pop-up to decimal degrees?
Your case will be simpler since you don't need to convert the meters to degrees.
Every reference I see on the math behind this calls for an integer conversion, including the original help article for Arc Map, yet Arcade seems to have no Integer function. What am I missing?
Convert degrees/minutes/seconds angles to or from decimal angles - Office | Microsoft Docs
Hi tpcolson
In the link I shared before you have the examples you can use to do this. Did you have a look at them?
Longitud:
Function LON_g_m_s(decimal_degrees) {
var grados = Floor(Abs(decimal_degrees), 0);
if (decimal_degrees < 0) {
var quad = 'W';
} else {
var quad = 'E';
}
var min_seg = Abs(decimal_degrees) * 60 - grados * 60;
var minutos = Floor(min_seg);
var segundos = min_seg * 60 - minutos * 60;
var gms = Text(grados, "###") + "° " + Text(minutos, "00") + "' " + Text(segundos, "00.000") + '" ' + quad;
return gms;
}
return LON_g_m_s($feature["Your longitud field name"]);
Latitud:
Function LAT_g_m_s(decimal_degrees) {
var grados = Floor(Abs(decimal_degrees), 0);
if (decimal_degrees< 0) {
var quad = 'S';
} else {
var quad = 'N';
}
var min_seg = Abs(decimal_degrees) * 60 - grados * 60;
var minutos = Floor(min_seg);
var segundos = min_seg * 60 - minutos * 60;
var gms = Text(grados, "###") + "° " + Text(minutos, "00") + "' " + Text(segundos, "00.000") + '" ' + quad;
return gms;
}
return LAT_g_m_s($feature["Your latitud field name"]);
Ah yes the elusive scroll wheel on the mouse. I'm having a hard time wrapping my head around how to eliminate the convert from meters function, and apply the other two functions directly to
(Geometry($feature).X, Geometry($feature).Y);
Hi Thomas Colson ,
To understand it completely, are you using as basis:
I included the code for the third case. In case it is the first, you can use the X and Y properties of the geometry as you mentioned and use those. I case it is the second the link I included in my first reply shows how to extract the coordinates from the geometry, convert the meters to degrees and apply the functions to get the DMS.
type(math.floor(2316.25))
int
dont' forget, ceil and floor provide controlled specific ways of deriving integers from floats.
Related to what Dan_Patterson mentions, Floor is also available in Arcade.You can find an example here: How do I convert seconds to minutes, hours, or days with Arcade
I may be in a 4th case here. The data is in a GDB feature class and is NAD 83 UTM Zone 17. I'm trying to use an attribute rule to populate a text field (when I say "display", we are porting the data into a downstream non-gis application where such conversions aren't possible)
Hi tpcolson ,
Sorry to tell you, but Arcade does not have access to any projections. Unless you can provide the calculation for the projection yourself and include it in the expression, Arcade will not be the option here.