Calculate - field is not nullable.

14259
12
03-31-2018 05:40 PM
JohnMorgan
Occasional Contributor

Hello,

I am working on a shapefile within ArcGIS Pro 2.1. I am trying to use the field calculator to add a few fields to the populated one I created. However, I keep getting the error message of field is not nullable.

Can anyone tell me what I am doing wrong?

Thanks,

Derek

12 Replies
DanPatterson_Retired
MVP Emeritus

shapefile fields are not nullable

http://pro.arcgis.com/en/pro-app/tool-reference/appendices/geoprocessing-considerations-for-shapefil...

you have to use a featureclass in a file geodatabase if you need that capability

JohnMorgan
Occasional Contributor

Thanks Dan. I had read that and was wondering if that was of issue. I did move it to a geodatabase at one point, but I think I was getting the same issue. I will try it again. A perplexing thing is that my calculations should be producing any nulls unless field calculator is treating 0+0+0 as null. 

0 Kudos
DanPatterson_Retired
MVP Emeritus

Moving to a geodatabase won't 'fix' the issue, you will probably have to create new fields since Alter Field only works on empty tables.

Moving from a shapefile to a geodatabase is sketchy at best if people haven't been careful to assign nulls in the shapefile properly. 

0 (zero) is the default for numeric field... sadly 0 is a valid observation and a valid number, it is totally unsuitable as a null as is the <null> itself in my opinion. 

Even in a geodatabase, you would be advised to use the largest or smallest integer possible for you operating system (ie 32 bit integers (min=-2147483648, max=2147483647, dtype=int32) and the same for float/doubles (min=-1.7976931348623157e+308, max=1.7976931348623157e+308, dtype=float64)  It just kind of makes things obvious that they just aren't 'observations' or 'measurements'

XanderBakker
Esri Esteemed Contributor

What values do you have for city_ords, prohib_in_ and prohib_by_ for those records that yield the error?
What field type do you have for those 3 input fields and the output field?

0 Kudos
JohnMorgan
Occasional Contributor

The values on those fields (both Long type) on are 0 or 1. I feel like I am doing something wrong with my calculate field statement. Like most folks, I am new to ArcGIS Pro. I added a new Long field to hold the results of the sum. Then I right-click on that new field and select Calculate Field. From there I put in the build up in the first input box following the new_field=  something like !city_ords! + !county_ord!. I leave the default of Python 3 as the expression type. But, everything I get nulls in the result of the new field. I am able to get it to run in a geodatabase as Dan suggested, but the values are still null. 

0 Kudos
DanPatterson_Retired
MVP Emeritus

!city_ords! + !county_ord!

would be the only part you should put in the expression section

You might want to put in a screen grab of exactly what you want.

And make sure that all the fields are numeric. 

If one of the row values is null, then the result will be null

JohnMorgan
Occasional Contributor

I am doing this now in a geodatabase and am verifying that the fields are all of the type numeric. From the screenshot below you can see the zeros in the table. There are some 1's further down in the table. 

Here is the setup I do:

setting up expression

Here is the result of the table

result

Thanks for all of your feedback and suggestions. I am just trying to learn some of the subtle nuances of ArcGIS here. 

Derek

0 Kudos
DanPatterson_Retired
MVP Emeritus

Is this a joined table?

CountyENDS:1 is a strange table name

you fields are out of order so that might be due to a join unless you rearrange things

Something is amiss.

I would copy those values to new fields (ie make a new field and do the newfield = oldfield thing), so that you have a clean file without joins (if indeed you have them) since you can only calculate values in the destination table, and not the table that you are joining over.

0 Kudos
JohnMorgan
Occasional Contributor

This layer is not currently in a joined state. I believe the CountyENDS:1 is occurring because I have another layer added to the same project with the same name. One is from a standalone shapefile and the other is within a geodatabase, but they both have the same names. I think that Field Calculate tool just adds that :# on there from multiple layers with the same name. 

0 Kudos