<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: GetParameter() - Double Value needs to be re-cast as a Double (from string) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672669#M74995</link>
    <description>&lt;P&gt;So, I tested this just now on 3.5.5 and I don't have any problem?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_0-1765554912943.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/145371iB3E7AB89B904B4C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_0-1765554912943.png" alt="AlfredBaldenweck_0-1765554912943.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"""
Script documentation

- Tool parameters are accessed using arcpy.GetParameter() or 
                                     arcpy.GetParameterAsText()
- Update derived parameter values using arcpy.SetParameter() or
                                        arcpy.SetParameterAsText()
"""
import arcpy


def script_tool(param0):
    """Script code goes below"""
    x = float(10)
    y = param0+x
    arcpy.AddMessage(y)
    return

if __name__ == "__main__":
    param0 = arcpy.GetParameter(0)
    script_tool(param0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_1-1765554980164.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/145372i79CBC1217629B4A6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_1-1765554980164.png" alt="AlfredBaldenweck_1-1765554980164.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_2-1765554994406.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/145373i91FFBDCDB5B587E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_2-1765554994406.png" alt="AlfredBaldenweck_2-1765554994406.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'd double-check the types of everything again. You can arcpy.AddMessage(type(x)) to make sure.&lt;/P&gt;&lt;P&gt;If everything is actually as intended, this is super weird and would probably worth trying to replicate in an unrelated toolbox with a very simple tool (as above).&lt;/P&gt;</description>
    <pubDate>Fri, 12 Dec 2025 15:58:16 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2025-12-12T15:58:16Z</dc:date>
    <item>
      <title>GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672366#M74977</link>
      <description>&lt;P&gt;In my tool, I have one parameter that accepts a double value.&amp;nbsp;In my script, I have to re-cast the value as a float() type.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;proximity_threshold = float(arcpy.GetParameterAsText(1))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;This feels kind of silly to have to re-cast the value that was originally input as the correct data type.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a more elegant solution here that I'm not seeing?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 17:37:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672366#M74977</guid>
      <dc:creator>MGAL</dc:creator>
      <dc:date>2025-12-11T17:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672370#M74978</link>
      <description>&lt;P&gt;Yeah just use arcpy.GetParameter()&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 17:43:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672370#M74978</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2025-12-11T17:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672392#M74979</link>
      <description>&lt;P&gt;That's what I thought too...&lt;/P&gt;&lt;P&gt;When I change the line to...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;proximity_threshold = arcpy.GetParameter(1)
arcpy.AddMessage(proximity_threshold)
arcpy.AddMessage(type(proximity_threshold))&lt;/LI-CODE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;if near_dist &amp;lt; proximity_threshold:&lt;BR /&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;TypeError: '&amp;lt;' not supported between instances of 'float' and 'str'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Messages before the failure show 10, and &amp;lt;class 'str'&amp;gt; respectively. Here's my tool parameter config for good measure.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MGAL_0-1765476976378.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/145292i29BBBABBEA9060CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MGAL_0-1765476976378.png" alt="MGAL_0-1765476976378.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;-M&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 18:20:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672392#M74979</guid>
      <dc:creator>MGAL</dc:creator>
      <dc:date>2025-12-11T18:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672410#M74980</link>
      <description>&lt;P&gt;Alfred's suggestion is the intended way to get a Double parameter so I can't say why it's failing for you. As a workaround, try getting all your parameters using &lt;FONT face="courier new,courier"&gt;arcpy.GetParameterInfo()&lt;/FONT&gt; and then use the &lt;FONT face="courier new,courier"&gt;value&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;valueAsText&lt;/FONT&gt; parameters as needed. For example, a drop-in replacement for the first line of your sample is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;proximity_threshold = arcpy.GetParameterInfo()[1].value&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 18:42:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672410#M74980</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-12-11T18:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672413#M74981</link>
      <description>&lt;P&gt;Dumb question, but what's the parameter type of near_dist?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 18:56:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672413#M74981</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2025-12-11T18:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672456#M74985</link>
      <description>&lt;P&gt;near_dist isn't a parameter... it's derived from the script. it's the variable for the output of .distanceTo() the geometry method (&lt;A href="https://pro.arcgis.com/en/pro-app/3.3/arcpy/classes/pointgeometry.htm#:~:text=points%20in%20common.-,distanceTo,-(other)" target="_blank" rel="noopener"&gt;outputs double&lt;/A&gt;).&amp;nbsp;&lt;/P&gt;&lt;P&gt;the script joins information from two different line feature classes, to a table of inspection points. where the tables' ID's don't match 1:1 (for reasons i don't want to get into :/) the script reverts to a proximity match. the proximity match is the min threshold that automatically matches the line to the point.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def find_closest_line(pcs_geom, input_fc, oid_idx, shape_idx, proximity_threshold):
    near_dists = {}
    for feats in input_fc: 
        for k,v in feats.items():
            oid = v[oid_idx]
            shape = v[shape_idx]
        near_dist = pcs_geom.distanceTo(shape)
        if near_dist &amp;lt; proximity_threshold:
            # arcpy.AddMessage("Bullseye!")
            return list(feats.values())[0]
        else:
            near_dists[oid] = near_dist
    if len(near_dists) == 0:
        return False
    closest_oid = sorted(near_dists.items(), key=lambda item: item[1])[0][0]
    closest_feat = [oid for rows in input_fc for oid in rows.keys() if oid == closest_oid]
    for feats in input_fc:
        for k,v in feats.items():
            if v[oid_idx] == closest_oid:
                return v
    return closest_feat&lt;/LI-CODE&gt;&lt;P&gt;(note that "input_fc" is really a list of python dictionaries derived from SearchCursor)&lt;/P&gt;&lt;P&gt;depending on the size &amp;amp; location quality of the incoming dataset, this value can be adjusted to speed up the process, or slow down the process to get better accuracy. the tool also has a boolean parameter that puts the process into a test mode to allow the user to see the results as a formatted arcpy message, before the data is appended to the master inspection table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;not a dumb question!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 20:24:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672456#M74985</guid>
      <dc:creator>MGAL</dc:creator>
      <dc:date>2025-12-11T20:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672458#M74986</link>
      <description>&lt;P&gt;you can float both with issue in python&lt;/P&gt;&lt;LI-CODE lang="python"&gt;(float(1) == float("1")) and (float("1.0") == float(1.0))
True&lt;/LI-CODE&gt;&lt;P&gt;so if it isn't an integer, float/double or text, what is it?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 20:27:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672458#M74986</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-12-11T20:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672464#M74987</link>
      <description>&lt;P&gt;That worked...&lt;/P&gt;&lt;P&gt;I'm still not understanding why the double data type is so buried in the tool. For example, I also have a boolean parameter in this tool, and the ".GetParameter()" method works w/o transformation.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my mind, the toolboxes parameters should dictate the data type of the incoming data as it was configured in the toolbox. Otherwise, what's the point of setting a data type?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 20:38:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672464#M74987</guid>
      <dc:creator>MGAL</dc:creator>
      <dc:date>2025-12-11T20:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672470#M74989</link>
      <description>&lt;P&gt;It is one reason that I use the old school sys.argv&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/accessing-parameters-in-a-script-tool.htm" target="_blank"&gt;Accessing parameters in a script tool—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;you just have to remember that sys.argv[0] is the script and sys.argv[1] is parameter id 0&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 20:44:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672470#M74989</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-12-11T20:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: GetParameter() - Double Value needs to be re-cast as a Double (from string)</title>
      <link>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672669#M74995</link>
      <description>&lt;P&gt;So, I tested this just now on 3.5.5 and I don't have any problem?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_0-1765554912943.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/145371iB3E7AB89B904B4C3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_0-1765554912943.png" alt="AlfredBaldenweck_0-1765554912943.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"""
