<?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: Python script parameters for Integer not working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508502#M39938</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the GetParameterAsText method means that all parameter values are converted to text before being passed to your code.&amp;nbsp; Therefore you have to convert them back to their original type.&amp;nbsp; You need to modify you code to:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;min_scale = int(arcpy.GetParameterAsText(5))
max_scale = int(arcpy.GetParameterAsText(6))‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, you may want to add validation to ensure they are valid values (not Null or out of range) before the parameters are converted and passed to the rest of your code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:16:57 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2021-12-11T22:16:57Z</dc:date>
    <item>
      <title>Python script parameters for Integer not working</title>
      <link>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508500#M39936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;am using a Python library called&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/ucd-cws/arcpy_metadata" rel="nofollow noreferrer" style="color: #358daa; border: 0px; font-weight: inherit; text-decoration: none;"&gt;arcpy_metadata&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that uses 2 datatype called&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE style="background-color: #eff0f1; border: 0px; font-weight: inherit; padding: 1px 5px;"&gt;max_scale&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE style="background-color: #eff0f1; border: 0px; font-weight: inherit; padding: 1px 5px;"&gt;min_scale&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that take integers:&lt;A href="https://i.stack.imgur.com/Qr3iS.png" rel="nofollow noreferrer" style="color: #358daa; border: 0px; font-weight: inherit; text-decoration: none;"&gt;&lt;IMG alt="enter image description here" src="https://i.stack.imgur.com/Qr3iS.png" style="border: 0px; font-weight: inherit;" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em;"&gt;My code for that is just:&lt;/P&gt;&lt;PRE class="" style="color: #393318; background-color: #eff0f1; border: 0px; margin: 0px 0px 1em; padding: 5px;"&gt;&lt;CODE style="background-color: #eff0f1; border: 0px; font-weight: inherit;"&gt;&lt;SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;"&gt;import&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; arcpy_metadata &lt;/SPAN&gt;&lt;SPAN class="" style="color: #101094; border: 0px; font-weight: inherit; font-size: 13px;"&gt;as&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; md&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;....&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;min_scale &lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;"&gt;GetParameterAsText&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;"&gt;5&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;max_scale &lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;"&gt;GetParameterAsText&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #7d2727; border: 0px; font-weight: inherit; font-size: 13px;"&gt;6&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;....&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;metadata &lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; md&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;"&gt;MetadataEditor&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;file&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;...&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;metadata&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; min_scale &lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; min_scale metadata&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;max_scale &lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; max_scale&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em;"&gt;I am trying to turn this into a Python script in ArcMap toolbox. An example input for the max and min scale would 5000 and 150000000. Since there is no&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE style="background-color: #eff0f1; border: 0px; font-weight: inherit; padding: 1px 5px;"&gt;integer&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;type and I don't really need decimals, I just entered&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE style="background-color: #eff0f1; border: 0px; font-weight: inherit; padding: 1px 5px;"&gt;double&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;when configuring the parameters for the tool. I also set it as ``optional`.&lt;A href="https://i.stack.imgur.com/9HXJY.png" rel="nofollow noreferrer" style="color: #358daa; border: 0px; font-weight: inherit; text-decoration: none;"&gt;&lt;IMG alt="enter image description here" src="https://i.stack.imgur.com/9HXJY.png" style="border: 0px; font-weight: inherit;" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em;"&gt;When I run the tool however, I keep getting the following error. What am I doing wrong here?&lt;/P&gt;&lt;PRE class="" style="color: #393318; background-color: #eff0f1; border: 0px; margin: 0px 0px 1em; padding: 5px;"&gt;&lt;CODE style="background-color: #eff0f1; border: 0px; font-weight: inherit;"&gt;&lt;SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;"&gt;RuntimeWarning&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt;:&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;"&gt;Input&lt;/SPAN&gt;&lt;SPAN class="" style="color: #303336; border: 0px; font-weight: inherit; font-size: 13px;"&gt; value must be of type &lt;/SPAN&gt;&lt;SPAN class="" style="color: #2b91af; border: 0px; font-weight: inherit; font-size: 13px;"&gt;Integer&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2018 15:37:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508500#M39936</guid>
      <dc:creator>JustinBridwell2</dc:creator>
      <dc:date>2018-09-05T15:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python script parameters for Integer not working</title>
      <link>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508501#M39937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your picture shows long (integer), but you say double (float). GetParameterAsText returns a string. This seems to be a data type issue, so I'd start by forcing your parameters into the correct type.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2018 16:24:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508501#M39937</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2018-09-05T16:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python script parameters for Integer not working</title>
      <link>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508502#M39938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the GetParameterAsText method means that all parameter values are converted to text before being passed to your code.&amp;nbsp; Therefore you have to convert them back to their original type.&amp;nbsp; You need to modify you code to:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;min_scale = int(arcpy.GetParameterAsText(5))
max_scale = int(arcpy.GetParameterAsText(6))‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, you may want to add validation to ensure they are valid values (not Null or out of range) before the parameters are converted and passed to the rest of your code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:16:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508502#M39938</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-11T22:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python script parameters for Integer not working</title>
      <link>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508503#M39939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just got the answer. Feel kinda dumb for missing the whole "GetParameterAs&lt;STRONG&gt;Text"&amp;nbsp;&lt;/STRONG&gt;part. I just added metadata.max_scale = int(max_scale) and it worked fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2018 16:37:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508503#M39939</guid>
      <dc:creator>JustinBridwell2</dc:creator>
      <dc:date>2018-09-05T16:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python script parameters for Integer not working</title>
      <link>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508504#M39940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep, that was totally the issue. Rookie mistake.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Sep 2018 16:37:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-parameters-for-integer-not-working/m-p/508504#M39940</guid>
      <dc:creator>JustinBridwell2</dc:creator>
      <dc:date>2018-09-05T16:37:50Z</dc:date>
    </item>
  </channel>
</rss>

