Labelling Depth points in ArcMap

3816
5
02-16-2014 06:17 PM
by Anonymous User
Not applicable
Original User: azzwan

I am not sure if this is the best forum to post this question but hopefully someone can point me in the right direction.

I have a thinned bathymetry points file where the depths are negative in sign and drying heights are positive.  I intend to create a map and label my points as depths as you would see them on a nautical chart.  For example the the negative depths become positive values and the depths are rounded to 1 decimal place etc.  I have a a small VB Script for doing just that and it works quite well.  However, I have a problem, the drying heights appear as negative numbers once labelled.  I would like to have the drying heights remain positive sign but become underlined labels.   I do not know much about scripting so if anyone can help me out with a way to do this it would be greatly appreciated.

To enter the label script I go to layer properties>label>test string Expression>Under Expression I tick the advanced option and then paste in the VBScript.  I then click on Verify to make sure that it works and then OK.


Here is an example of the points file [ATTACH=CONFIG]31500[/ATTACH]

Here is an example of how the points are labelled[ATTACH=CONFIG]31501[/ATTACH]

Here is the current VB Script that I am using:

Function FindLabel ( [Depth] )
fltDepth = Round([Depth] * -1, 1)
strChar = "."
intPos = InStr(1, fltDepth, strChar)
intLen1 = Len(fltDepth)
intLen2 = intLen1 - intPos
If intPos <> 0 Then
  intStart = Left(fltDepth, intPos - 1)
  intLast = Right(fltDepth, intLen2)
  'strOutput = intStart & " " & intLast
  FindLabel = intStart & "<SUB>" & intLast & "</SUB>"
Else
  FindLabel = fltDepth
End If
  'FindLabel = strOutput
End Function


Regards, Aaron
0 Kudos
5 Replies
SabeshanSrinivasan
New Contributor
Hello Aaron,

Looks like you might need a conditional branch around the second statement:

fltDepth = Round([Depth] * -1, 1)

Where you check if [Depth] is greater than zero and only apply the multiplication factor of -1 if it is less than zero. As for your second question on how to apply underlining only to the positive drying heights, you could apply it only if the depths value is greater than zero in your conditional block.

Thanks,
Sabeshan Srinivasan
0 Kudos
by Anonymous User
Not applicable
Original User: azzwan

Hello Aaron,

Looks like you might need a conditional branch around the second statement:

fltDepth = Round([Depth] * -1, 1)

Where you check if [Depth] is greater than zero and only apply the multiplication factor of -1 if it is less than zero. As for your second question on how to apply underlining only to the positive drying heights, you could apply it only if the depths value is greater than zero in your conditional block.

Thanks,
Sabeshan Srinivasan


Sabeshan, thanks for the reply.  I understand what you are saying but my lack of script writing knowledge prevents me from going any further.  Would you mind modifying the script that I submitted to show me how to do this?
0 Kudos
SabeshanSrinivasan
New Contributor
Aaron, try this out:

Function FindLabel ( [Depth] )
 If Round([Depth]) > 0 Then
  fltDepth = Round([Depth], 1)
 Else
  fltDepth = Round([Depth] * -1, 1)
 End If
 
 strChar = "."
  intPos = InStr(1, fltDepth, strChar)
 intLen1 = Len(fltDepth)
  intLen2 = intLen1 - intPos
  
  If intPos <> 0 Then
   intStart = Left(fltDepth, intPos - 1)
  intLast = Right(fltDepth, intLen2)
   'strOutput = intStart & " " & intLast
      
   FindLabel = intStart & "<SUB>" & intLast & "</SUB>"
  Else
   FindLabel = fltDepth
 End If
 
 If fltDepth > 0 Then
  FindLabel = "<UND>" & FindLabel & "</UND>"
 End If
 
 'FindLabel = strOutput
End Function


I basically added a conditional check in the beginning to only negate the value returned from [Depth] if it was less than 0. I also added logic at the end to apply an underline ("<UND>" tag) if the depth was positive. Hope this helps.

One word of caution - I didn't test the code changes as I directly wrote them here. The changes are simple enough and should work but don't be surprised if you see an error due to some simple mistake I may have made!

Cheers,
Sabeshan
0 Kudos
by Anonymous User
Not applicable
Original User: azzwan

Hi Sabeshan,

Thank you for the modified script.  I have trialled it but I did not get the results that I expected.

This first screen capture shows the points labelled with your script unmodified.   [ATTACH=CONFIG]31748[/ATTACH]

Notice that all the depths are underlined

I then modified the script by replacing the fltDepth = Round([Depth] * -1, 1) with fltDepth = Round([Depth] * 1, 1) and this is the result that I got  [ATTACH=CONFIG]31749[/ATTACH]

Notice that the drying height in the top left is labelled correctly but all of the other depths have picked up the negative sign.

Do you have any more ideas.  Thanks again for your time.

Regards,
Aaron Godwin
0 Kudos
arlandeleon
New Contributor
Function FindLabel ( [Depth] )
If Round([Depth]) < 0 Then
fltDepth = Round([Depth] * -1, 1)
Else
fltDepth = Round([Depth] , 1)
End If

strChar = "."
intPos = InStr(1, fltDepth, strChar)
intLen1 = Len(fltDepth)
intLen2 = intLen1 - intPos

If intPos <> 0 Then
intStart = Left(fltDepth, intPos - 1)
intLast = Right(fltDepth, intLen2)
'strOutput = intStart & " " & intLast

FindLabel = intStart & "<SUB>" & intLast & "</SUB>"
Else
FindLabel = fltDepth
End If

If fltDepth < 0 Then
FindLabel = "<UND>" & FindLabel & "</UND>"
End If

'FindLabel = strOutput
End Function
0 Kudos