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
Decimal Degrees to Degrees,Minutes,Seconds converter
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 <SPAN class="token function">LON_g_m_s</SPAN><SPAN class="punctuation token">(</SPAN>decimal_degrees<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> grados <SPAN class="operator token">=</SPAN> <SPAN class="token function">Floor</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">Abs</SPAN><SPAN class="punctuation token">(</SPAN>decimal_degrees<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>decimal_degrees <SPAN class="operator token"><</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> quad <SPAN class="operator token">=</SPAN> <SPAN class="string token">'W'</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> quad <SPAN class="operator token">=</SPAN> <SPAN class="string token">'E'</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">var</SPAN> min_seg <SPAN class="operator token">=</SPAN> <SPAN class="token function">Abs</SPAN><SPAN class="punctuation token">(</SPAN>decimal_degrees<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="number token">60</SPAN> <SPAN class="operator token">-</SPAN> grados <SPAN class="operator token">*</SPAN> <SPAN class="number token">60</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> minutos <SPAN class="operator token">=</SPAN> <SPAN class="token function">Floor</SPAN><SPAN class="punctuation token">(</SPAN>min_seg<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> segundos <SPAN class="operator token">=</SPAN> min_seg <SPAN class="operator token">*</SPAN> <SPAN class="number token">60</SPAN> <SPAN class="operator token">-</SPAN> minutos <SPAN class="operator token">*</SPAN> <SPAN class="number token">60</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> gms <SPAN class="operator token">=</SPAN> <SPAN class="token function">Text</SPAN><SPAN class="punctuation token">(</SPAN>grados<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"###"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"° "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">Text</SPAN><SPAN class="punctuation token">(</SPAN>minutos<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"00"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"' "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">Text</SPAN><SPAN class="punctuation token">(</SPAN>segundos<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"00.000"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">'" '</SPAN> <SPAN class="operator token">+</SPAN> quad<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">return</SPAN> gms<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="token function">LON_g_m_s</SPAN><SPAN class="punctuation token">(</SPAN>$feature<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"Your longitud field name"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Latitud:
Function <SPAN class="token function">LAT_g_m_s</SPAN><SPAN class="punctuation token">(</SPAN>decimal_degrees<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> grados <SPAN class="operator token">=</SPAN> <SPAN class="token function">Floor</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">Abs</SPAN><SPAN class="punctuation token">(</SPAN>decimal_degrees<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>decimal_degrees<SPAN class="operator token"><</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> quad <SPAN class="operator token">=</SPAN> <SPAN class="string token">'S'</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">else</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> quad <SPAN class="operator token">=</SPAN> <SPAN class="string token">'N'</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">var</SPAN> min_seg <SPAN class="operator token">=</SPAN> <SPAN class="token function">Abs</SPAN><SPAN class="punctuation token">(</SPAN>decimal_degrees<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="number token">60</SPAN> <SPAN class="operator token">-</SPAN> grados <SPAN class="operator token">*</SPAN> <SPAN class="number token">60</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> minutos <SPAN class="operator token">=</SPAN> <SPAN class="token function">Floor</SPAN><SPAN class="punctuation token">(</SPAN>min_seg<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> segundos <SPAN class="operator token">=</SPAN> min_seg <SPAN class="operator token">*</SPAN> <SPAN class="number token">60</SPAN> <SPAN class="operator token">-</SPAN> minutos <SPAN class="operator token">*</SPAN> <SPAN class="number token">60</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> gms <SPAN class="operator token">=</SPAN> <SPAN class="token function">Text</SPAN><SPAN class="punctuation token">(</SPAN>grados<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"###"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"° "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">Text</SPAN><SPAN class="punctuation token">(</SPAN>minutos<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"00"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"' "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">Text</SPAN><SPAN class="punctuation token">(</SPAN>segundos<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"00.000"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">'" '</SPAN> <SPAN class="operator token">+</SPAN> quad<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">return</SPAN> gms<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="token function">LAT_g_m_s</SPAN><SPAN class="punctuation token">(</SPAN>$feature<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"Your latitud field name"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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
<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;">Geometry</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN>$feature<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>X<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">,</SPAN> <SPAN class="" style="color: #d74444; border: 0px; font-weight: inherit;">Geometry</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN>$feature<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>Y<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">;</SPAN>
type<SPAN class="punctuation token">(</SPAN>math<SPAN class="punctuation token">.</SPAN>floor<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2316.25</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> int<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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)
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.
Thomas Colson are you looking at providing a different coordinate notation?
Convert Coordinate Notation—Data Management toolbox | ArcGIS Desktop
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.