<?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 Why is exe path added to workspace path when saving raster? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-is-exe-path-added-to-workspace-path-when/m-p/589011#M46150</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to save a raster to an sde workspace, but get the following error:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ERROR 000875: Output raster: c:\program files (x86)\arcgis\desktop10.2\bin\Database Connections\test.sde\LatNorth's workspace is an invalid output workspace.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Sample code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;INWorkspace = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;)
&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;InputLatitude = arcpy.Raster(INWorkspace + &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;" &lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;+ StageAge + &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"_Latitude"&lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;)&lt;/SPAN&gt;
LatNorth = Con((InputLatitude &amp;gt; &lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;InputLatitude)
LatNorth.save(&lt;SPAN style="color: #a5c261;"&gt;"LatNorth"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;(StageAge is just a string)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also tried:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;OUTWorkspace = arcpy.env.workspace
LatNorth.save(os.path.join(OUTWorkspace&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"LatNorth"&lt;/SPAN&gt;))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the correct syntax for saving a raster to sde? This isn't documented, or if it is, it's well hidden.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:17:56 GMT</pubDate>
    <dc:creator>JonMorris2</dc:creator>
    <dc:date>2021-12-12T01:17:56Z</dc:date>
    <item>
      <title>Why is exe path added to workspace path when saving raster?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-exe-path-added-to-workspace-path-when/m-p/589011#M46150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to save a raster to an sde workspace, but get the following error:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;ERROR 000875: Output raster: c:\program files (x86)\arcgis\desktop10.2\bin\Database Connections\test.sde\LatNorth's workspace is an invalid output workspace.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Sample code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;INWorkspace = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;)
&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;InputLatitude = arcpy.Raster(INWorkspace + &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\\&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;" &lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;+ StageAge + &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"_Latitude"&lt;/SPAN&gt;&lt;SPAN style="font-size: 9pt; line-height: 12pt;"&gt;)&lt;/SPAN&gt;
LatNorth = Con((InputLatitude &amp;gt; &lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;)&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;InputLatitude)
LatNorth.save(&lt;SPAN style="color: #a5c261;"&gt;"LatNorth"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;(StageAge is just a string)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also tried:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;OUTWorkspace = arcpy.env.workspace
LatNorth.save(os.path.join(OUTWorkspace&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"LatNorth"&lt;/SPAN&gt;))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the correct syntax for saving a raster to sde? This isn't documented, or if it is, it's well hidden.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:17:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-exe-path-added-to-workspace-path-when/m-p/589011#M46150</guid>
      <dc:creator>JonMorris2</dc:creator>
      <dc:date>2021-12-12T01:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why is exe path added to workspace path when saving raster?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-exe-path-added-to-workspace-path-when/m-p/589012#M46151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Update: I tried a few things out in the python window and it looks like this is possible for sde if you ignore the usual 'Database Connections' syntax and give the full path of the sde connection file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy
&amp;gt;&amp;gt;&amp;gt; import os
&amp;gt;&amp;gt;&amp;gt; out_gdb = r"Database Connections\test.sde"
&amp;gt;&amp;gt;&amp;gt; from arcpy.sa import Con
&amp;gt;&amp;gt;&amp;gt; from arcpy.sa import Raster
&amp;gt;&amp;gt;&amp;gt; InputLatitude = Raster("GEOLOGY.Maas_Latitude")
&amp;gt;&amp;gt;&amp;gt; LatNorth = Con((InputLatitude &amp;gt; 0), InputLatitude)
&amp;gt;&amp;gt;&amp;gt; arcpy.env.workspace
u'C:\\Users\\jpm\\Documents\\ArcGIS\\Default.gdb'
&amp;gt;&amp;gt;&amp;gt; LatNorth.save("LatNorth")
Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
RuntimeError: ERROR 010240: Could not save raster dataset to C:\Users\jpm\Documents\ArcGIS\Default.gdb\ifthe_ras4 with output format FGDBR.
&amp;gt;&amp;gt;&amp;gt; LatNorth.save()
&amp;gt;&amp;gt;&amp;gt; LatNorth.save(arcpy.env.workspace + "\\LatNorth")
&amp;gt;&amp;gt;&amp;gt; LatNorth.save(os.path.join(arcpy.env.workspace, "LatNorth"))
&amp;gt;&amp;gt;&amp;gt; LatNorth.save(os.path.join(out_gdb, "LatNorth"))
Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
RuntimeError: ERROR 000875: Output raster: C:\Windows\system32\Database Connections\test.sde\LatNorth's workspace is an invalid output workspace.
&amp;gt;&amp;gt;&amp;gt; arcpy.env.workspace = out_gdb
&amp;gt;&amp;gt;&amp;gt; arcpy.env.workspace
u'Database Connections\\test.sde'
&amp;gt;&amp;gt;&amp;gt; LatNorth.save(os.path.join(arcpy.env.workspace, "LatNorth"))
Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
RuntimeError: ERROR 000875: Output raster: C:\Windows\system32\Database Connections\test.sde\LatNorth's workspace is an invalid output workspace.
&amp;gt;&amp;gt;&amp;gt; LatNorth.save("LatNorth")
Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
RuntimeError: ERROR 000875: Output raster: C:\Windows\system32\Database Connections\test.sde\LatNorth's workspace is an invalid output workspace.
&amp;gt;&amp;gt;&amp;gt; LatNorth.save()
&amp;gt;&amp;gt;&amp;gt; LatNorth.save(r"C:\Users\jpm\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\test.sde\LatNorth")
&amp;gt;&amp;gt;&amp;gt; &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The penultimate line appears to show that it worked, but nothing new appeared in the sde database. Not sure where ArcMap saved it - I suspect it was just overwriting the raster in Default.gdb.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The last line, however, did work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:17:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-exe-path-added-to-workspace-path-when/m-p/589012#M46151</guid>
      <dc:creator>JonMorris2</dc:creator>
      <dc:date>2021-12-12T01:17:59Z</dc:date>
    </item>
  </channel>
</rss>

