I'm using ArcGIS pro 2.7 and building a model that uses the "Calculate field" tool. I'd like the field to be a new field and it needs to be of the data type "double".
When inputting the parameters there is no option to select data type of the output field. The documentation says this is an optional parameter. However, where and how should this be entered into the dialog box?
Below is an example of what I have so far (calculating area in hectares). Currently this creates the output field as "text" data type.
Cheers,
Oliver
not the pyt
What is a script tool?—ArcGIS Pro | Documentation
You can establish your parameters through a dialog... much easier for the novice
Thanks Dan. I think it might be easier to include the "add field" as a work around in the original model.
The tool should then add a new dropdown of field type if its not in the table. I hate to ask, but does the field name already exist in the table? Also what is the error icon beside the field?
Thanks David, the new dropdown is not appearing. The tool is being used in Modelbuilder and connected to an intermediate datasource. I've deleted all intermediate data and the yellow warning is to inform me that the field does not exist.
On further testing the dropdown doesn't appear when using the tool on intermediate data within Modelbuilder. It does appear if I use it on the original input feature class.
The workaround for intermediate data is to use the "add field" tool first within the model and then "calculate field"
So this appears to be more of a Model Builder issue than a Calculate Field issue.
In terms of Model Builder and an intermediate data source, I am guessing Model Builder isn't allowing the option because it has no idea what the schema will look like when the model is run. When you are pointing to an existing/original data set, Model Builder can lookup the schema of the data set and determine what fields do and don't exist, and hence give you the option to create a new field and set the data type. When working with intermediate data, it is derived and the schema won't be known until runtime so Model Builder isn't allowing that parameter to be set.
This makes a lot of sense. Thanks Joshua.
If memory serves this produces the field and allows you to do a calculation at once.
Calculate Fields (multiple) (Data Management)—ArcGIS Pro | Documentation
Even though it says "multiple" that includes one. The data type is determined from the calculation
I've got the same issue in Model Builder in Pro 2.8.2
I've found a workaround:
is this a bug?? Has it been submitted?
Same issue with Python the Field Type seems to vanish as a selection. I switch to Arcade which has helped.
For your distinct issue, I used Add Field so that I can be specific of the Field Name, Field Alias, and Type, before I ran the next Calculate Field.