Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Python in Field Calculator - mod function

$
0
0
There are two fields in a topo line feature class, Elev for elevation and LineType10. I want to set LineType10 to 1 if Elev % 10 == 0, and 2 otherwise. The purpose is to be able to symbolize at ten foot intervals. I've got the code below, which doesn't give errors but also doesn't set any values. I've also used the plain % mod symbol. Any ideas why this doesn't run? Thanks.

Pre-Logic
Code:

def SetTen(elv, line):
  if math.fmod(elv) == 0:
    line = 1
  else:
    line = 2
  return line

Window
Code:

SetTen( !Elev!, !LineType10!)
Attached Thumbnails
Click image for larger version

Name:	SetTen.PNG‎
Views:	N/A
Size:	31.6 KB
ID:	30578  

Viewing all articles
Browse latest Browse all 2485

Trending Articles