<?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: Filter of parameter for python tool? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133169#M10367</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/405782"&gt;Dan Patterson&lt;/A&gt;‌ Thanks for your reply, what I want to do to call one function rescale (input, mode, other parameters)&lt;/P&gt;&lt;P&gt;inside mode there is different method {edge, warp,}, if the user select one of the method it will be different result ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Jul 2020 16:11:44 GMT</pubDate>
    <dc:creator>MinaAlsaad</dc:creator>
    <dc:date>2020-07-24T16:11:44Z</dc:date>
    <item>
      <title>Filter of parameter for python tool?</title>
      <link>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133167#M10365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I have different methods within the same&amp;nbsp;script tool how I can apply filter so that the user will select different method and run code&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2020 15:29:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133167#M10365</guid>
      <dc:creator>MinaAlsaad</dc:creator>
      <dc:date>2020-07-24T15:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Filter of parameter for python tool?</title>
      <link>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133168#M10366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for one of your parameters, define it as a text parameter and make a value list with your options.&lt;/P&gt;&lt;P&gt;For each option, create a def that performs the task&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; blah


method &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;# a value list of the method names&lt;/SPAN&gt;
params &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;method1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"""method1 functionality"""&lt;/SPAN&gt;
    Do stuff
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; something

&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;method2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"""method2 functionality"""&lt;/SPAN&gt;
    Do stuff
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; something

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; method &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"first"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; method1&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; method2&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;


&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Here is the amazing result : {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:28:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133168#M10366</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-12-11T07:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Filter of parameter for python tool?</title>
      <link>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133169#M10367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/405782"&gt;Dan Patterson&lt;/A&gt;‌ Thanks for your reply, what I want to do to call one function rescale (input, mode, other parameters)&lt;/P&gt;&lt;P&gt;inside mode there is different method {edge, warp,}, if the user select one of the method it will be different result ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2020 16:11:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133169#M10367</guid>
      <dc:creator>MinaAlsaad</dc:creator>
      <dc:date>2020-07-24T16:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Filter of parameter for python tool?</title>
      <link>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133170#M10368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/405782"&gt;Dan Patterson&lt;/A&gt;‌ What I meant only I want to change one parameter and run the tool?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2020 16:15:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133170#M10368</guid>
      <dc:creator>MinaAlsaad</dc:creator>
      <dc:date>2020-07-24T16:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Filter of parameter for python tool?</title>
      <link>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133171#M10369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/415295"&gt;Mina Alsaad&lt;/A&gt;‌, I read your question and your responses, and I am having a hard time figuring out your question.&amp;nbsp; I realize there may be a language barrier occurring, but that makes it even more important to provide specifics and examples rather than speaking in general.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2020 17:00:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133171#M10369</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-07-24T17:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Filter of parameter for python tool?</title>
      <link>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133172#M10370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply,&amp;nbsp;Sure I am trying to use ready function that need arguments such (raster, scale , and method)&amp;nbsp;&lt;/P&gt;&lt;P&gt;what I need the user to select the method from drop down menu and run the tool ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2020 17:06:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133172#M10370</guid>
      <dc:creator>MinaAlsaad</dc:creator>
      <dc:date>2020-07-24T17:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Filter of parameter for python tool?</title>
      <link>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133173#M10371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand you correctly, you have a function with 3 parameters:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;input raster&lt;/LI&gt;&lt;LI&gt;scale&lt;/LI&gt;&lt;LI&gt;a method which changes how your function manipulates the raster&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use this function inside a script tool, you have to define 3 parameters for the tool:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;input raster&lt;/LI&gt;&lt;LI&gt;scale&lt;/LI&gt;&lt;LI&gt;method&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;In the method parameter, define a filter list with valid method names. This way, you have a dropdown list with predefined things like "warp", "edge", etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you change your script:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# imports&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# get the script parameters&lt;/SPAN&gt;
raster_param &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
scale_param &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# convert to int or float as needed&lt;/SPAN&gt;

method_param &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# this parameter has a filter list,&lt;/SPAN&gt;
                                           &lt;SPAN class="comment token"&gt;# so you know it can only be "warp" or "edge".&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# define your function (I think you already have that)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;your_function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;raster&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; scale&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; method&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;# stuff&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; method &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"warp"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;# warp implementation&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; method &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"edge"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="comment token"&gt;# edge implementation&lt;/SPAN&gt;
    &lt;SPAN class="comment token"&gt;# more stuff&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# call your function&lt;/SPAN&gt;
your_function&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;raster_param&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; scale_param&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; method_param&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:28:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/filter-of-parameter-for-python-tool/m-p/133173#M10371</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-12-11T07:28:10Z</dc:date>
    </item>
  </channel>
</rss>

