<?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: Getting zmin zmax of a raster parameter in a tool validation in ArcGIS Desktop 10.7 toolbox Python script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/getting-zmin-zmax-of-a-raster-parameter-in-a-tool/m-p/1016822#M59513</link>
    <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - GeoNet, The Esri Community&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;def updateParameters(self):&lt;/LI-CODE&gt;&lt;P&gt;Use python for the language... It will make your def happy again&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def updateParameters(self):&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The parameter type would be "any" and you have to deal with either a raster or a number being added&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jan 2021 13:06:05 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2021-01-14T13:06:05Z</dc:date>
    <item>
      <title>Getting zmin zmax of a raster parameter in a tool validation in ArcGIS Desktop 10.7 toolbox Python script</title>
      <link>https://community.esri.com/t5/python-questions/getting-zmin-zmax-of-a-raster-parameter-in-a-tool/m-p/1016819#M59512</link>
      <description>&lt;P&gt;I am developing a python script tool (my first one). The tool has 3 input parameters:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;a raster&lt;/LI&gt;&lt;LI&gt;z min&lt;/LI&gt;&lt;LI&gt;z max&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I am trying to get automatically z min and z max after the user specify the raster using the validation script but I got this error: &lt;STRONG&gt;TypeError: expected a raster or&amp;nbsp; layer&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This is my code (commented lines are other attempts I tried without results):&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-function"&gt;&lt;SPAN class="hljs-keyword"&gt;def&lt;/SPAN&gt; &lt;SPAN class="hljs-title"&gt;updateParameters&lt;/SPAN&gt;(&lt;SPAN class="hljs-params"&gt;self&lt;/SPAN&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;
&lt;SPAN class="hljs-string"&gt;"""Modify the values and properties of parameters before internal
validation is performed.  This method is called whenever a parameter
has been changed."""&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; self.params[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;].altered:
  &lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; self.params[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;].value:
    &lt;SPAN class="hljs-comment"&gt;#rst_ds = self.params[0]&lt;/SPAN&gt;
    rst_ds = self.params[&lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt;].value
    self.params[&lt;SPAN class="hljs-number"&gt;1&lt;/SPAN&gt;].value = arcpy.Raster(rst_ds).minimum

    &lt;SPAN class="hljs-comment"&gt;#self.params[2].value = arcpy.Raster(rst_ds.replace('\\','/')).maximum&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;#arcpy.MakeRasterLayer_management(rst_ds, "rst_lyr")&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;#self.params[1].value = arcpy.Raster("rst_lyr").minimum&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;return&lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 12:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-zmin-zmax-of-a-raster-parameter-in-a-tool/m-p/1016819#M59512</guid>
      <dc:creator>MarcoBelotti</dc:creator>
      <dc:date>2021-01-14T12:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Getting zmin zmax of a raster parameter in a tool validation in ArcGIS Desktop 10.7 toolbox Python script</title>
      <link>https://community.esri.com/t5/python-questions/getting-zmin-zmax-of-a-raster-parameter-in-a-tool/m-p/1016822#M59513</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - GeoNet, The Esri Community&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;def updateParameters(self):&lt;/LI-CODE&gt;&lt;P&gt;Use python for the language... It will make your def happy again&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def updateParameters(self):&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The parameter type would be "any" and you have to deal with either a raster or a number being added&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 13:06:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-zmin-zmax-of-a-raster-parameter-in-a-tool/m-p/1016822#M59513</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-01-14T13:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Getting zmin zmax of a raster parameter in a tool validation in ArcGIS Desktop 10.7 toolbox Python script</title>
      <link>https://community.esri.com/t5/python-questions/getting-zmin-zmax-of-a-raster-parameter-in-a-tool/m-p/1017438#M59550</link>
      <description>&lt;P&gt;This question is a cross forum post and has been answered here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://gis.stackexchange.com/questions/384285/getting-zmin-zmax-of-a-raster-parameter-in-a-tool-validation-in-arcgis-desktop-1/384310#384310" target="_blank"&gt;https://gis.stackexchange.com/questions/384285/getting-zmin-zmax-of-a-raster-parameter-in-a-tool-validation-in-arcgis-desktop-1/384310#384310&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2021 00:52:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-zmin-zmax-of-a-raster-parameter-in-a-tool/m-p/1017438#M59550</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2021-01-16T00:52:56Z</dc:date>
    </item>
  </channel>
</rss>

