<?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: How to save a raster with a script tool input? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484340#M37813</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both for your reply. After another 45 min- 1 hour of banging my head this is where I'm at:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan:&lt;/P&gt;&lt;P&gt;I've changed my workspace (from the user input end of the script tool) to a folder rather than a gdb. I changed the outRaster to outRaster.tif (again in the user end).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess I'm unsure how to call my FinalResult and save it in the concatentated file path.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FinalResult.save(concatenatedVariable) ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I try this, I get a 000875 error saying the workspace is an invalid output workspace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Curtis:&lt;/P&gt;&lt;P&gt;I've tried the line you added, but I get a 010240 error that it could not save the raster dataset with output format FGDBR.&lt;/P&gt;&lt;P&gt;When I run the script in the python window it adds my final raster to my map and it has a temporary location. If I just do&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FinalRaster.save()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the python window it saves in my workspace without any issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again to both of you for your input and patience with my very basic knowledge &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Feb 2019 16:45:07 GMT</pubDate>
    <dc:creator>RyanHowell1</dc:creator>
    <dc:date>2019-02-22T16:45:07Z</dc:date>
    <item>
      <title>How to save a raster with a script tool input?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484337#M37810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm learning python and have been banging my head on this for hours now and can't figure it out. It's probably something really basic but here it goes...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a base elevation raster that I'm running some math on to get a basic ruggedness layer. The script works when I run it in the python window, but I'm trying to use it to create a script tool. Here is what I have simplified:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;outWorkspace = arcpy.GetParameterAsText(0)&lt;BR /&gt;baseRaster = arcpy.GetParameterAsText(1)&lt;BR /&gt;scale = arcpy.GetParameterAsText(2)&lt;BR /&gt;outRaster = arcpy.GetParameterAsText(3)&lt;/P&gt;&lt;P&gt;env.workspace = outWorkspace&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;###lots of math on the baseRaster&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FinalResult = #more math&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;finalResult.save()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I run it like this, the tool runs but it doesn't appear to save my file in the workspace specified (or anywhere for that matter, I can't find the results of the tool). So I guess that's issue #1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second question is how do I script this so that the name of FinalResult is whatever the user puts in for outRaster, instead of FinalResult?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case it is needed, my parameters that I have set up in my script tool are as follows:&lt;/P&gt;&lt;P&gt;0 = Workspace (data type), input&lt;/P&gt;&lt;P&gt;1 = Raster Dataset, Input&lt;/P&gt;&lt;P&gt;2 = Long, Input&lt;/P&gt;&lt;P&gt;3 = Raster Dataset, Output&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2019 21:52:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484337#M37810</guid>
      <dc:creator>RyanHowell1</dc:creator>
      <dc:date>2019-02-21T21:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a raster with a script tool input?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484338#M37811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you need an output workspace (make it a folder not a gdb)&lt;/P&gt;&lt;P&gt;and an output filename (raster.tif&amp;nbsp; for example)&lt;/P&gt;&lt;P&gt;Concatenate the workspace and the output filename prior to saving&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2019 22:37:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484338#M37811</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-02-21T22:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a raster with a script tool input?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484339#M37812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ryan:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think your raster is saving but&amp;nbsp;not at the location specified as outRaster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is set up as a script tool, outRaster will be full path.&amp;nbsp;So, this statement:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;finalResult&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;outRaster&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;/CODE&gt;&lt;/PRE&gt;&lt;P style="background-color: #ffffff; border: 0px;"&gt;should save the output in the location (and format) specified in the script tool dialog box.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2019 02:08:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484339#M37812</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2019-02-22T02:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a raster with a script tool input?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484340#M37813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both for your reply. After another 45 min- 1 hour of banging my head this is where I'm at:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan:&lt;/P&gt;&lt;P&gt;I've changed my workspace (from the user input end of the script tool) to a folder rather than a gdb. I changed the outRaster to outRaster.tif (again in the user end).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess I'm unsure how to call my FinalResult and save it in the concatentated file path.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FinalResult.save(concatenatedVariable) ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I try this, I get a 000875 error saying the workspace is an invalid output workspace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Curtis:&lt;/P&gt;&lt;P&gt;I've tried the line you added, but I get a 010240 error that it could not save the raster dataset with output format FGDBR.&lt;/P&gt;&lt;P&gt;When I run the script in the python window it adds my final raster to my map and it has a temporary location. If I just do&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FinalRaster.save()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the python window it saves in my workspace without any issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again to both of you for your input and patience with my very basic knowledge &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2019 16:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484340#M37813</guid>
      <dc:creator>RyanHowell1</dc:creator>
      <dc:date>2019-02-22T16:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a raster with a script tool input?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484341#M37814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would suggest the same thing&amp;nbsp;as Curtis...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get your&amp;nbsp;output&amp;nbsp;location as a parameter. Don't count on the arcpy.env.workspace setting and pass your&amp;nbsp;full path...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;final_raster.save(output_path)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/classes/raster-object.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/classes/raster-object.htm"&gt;Raster—ArcPy classes | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;One thing that I find helps a lot is to get everything working in a python IED with hardcoded parameters before turning it into a "script tool". That way you can take advantage of debuggers, etc. (helps cut down on the black box effect).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.jetbrains.com/pycharm/download/#section=windows" title="https://www.jetbrains.com/pycharm/download/#section=windows"&gt;https://www.jetbrains.com/pycharm/download/#section=windows&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://github.com/pyscripter/pyscripter" title="https://github.com/pyscripter/pyscripter"&gt;GitHub - pyscripter/pyscripter: Pyscripter is a feature-rich but lightweight Python IDE&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:59:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484341#M37814</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2019-02-22T17:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a raster with a script tool input?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484342#M37815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Getting rid of&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;env.workspace = outWorkspace&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;and then doing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;FinalRaster.save(outRaster)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;ended up fixing all of my problems. I guess it was setting the workspace that was causing me issues.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2019 18:55:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484342#M37815</guid>
      <dc:creator>RyanHowell1</dc:creator>
      <dc:date>2019-02-22T18:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to save a raster with a script tool input?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484343#M37816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice! Don't forget to mark a correct&amp;nbsp;answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2019 19:26:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-save-a-raster-with-a-script-tool-input/m-p/484343#M37816</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2019-02-22T19:26:05Z</dc:date>
    </item>
  </channel>
</rss>

