Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a field that is in degree minutes seconds, populated from ET Geowizards COGO Inverse tool. It populates the values as 90-12-28.15 where 90 is the degree, 12 is the minutes and 28.15 is the seconds.

I need to use this field to label on a map. The format of the label is calling for the degree minutes seconds characters (i.e. 90° 12' 28.15") so I want to add a new field and use VB/Python to field calculate these characters in and remove the dashes.

I've been working on this for a while and I can't seem to figure it out, but I'm sure this is doable.

Thanks, Mike

share|improve this question
add comment

1 Answer 1

The following Python field calculation script should work for you (tested in ArcMap 10.0):

Your expression should be:

calc(!YOUR_FIELD_NAME_HERE!)

And your code block should be:

def calc(val):
    val = val.split('-')
    return u'%s\u00B0 %s\u2032 %s\u2033' % tuple(val)

The \uXXXX characters are special unicode characters for °, ′, and ″ (thanks to Mike Toews)

share|improve this answer
1  
Try using u'%s\u00B0 %s\u2032 %s\u2033'%tuple(val) to format using prime and double prime Unicode characters, e.g.: 1° 2′ 3″ –  Mike T Aug 2 '12 at 4:05
    
Thanks for the feedback Mike! I incorporated it into my answer. –  Tanner Aug 2 '12 at 6:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.