<?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: Using Multivalue to add multiple raster layers in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452708#M35475</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added the split method and the raster calculations run as expected!&amp;nbsp; Thank You!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Jan 2016 14:27:51 GMT</pubDate>
    <dc:creator>ShawnKasprick</dc:creator>
    <dc:date>2016-01-26T14:27:51Z</dc:date>
    <item>
      <title>Using Multivalue to add multiple raster layers</title>
      <link>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452704#M35471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to bring in multiple raster layers by using the multivalue parameter properties, however the script fails and states the dataset does not exist or is not supported.&amp;nbsp; I have attached the error message as well as the script I am using.&amp;nbsp; The raster layers are normally brought in directly from the TOC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Error&lt;/P&gt;&lt;P&gt;Messages&lt;/P&gt;&lt;P&gt;Executing: CalcCompRasters Image1;Image2;Image3;Image4 S:\AVWorks\Scratch.gdb\avgtest&lt;/P&gt;&lt;P&gt;Start Time: Mon Jan 25 11:13:38 2016&lt;/P&gt;&lt;P&gt;Running script CalcCompRasters...&lt;/P&gt;&lt;P&gt;Failed script CalcCompRasters...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "S:\Data\My Toolboxes\MyScripts\Calculate Composite Rasters.py", line 24, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OutAvgTemp = CellStatistics(InRasters, "MEAN", "DATA")&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\sa\Functions.py", line 2967, in CellStatistics&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ignore_nodata)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\sa\Utils.py", line 53, in swapper&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = wrapper(*args, **kwargs)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\sa\Functions.py", line 2963, in Wrapper&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [function] + Utils.flattenLists(in_rasters_or_constants))&lt;/P&gt;&lt;P&gt;RuntimeError: ERROR 000732: Input Raster: Dataset Image1;Image2;Image3;Image4 does not exist or is not supported&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Failed to execute (CalcCompRasters).&lt;/P&gt;&lt;P&gt;Failed at Mon Jan 25 11:13:40 2016 (Elapsed Time: 1.97 seconds)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the Script I am using.&amp;nbsp; This will be the start of a larger script, but until I get past this I won't add more to it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Import arcpy module&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;from arcpy.sa import *&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Script arguments&lt;/P&gt;&lt;P&gt;InRasters = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;OutAvg = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Process: Cell Statistics - Avg&lt;/P&gt;&lt;P&gt;OutAvgTemp = CellStatistics(InRasters, "MEAN", "DATA")&lt;/P&gt;&lt;P&gt;OutAvgTemp.save(OutAvg)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jan 2016 17:31:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452704#M35471</guid>
      <dc:creator>ShawnKasprick</dc:creator>
      <dc:date>2016-01-25T17:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multivalue to add multiple raster layers</title>
      <link>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452705#M35472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="pln"&gt;First, I don't see where your workspace is getting set.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14537436095803278 jive_macro_code jive_text_macro" data-renderedposition="50_8_912_16" jivemacro_uid="_14537436095803278" modifiedtitle="true"&gt;&lt;CODE&gt;&lt;SPAN class="pln"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;env&lt;/SPAN&gt;&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln"&gt;workspace &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln"&gt; &lt;/SPAN&gt;&lt;SPAN class="pun"&gt;&amp;lt;workspace&amp;gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Next would be to make sure the input rasters are actually being treated as a list of rasters.&amp;nbsp; Which this doesn't look correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14537434746308609 jive_text_macro" data-renderedposition="150_8_912_16" jivemacro_uid="_14537434746308609"&gt;&lt;P&gt;InRasters = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe should be more like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14537434832194780 jive_macro_code jive_text_macro" data-renderedposition="229_8_912_16" jivemacro_uid="_14537434832194780"&gt;&lt;P&gt;InRasters = arcpy&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;ListRasters&lt;/SPAN&gt;(arcpy.GetParameterAsText(0))&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although I don't know if that input will be treated as a list of values.&amp;nbsp; You may have to be more verbose in setting this up and iterate through to populate an actual list of rasters:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14537439455412869 jive_macro_code jive_text_macro" data-renderedposition="329_8_912_16" jivemacro_uid="_14537439455412869"&gt;&lt;P&gt;InRasters = arcpy&lt;SPAN class="pun"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ"&gt;ListRasters&lt;/SPAN&gt;(["raster1","raster2"])&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jan 2016 17:45:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452705#M35472</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-01-25T17:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multivalue to add multiple raster layers</title>
      <link>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452706#M35473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The error... although is hidden... can be found here &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/python/setting-paths-to-data.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/python/setting-paths-to-data.htm"&gt;Setting paths to data in Python—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp; and the most common problem is how people pass on file paths and filenames in scripts... for example&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;"c:\somepath\that is\here"&amp;nbsp;&amp;nbsp; is wrong on so many levels...&lt;UL&gt;&lt;LI&gt;there is no r in front of the path name to utilize python's "raw" syntax&lt;/LI&gt;&lt;LI&gt;it contains a \t which is treated as a python tab&lt;/LI&gt;&lt;LI&gt;it contains a space... not a specific problem in this situation, but it will come back to bite you at some time.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;r"c:\somepath\that_is\here"&amp;nbsp; is acceptable, "r" in front "_" for spaces&lt;/LI&gt;&lt;LI&gt;"c:\\somepath\\that_is\\here""&amp;nbsp; use python double slashes to override the escape useage in python&lt;/LI&gt;&lt;LI&gt;"c:/somepath/that_is/here"&amp;nbsp;&amp;nbsp;&amp;nbsp; use foreward slashes&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;and if you file path doesn't exist or it is wrong, you will get that error message... if the file isn't supported you will get that error message... and any combination of the above.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 00:31:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452706#M35473</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-26T00:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multivalue to add multiple raster layers</title>
      <link>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452707#M35474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Your multivalue gets read in as a semicolon-delineated string (e.g. 'ras1;ras2;ras3;ras4'). You need to split that into a regular list, which the split() method will do for you (e.g. 'ras1;ras2;ras3;ras4'.split(';') would return ['ras1','ras2','ras3','ras4']).&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import arcpy module
import arcpy
from arcpy.sa import *

# Script arguments
InRasters = arcpy.GetParameterAsText(0).split(';') # use split method here
OutAvg = arcpy.GetParameterAsText(1)

# Process: Cell Statistics - Avg
OutAvgTemp = CellStatistics(InRasters, "MEAN", "DATA")
OutAvgTemp.save(OutAvg)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:11:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452707#M35474</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T20:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using Multivalue to add multiple raster layers</title>
      <link>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452708#M35475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added the split method and the raster calculations run as expected!&amp;nbsp; Thank You!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 14:27:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-multivalue-to-add-multiple-raster-layers/m-p/452708#M35475</guid>
      <dc:creator>ShawnKasprick</dc:creator>
      <dc:date>2016-01-26T14:27:51Z</dc:date>
    </item>
  </channel>
</rss>

