Changing NULL values with model builder

1537
4
Jump to solution
05-22-2013 02:58 AM
TanyaEsteves
New Contributor
Hi.

I'm using model builder to build a tool, where at a certain point, I need to take the Z elevation values from the feature class that are NULL and turn them into the value 0 (zero). To do so, I'm using the calculate field tool. I just have a problem... I know very little of VB and NOTHING of python... I was hoping someone could help me create the appropriate code to change the values I need?

I'm guessing it should be something very simple... like an if..then statement? Something like: if Z=Null then Z=0. I just need to "translate" it into programming language.

Any help... please?

Thanks in advance.http://forums.arcgis.com/images/icons/icon7.png
0 Kudos
1 Solution

Accepted Solutions
RichardFairhurst
MVP Honored Contributor
Well, so far I got:

Dim Z
If IsNull () = "True" then
= 0
End if

But it doesn't work... any suggestions?

Thanks.


To do this you need to check the codeblock checkbox.  You also have to handle the situation where the Z field has a value and is not Null.  Finally you cannot use a field name as the output of the calculation only a variable which is only resolved to a specific field by doing the calculation on a given field.

Parser:  VBScript

Prelogic codeblock:
If IsNull() Then   Output = 0 Else   Output =  End If


Expression:  Output

View solution in original post

4 Replies
JimCousins
MVP Regular Contributor
The correct syntax for the NULL keyword is:
"Z" IS NULL
do not use the "=" with NULL.
Regards,
Jim
0 Kudos
TanyaEsteves
New Contributor
Well, so far I got:

Dim Z
If IsNull () = "True" then
= 0
End if

But it doesn't work... any suggestions?

Thanks.
0 Kudos
RichardFairhurst
MVP Honored Contributor
Well, so far I got:

Dim Z
If IsNull () = "True" then
= 0
End if

But it doesn't work... any suggestions?

Thanks.


To do this you need to check the codeblock checkbox.  You also have to handle the situation where the Z field has a value and is not Null.  Finally you cannot use a field name as the output of the calculation only a variable which is only resolved to a specific field by doing the calculation on a given field.

Parser:  VBScript

Prelogic codeblock:
If IsNull() Then   Output = 0 Else   Output =  End If


Expression:  Output
TanyaEsteves
New Contributor
Dear rfairhur24,

Thank you so much for your help. It worked perfectly!! I really need to get my head around programming!! http://forums.arcgis.com/images/icons/icon11.png

Best wishes.
0 Kudos