Field calculate vb to python

830
8
Jump to solution
10-16-2018 09:35 AM
TonyAlmeida
Occasional Contributor II

I have a model that i am trying to add a field then do a filed calculate but i am having trouble getting it right. I have tried the following in VB but keep getting the following error. So i was wondering if someone could help maybe right this in python unless someone can help me get the VB script right.

Thanks.

VB Error

ERROR 999999: Error executing function.
Expected end of statement
Failed to execute (Calc Index 50')

Pre-Logis Script Code:

dim cont as Long
If([CONTOUR_FEET] MOD 50=0) Then
cont=1
Else
cont=0
End if

INDEX_50FT=
cont
0 Kudos
1 Solution

Accepted Solutions
JoeBorgione
MVP Emeritus

Python in Field calculator:

That should just about do it....

View solution in original post

8 Replies
TonyAlmeida
Occasional Contributor II

Never mind i for got that VB doesn't let you declare any data types.

dim cont
If([CONTOUR_FEET] MOD 50=0) Then
cont=1
Else
cont=0
End if

But my code doesn't do anyting i have "0" in the INDEX_50ft field.
0 Kudos
JoeBorgione
MVP Emeritus

Python in Field calculator:

That should just about do it....
TonyAlmeida
Occasional Contributor II

Thanks for the help on the python code!

I am still not able to get anything other than "0" in the fields.

I am trying to create a contour map that i could make very 50 or 100 contour stand out.

attached a pic of what my contour data looks like.

0 Kudos
DarrenWiens2
MVP Honored Contributor

Presumably some of your records are truly divisible by 50?

TonyAlmeida
Occasional Contributor II

Darren i just thought of that. It doesn't seem as some of my records are. I mad contours from a DEM with the Contour tool with contour interval = 2. I assuming in need to re-create my contours from the DEM at every 50 feet if so how do i do that?

0 Kudos
JoeBorgione
MVP Emeritus

Seems to me that if you make contours at every 50 feet, you won't need the expression.  Looks like you made contours every 2 feet (or 2 meters?  I don't know what units your dem is in...) Assuming units are feet, why don't you try 10 feet intervals?  or 20 feet intervals?  What level of detail are you looking to display? What is the topography of your area of interest?  If you are looking at farm land in Kansas, perhaps your 2 foot interval is appropriate: if you are looking at the Alaska Range, you'll want to go much greater...

That should just about do it....
0 Kudos
TonyAlmeida
Occasional Contributor II

I wasn't sure how to make contours, the approach i took was us the Focal Statistics tool run that on the DEM, then use the contour tool. Which I didn't know what actually the "contour interval" meant. I guess what through me off was that the DEM was in meters. I was making it harder that what i should have been.

My main object was to create a contour map that would display contours every 50 or 100 feet a different color, a nice cartographic appearance. Which is why i created a new fields.

JoeBorgione
MVP Emeritus

I was making it harder that what i should have been

Haven't done that since.... This morning!

That should just about do it....
0 Kudos