<?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: automate raster extraction and saving data based on input raster in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/automate-raster-extraction-and-saving-data-based/m-p/326672#M4574</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this question is related to the rasters created in your thread &lt;A href="https://community.esri.com/message/390793"&gt;Re: loop for value and counts in raster attribute&lt;/A&gt;‌, then &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;‌ is absolutely right. The problem occurs in the line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14065139873797399" jivemacro_uid="_14065139873797399" modifiedtitle="true"&gt;
&lt;P&gt;outname=os.path.join(outws,str(i), str(j))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14065140777747668" jivemacro_uid="_14065140777747668"&gt;
&lt;P&gt;outname=os.path.join(outws,"{0}{1}".format(i,j))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first creates an outname of: &lt;SPAN style="font-family: courier new,courier;"&gt;C:/Subhasis/Test/Neshanic_Python/extract\&lt;STRONG style="color: #e23d39;"&gt;01367620-r-r\9&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The second creates an outname of: &lt;SPAN style="font-family: courier new,courier;"&gt;C:/Subhasis/Test/Neshanic_Python/extract\&lt;STRONG style="color: #7ed529;"&gt;01367620-r-r9&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;EM&gt;os,path.join&lt;/EM&gt; will place a slash between each parameter. This causes the value "j" to be the raster name and the value "i" is interpreted as folder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;BTW&lt;/STRONG&gt;: if the thread &lt;A href="https://community.esri.com/message/390793"&gt;Re: loop for value and counts in raster attribute&lt;/A&gt; is solved, you should mark it as answered!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Jul 2014 02:28:43 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2014-07-28T02:28:43Z</dc:date>
    <item>
      <title>automate raster extraction and saving data based on input raster</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/automate-raster-extraction-and-saving-data-based/m-p/326670#M4572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I have 70 raster files and I want to make 3 new raster from each of the 70 raster. For that, I want to automate the process using python script and store the output new raster based on the raster file name plus value field. For example, My input raster is&amp;nbsp; 01367620-r-r and 3 value fields are 9,11, and 13. So the output folder should be 01367620-r-r-9. 01367620-r-r-11, and 01367620-r-r-13. When I ran my code, I got the below error message. I think, I am doing mistake at "outname=os.path.join(outws,str(i), str(j))" in my code. I would appreciate your suggestion/input.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error Message:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:/Subhasis/Test/Neshanic_Python/Neshanic-test.py", line 23, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; attExtract.save(outname)&lt;/P&gt;&lt;P&gt;RuntimeError: ERROR 000875: Output raster: C:\Subhasis\Test\Neshanic_Python\extract\01367620-r-r\9's workspace is an invalid output workspace.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am providing my code below.&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;from arcpy.sa import *&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#To overwrite output&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#Set environment settings&lt;/P&gt;&lt;P&gt;env.workspace = "C:/Subhasis/Test/Neshanic_Python"&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;outws="C:/Subhasis/Test/Neshanic_Python/extract"&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#checkout ArcGIS spatial analyst extension license&lt;/P&gt;&lt;P&gt;arcpy.CheckOutExtension("Spatial")&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# set local variable&lt;/P&gt;&lt;P&gt;inraster = ["01367620-r-r"] &lt;/P&gt;&lt;P&gt;for i in inraster:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; STI_list=[9,11,13]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for j in STI_list:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attExtract = ExtractByAttributes(str(i), "VALUE&amp;gt;=" + str(j))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outname=os.path.join(outws,str(i), str(j))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attExtract.save(outname)&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 18:44:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/automate-raster-extraction-and-saving-data-based/m-p/326670#M4572</guid>
      <dc:creator>InceptionWoznicki</dc:creator>
      <dc:date>2014-07-21T18:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: automate raster extraction and saving data based on input raster</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/automate-raster-extraction-and-saving-data-based/m-p/326671#M4573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The gist I get from that error message is that this folder ... C:\Subhasis\Test\Neshanic_Python\extract\01367620-r-r\9 ... doesn't exist and I think you need to create a raster object before using save&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;outname = Raster(os.path.join(outws,str(i), str(j)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but I can't check... see &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00p60000000r000000" title="http://resources.arcgis.com/en/help/main/10.2/index.html#//00p60000000r000000"&gt;ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2014 18:53:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/automate-raster-extraction-and-saving-data-based/m-p/326671#M4573</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-07-21T18:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: automate raster extraction and saving data based on input raster</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/automate-raster-extraction-and-saving-data-based/m-p/326672#M4574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this question is related to the rasters created in your thread &lt;A href="https://community.esri.com/message/390793"&gt;Re: loop for value and counts in raster attribute&lt;/A&gt;‌, then &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;‌ is absolutely right. The problem occurs in the line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14065139873797399" jivemacro_uid="_14065139873797399" modifiedtitle="true"&gt;
&lt;P&gt;outname=os.path.join(outws,str(i), str(j))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14065140777747668" jivemacro_uid="_14065140777747668"&gt;
&lt;P&gt;outname=os.path.join(outws,"{0}{1}".format(i,j))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first creates an outname of: &lt;SPAN style="font-family: courier new,courier;"&gt;C:/Subhasis/Test/Neshanic_Python/extract\&lt;STRONG style="color: #e23d39;"&gt;01367620-r-r\9&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The second creates an outname of: &lt;SPAN style="font-family: courier new,courier;"&gt;C:/Subhasis/Test/Neshanic_Python/extract\&lt;STRONG style="color: #7ed529;"&gt;01367620-r-r9&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;EM&gt;os,path.join&lt;/EM&gt; will place a slash between each parameter. This causes the value "j" to be the raster name and the value "i" is interpreted as folder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;BTW&lt;/STRONG&gt;: if the thread &lt;A href="https://community.esri.com/message/390793"&gt;Re: loop for value and counts in raster attribute&lt;/A&gt; is solved, you should mark it as answered!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jul 2014 02:28:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/automate-raster-extraction-and-saving-data-based/m-p/326672#M4574</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-07-28T02:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: automate raster extraction and saving data based on input raster</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/automate-raster-extraction-and-saving-data-based/m-p/326673#M4575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Xander,&lt;/P&gt;&lt;P&gt;Thank you very much for your reply. I marked it as answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Subhais&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jul 2014 12:57:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/automate-raster-extraction-and-saving-data-based/m-p/326673#M4575</guid>
      <dc:creator>InceptionWoznicki</dc:creator>
      <dc:date>2014-07-28T12:57:54Z</dc:date>
    </item>
  </channel>
</rss>

