<?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: Saving output with predefined name in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/saving-output-with-predefined-name/m-p/469612#M36652</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not really sure but have you verified that the user enter variables are coming out the way they should be? What I do while testing is to do a few prints just to make sure that the output locations and things like that are looking how they are supposed to look.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you see if the geodatabase is locked (like, can you perform this clipping without Python to make sure it works)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, for saving, doesn't the Clip_management command save to a variable in its options (as opposed to having to save the raster later on)?&lt;/P&gt;&lt;P&gt;This article shows that the third parameter in Clip_management is the output raster:&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/clip.htm" title="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/clip.htm"&gt;Clip—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Jan 2016 20:07:23 GMT</pubDate>
    <dc:creator>AdrianWelsh</dc:creator>
    <dc:date>2016-01-28T20:07:23Z</dc:date>
    <item>
      <title>Saving output with predefined name</title>
      <link>https://community.esri.com/t5/python-questions/saving-output-with-predefined-name/m-p/469610#M36650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to clip a raster and save the output with a predefined name to a file geodatabase which will be defined by the user as a parameter.&amp;nbsp; I have tried two different angles, and both give me errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;Trial 1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;# Import modules&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;from arcpy import env&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;from arcpy.sa import *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;# Input Parameters&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Boundary = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;InRaster = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;GDBLoc = arcpy.GetParameterAsText(2) # data type set as workspace&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;# Clip Raster&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Raster = arcpy.Clip_management(InRaster, "", "in_memory", Boundary, "0", "ClippingGeometry", "NO_MAINTAIN_EXTENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;RasName = ("GDBLoc" + "\\PredefinedName")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Raster.save(RasName)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Results in&lt;/STRONG&gt;&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;AttributeError: 'Result' object has no attribute 'save'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt; Trial 2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;# Import modules&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;from arcpy import env&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;from arcpy.sa import *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;# Input Parameters&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Boundary = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;InRaster = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;GDBLoc = arcpy.GetParameterAsText(2) &lt;SPAN style="font-size: 13.3333px;"&gt;# data type set as workspace&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;# Clip Raster&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Raster = arcpy.Clip_management(InRaster, "", "GDBLoc + \\PredefinedName", Boundary, "0", "ClippingGeometry", "NO_MAINTAIN_EXTENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Results in:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 999999: Error executing function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 19:50:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/saving-output-with-predefined-name/m-p/469610#M36650</guid>
      <dc:creator>ShawnKasprick</dc:creator>
      <dc:date>2016-01-28T19:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Saving output with predefined name</title>
      <link>https://community.esri.com/t5/python-questions/saving-output-with-predefined-name/m-p/469611#M36651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shawn,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the second example, the issue is that you are placing quotes around the GDBLoc variable.&amp;nbsp; This will cause the variable to be read as a string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-size: 10pt;"&gt;# Import modules&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;import arcpy&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;from arcpy import env&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;from arcpy.sa import *&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;# Input Parameters&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;Boundary = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;InRaster = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10pt;"&gt;GDBLoc = arcpy.GetParameterAsText(2) &lt;SPAN style="font-size: 13.3333px;"&gt;# data type set as workspace&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN style="font-size: 10pt;"&gt;arcpy.Clip_management(InRaster, "", GDBLoc + "\\PredefinedName", Boundary, "0", "ClippingGeometry", "NO_MAINTAIN_EXTENT")&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:48:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/saving-output-with-predefined-name/m-p/469611#M36651</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T20:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Saving output with predefined name</title>
      <link>https://community.esri.com/t5/python-questions/saving-output-with-predefined-name/m-p/469612#M36652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not really sure but have you verified that the user enter variables are coming out the way they should be? What I do while testing is to do a few prints just to make sure that the output locations and things like that are looking how they are supposed to look.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you see if the geodatabase is locked (like, can you perform this clipping without Python to make sure it works)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, for saving, doesn't the Clip_management command save to a variable in its options (as opposed to having to save the raster later on)?&lt;/P&gt;&lt;P&gt;This article shows that the third parameter in Clip_management is the output raster:&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/clip.htm" title="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/clip.htm"&gt;Clip—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 20:07:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/saving-output-with-predefined-name/m-p/469612#M36652</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-01-28T20:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Saving output with predefined name</title>
      <link>https://community.esri.com/t5/python-questions/saving-output-with-predefined-name/m-p/469613#M36653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked exactly as I was hoping!!&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 20:11:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/saving-output-with-predefined-name/m-p/469613#M36653</guid>
      <dc:creator>ShawnKasprick</dc:creator>
      <dc:date>2016-01-28T20:11:54Z</dc:date>
    </item>
  </channel>
</rss>

