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
Oliver - what I would do is create a new field and make it a DOUBLE. One the field exists, then you can run the Calculate Field geoprocessing tool.
Thanks Robert. I was looking at that as a workaround. Is there no way to add optional arguments through the codeblock?
You're welcome Oliver - not sure about adding optional arguments in the codeblock as I have not done that workflow. I'll do some digging around and get back to you.
I got it to work NOT using the CodeBlock - see attached image.
Thanks Robert,
I'm not getting the same behaviour. I'm on ArcPro 2.7 and using the tool within modelbuilder. But as you can see the "Field Type" setting is not appearing.
The yellow warning next to field name is to inform me that the field doesn't exist and will be created.
However, I just tried it with the original input (not intermediate data) and that dropdown does appear. So it would seem for intermediate data the "add field" tool would need to be run first.
field type is determined by what is calculated, you don't need to specify it. If you need a double/float and you are afraid of getting an integer, multiply the calculation by... 1.0 .... it will become double/float aka 64 bit floating point
Thanks Dan,
I expected the field type to be determined by what is calculated but that doesn't seem to be happening. The expression I'm using is
!Shape.area@hectares!
Here's a gif of the the tool not providing the second dropdown (as per Robert's answer) and creating a text field when a double or float would be expected.
Pro 2.7... Maybe try moving your model to a conventional python script tool
Thanks Dan,
I'm not sure how to do that. Would that be a .pyt toolbox? Having looked at the .pyt it's not really the desired workflow as I was hoping to use ModelBuilder for non-coders.
Cheers,
Oliver