Jump to content

 
Photo

label expression

- - - - -

  • Please log in to reply
5 replies to this topic

#1
mak_piseth

mak_piseth

    Newbie

  • New Member
  • Pip
  • 5 posts
  • Cambodia

Hi all
I have one field ,the data is a decimal degrees but i want to show label to degrees minute seconds.
i want to use labels expression to write VBScript in order to show labels.how should i write VBScript in labels expression?I do not want to use field Calculate.
Please hepl me

Edited by mak_piseth, 16 September 2010 - 08:44 AM.


#2
Claude

Claude

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 107 posts
  • Location:Denver, CO
  • United States

Hi all
I have one field ,the data is a decimal degrees but i want to show label to degrees minute seconds.
now i use labels expression to write VBScript in order to show labels.how should i write VBScript in labels expression?
Please hepl me


There are probably easier ways to do this but I would probably skip the fancy label expression and just create a new coordinate column and use Easy Calculate from www.ian-ko.com to get those DMS values, then just label from that new column.
Platts, a div. of McGraw-Hill
www.maps.platts.com


#3
Ninomax

Ninomax

    Contributor

  • Validated Member
  • PipPip
  • 37 posts
  • Vietnam

Hi all
I have one field ,the data is a decimal degrees but i want to show label to degrees minute seconds.
i want to use labels expression to write VBScript in order to show labels.how should i write VBScript in labels expression?I do not want to use field Calculate.
Please hepl me

I think you are mentioning about labeling in ArcGIS. If so, you can try this simple script

Function FindLabel ( [LAT] )
Degrees = Int[LAT]
Minutes = ([LAT] - Degrees) * 60
Seconds = ((Minutes - Int(Minutes)) * 60)
FindLabel = Degrees & "° " & Int(Minutes) & "' " _
& Seconds
End Function

Change [LAT] to the Field you want to label.

#4
mak_piseth

mak_piseth

    Newbie

  • New Member
  • Pip
  • 5 posts
  • Cambodia

Hi all
I have one field ,the data is a decimal degrees but i want to show label to degrees minute seconds.
i want to use labels expression to write VBScript in order to show labels.how should i write VBScript in labels expression?I do not want to use field Calculate.
Please hepl me

I think you are mentioning about labeling in ArcGIS. If so, you can try this simple script

Function FindLabel ( [LAT] )
Degrees = Int[LAT]
Minutes = ([LAT] - Degrees) * 60
Seconds = ((Minutes - Int(Minutes)) * 60)
FindLabel = Degrees & "° " & Int(Minutes) & "' " _
& Seconds
End Function

Change [LAT] to the Field you want to label.



#5
mak_piseth

mak_piseth

    Newbie

  • New Member
  • Pip
  • 5 posts
  • Cambodia

Hi friend
I do the same ur script but it is not succefull.

ur script:
Function FindLabel ( [LAT] )
Degrees = Int[LAT]
Minutes = ([LAT] - Degrees) * 60
Seconds = ((Minutes - Int(Minutes)) * 60)
FindLabel = Degrees & "° " & Int(Minutes) & "' " _
& Seconds
End Function

I change it like this:

Function FindLabel ( [Delta] )
Degrees = Int [Delta]
Minutes = ( [Delta]-Degrees) * 60
Seconds = ((Minutes - Int(Minutes)) * 60)
FindLabel = Degrees & "° " & Int(Minutes) & "' " _ & Seconds
End Function

Please help me.

#6
SaultDon

SaultDon

    Master Contributor

  • Validated Member
  • PipPipPipPip
  • 153 posts
  • Gender:Male
  • Location:BC
  • Interests:Environmental/Wildlife GIS, Aboriginal Land Use and Occupancy
  • Canada

There is a suspect ' in the expression.

Function FindLabel ( [LAT] )
Degrees = Int[LAT]
Minutes = ([LAT] - Degrees) * 60
Seconds = ((Minutes - Int(Minutes)) * 60)
FindLabel = Degrees & "° " & Int(Minutes) & " " & Seconds
End Function

In the above, i've removed the apostrophe that I thought was causing the error and that underscore. Excuse me if this is incorrect and there was an intended purpose for that?

Also, if your DD field is stored as text, this may not work as the expression looks for an integer in the Int() part of the script.
This label syntax may also require the If, Then, End If expression to make it complete...

If you can't get this to work, then I would recommend doing as suggested before, to create a new field. In this case a Text Field so that you can include the abbreviations and special characters of your coordinates in the field.

When the new text field is created, right click its header and go to Calculate Geometry. There is an option at the top for x or y centroids, and the bottom option is for the desired units, in this case, Lat and Long, and there is a full list of the examples and how they should appear in the final field. Also take note of the checkbox that asks if you would like to include the units abbreviations, click this to make it active.

If you need two fields in one label, then generate the x and y coordinates in your required geometry to separate fields than you can use a concatenation operator in the label expression to bring them together with the & key.

Ex:

[Lat_X] & " " & [Lat_Y]

where the space inbetween the double apostrophes can be something like a dash or whatever you like.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->