I want to assign numbers to a certain types of building and I need to use field calculator. I tried many different versions of this and I still can't find what's wrong. Could you tell me where do I make a mistake?
![Printscreen]1
-
obyv column is a short type... I tried float (among others) but didnt help.Robert Spal– Robert Spal2015年10月27日 12:09:09 +00:00Commented Oct 27, 2015 at 12:09
-
9Looks like a script for VB instead of Python, perhaps check the parser for VB Script?Joseph– Joseph2015年10月27日 12:12:53 +00:00Commented Oct 27, 2015 at 12:12
-
Artwork 21 has answered this but just for your info (and sanity) write your field calculator expressions in a text editor that supports python syntax highlighting. Notepad++ or similar. It will greatly decrease frustration - the field calculator is such an unfriendly tool.kingmi– kingmi2015年11月04日 11:24:36 +00:00Commented Nov 4, 2015 at 11:24
-
Yep, I just found out how unfriendly it is. I will use notepad next time. ThanksRobert Spal– Robert Spal2015年11月05日 11:52:24 +00:00Commented Nov 5, 2015 at 11:52
3 Answers 3
Your python syntax is not correct, try:
def myFunc(typ, oby):
if typ == 'D':
return 'Z'
else: return '25'
function call:
myFunc(!TYP!, !obyy!)
Here is a working if/then statement in VBS.
For your code, I would think something like this:
Dim result
if [TYP] = "D" then
result = "Z"
else result = "25"
end if
And:
obyv = result
Looks like you used "=" rather than "==".
def countRows(rowcount):
import arcpy
if %rowcount% == 0:
return "false"
else:
return "true"
-
There is no need to
import arcpy
and I think doing so would make this run very slowly.2015年11月04日 10:50:58 +00:00Commented Nov 4, 2015 at 10:50
Explore related questions
See similar questions with these tags.