Does arcpy.GetParameterAsText() have a data type?

As the name GetParameterAsText() indicates, or the documentation states, the value will be converted to text, or like we call it: a string.

Gets the specified parameter as a **text** string by its index position from the list of parameters. 

So, if the user enteres coordinates, such as 35.5432 then the tool would get understand those as '35.5432', a string. This is, however, not necessarily what we want, so, in this case, we would convert that string back to a number. As we are interested in the decimals we have to convert it to a float (not an integer, as it would chop off the decimals), and use float().

Note that you could also have converted right when getting the parameters:

inX = float(arcpy.GetParameterAsText(0))

In my opinion that makes the code easier to read, and less cluttered later on.

The important part with GetParameterAsText() is what you define in ArcGIS, when you build the tool. Here the more important, ArcGIS-internal data type, is defined. It can be daunting at first, and sometimes one has to try multiple times until finding the correct type. The interface looks like this (sorry, German interface!):

enter image description here

But the bottom line is, it would arrive in your Python as text, so sometimes conversions are necessary, such as the float() in this case!


To respect the type of input set on a Python script tool's dialog you would need to use arcpy.GetParameter().

By using arcpy.GetParameterAsText() my understanding is that whatever is ingested has its data type converted to a string.

It appears that float is being used here to convert those strings into floating point numbers.