Script documentation

- Tool parameters are accessed using arcpy.GetParameter() or 
                                     arcpy.GetParameterAsText()
- Update derived parameter values using arcpy.SetParameter() or
                                        arcpy.SetParameterAsText()
"""
import arcpy


def script_tool(param0):
    """Script code goes below"""
    x = float(10)
    y = param0+x
    arcpy.AddMessage(y)
    return

if __name__ == "__main__":
    param0 = arcpy.GetParameter(0)
    script_tool(param0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_1-1765554980164.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/145372i79CBC1217629B4A6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_1-1765554980164.png" alt="AlfredBaldenweck_1-1765554980164.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_2-1765554994406.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/145373i91FFBDCDB5B587E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_2-1765554994406.png" alt="AlfredBaldenweck_2-1765554994406.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'd double-check the types of everything again. You can arcpy.AddMessage(type(x)) to make sure.&lt;/P&gt;&lt;P&gt;If everything is actually as intended, this is super weird and would probably worth trying to replicate in an unrelated toolbox with a very simple tool (as above).&lt;/P&gt;</description>
      <pubDate>Fri, 12 Dec 2025 15:58:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getparameter-double-value-needs-to-be-re-cast-as-a/m-p/1672669#M74995</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2025-12-12T15:58:16Z</dc:date>
    </item>
  </channel>
</rss>

