<?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: Geoprocessing Python Scripts: How to work with directories and scratch? in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-python-scripts-how-to-work-with/m-p/241935#M9338</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is the topic you'll want to read regarding scripts you write for use in a GP Service:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.2/#/Authoring_geoprocessing_tasks_with_Python_scripts/00570000007r000000/" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.2/#/Authoring_geoprocessing_tasks_with_Python_scripts/00570000007r000000/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;In regards to scratchFolder, scratchGDB, I'd start with this blog: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://blogs.esri.com/esri/arcgis/2012/10/19/the-new-scratchgdb-and-scratchfolder-environments/" rel="nofollow" target="_blank"&gt;http://blogs.esri.com/esri/arcgis/2012/10/19/the-new-scratchgdb-and-scratchfolder-environments/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;(It has links to specific topics in the help as well)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you say it works locally and publishes fine but throws an error in Desktop, do you mean when you run the published service, that is throwing the error?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I see what's happened. This is the line which has confused the publishing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.Buffer_analysis(waterbodyPoly,"waterbodyBuffer",0.0 - shorelineBuffer)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your script you've told Buffer, the output will be called "waterbodyBuffer". I'm not entirely certain what happened when you ran this on Desktop, but it must have made output of some sort. Perhaps a shapefile?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, when the script gets published, decisions are made based on your script and your environment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;From the error it states: &lt;/SPAN&gt;&lt;STRONG&gt;IOError: "%scratchFolder%\waterbodyBuffer" does not exist&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I can tell that the publishing &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;thought&lt;/SPAN&gt;&lt;SPAN&gt; you wanted a shapefile, because it tried to place that output into a folder. However, you don't have .shp. So the output wont be valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The fix is easy enough. In your original script, I'd do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Buffer Waterbody inwards by shorelineBuffer waterbodyBuffer = "in_memory\\waterbody" arcpy.Buffer_analysis(waterbodyPoly,waterbodyBuffer,0.0 - shorelineBuffer) arcpy.AddMessage(str(arcpy.Describe(waterbodyBuffer).extent) + " of the waterbodyBuffer") #&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Noting that I turned your string "waterbodyBuffer" into a variable which points to in_memory\\waterbody and where it was used in Buffer and described, made that point to the variable.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Dec 2013 12:42:06 GMT</pubDate>
    <dc:creator>KevinHibma</dc:creator>
    <dc:date>2013-12-02T12:42:06Z</dc:date>
    <item>
      <title>Geoprocessing Python Scripts: How to work with directories and scratch?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-python-scripts-how-to-work-with/m-p/241934#M9337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having some frustrating times with a GP script I'm trying to publish to my Ubuntu ArcGIS Server 10.2 machine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script works perfectly locally and publishes just fine, but when trying to use it in ArcGIS Desktop, it throws an immediate error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Error executing tool.:&amp;nbsp; Traceback (most recent call last): &amp;nbsp; File "Z:\net\SITEHOST\gisdata\arcgisserver\directories\arcgissystem\arcgisinput\autoTransectFour.GPServer\extracted\v101\rq\atw.py", line 69, in &amp;lt;module&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(arcpy.Describe(g_ESRI_variable_2).extent) + " of the waterbodyBuffer") &amp;nbsp; File "Z:\arcgis\server\arcpy\arcpy\__init__.py", line 1234, in Describe &amp;nbsp;&amp;nbsp;&amp;nbsp; return gp.describe(value) &amp;nbsp; File "Z:\arcgis\server\arcpy\arcpy\geoprocessing\_base.py", line 374, in describe &amp;nbsp;&amp;nbsp;&amp;nbsp; self._gp.Describe(*gp_fixargs(args, True))) IOError: "%scratchFolder%\waterbodyBuffer" does not exist&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not including the whole script as it doesn't get far and the error seems to do with how I manage workspaces.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Imports import arcpy import gc import csv from arcpy import env from math import radians, tan, cos, fabs&amp;nbsp; ### INPUTS / OUTPUTS ### waterbodyPoly = arcpy.GetParameterAsText(0) transSpacing = float(arcpy.GetParameterAsText(1)) shorelineBuffer = float(arcpy.GetParameterAsText(2))&amp;nbsp;&amp;nbsp; outTransect = arcpy.GetParameterAsText(3) outPoints = arcpy.GetParameterAsText(4) angleType = arcpy.GetParameterAsText(5) pathLines = arcpy.GetParameterAsText(6)&amp;nbsp; #arcpy.env.workspace = ws&amp;nbsp;&amp;nbsp; ### VARIABLES ### kfPerimeter = shorelineBuffer - (transSpacing / 2) sRef = arcpy.Describe(waterbodyPoly).spatialReference&amp;nbsp; # Get start point from geometry boatStartPoint = arcpy.Point()&amp;nbsp; # Create Empty FCs arcpy.CreateFeatureclass_management(arcpy.env.scratchWorkspace, pathLines, "POLYLINE", spatial_reference = sRef) arcpy.AddMessage(str(arcpy.Describe(waterbodyPoly).extent) + " of the waterbodyPoly")&amp;nbsp; # Buffer Waterbody inwards by shorelineBuffer arcpy.Buffer_analysis(waterbodyPoly,"waterbodyBuffer",0.0 - shorelineBuffer) arcpy.AddMessage(str(arcpy.Describe("waterbodyBuffer").extent) + " of the waterbodyBuffer")&amp;nbsp; # &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There's a lot of bits and pieces in the ArcGIS help pages online for these things, but there's nothing I've found that very explicitly discusses how to structure and publish PYTHON scripts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Links to better documentation or some pointers/tips/suggestions would be greatly appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Dec 2013 16:36:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-python-scripts-how-to-work-with/m-p/241934#M9337</guid>
      <dc:creator>AndrewBlakey</dc:creator>
      <dc:date>2013-12-01T16:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Python Scripts: How to work with directories and scratch?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-python-scripts-how-to-work-with/m-p/241935#M9338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is the topic you'll want to read regarding scripts you write for use in a GP Service:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.2/#/Authoring_geoprocessing_tasks_with_Python_scripts/00570000007r000000/" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.2/#/Authoring_geoprocessing_tasks_with_Python_scripts/00570000007r000000/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;In regards to scratchFolder, scratchGDB, I'd start with this blog: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://blogs.esri.com/esri/arcgis/2012/10/19/the-new-scratchgdb-and-scratchfolder-environments/" rel="nofollow" target="_blank"&gt;http://blogs.esri.com/esri/arcgis/2012/10/19/the-new-scratchgdb-and-scratchfolder-environments/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;(It has links to specific topics in the help as well)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you say it works locally and publishes fine but throws an error in Desktop, do you mean when you run the published service, that is throwing the error?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I see what's happened. This is the line which has confused the publishing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.Buffer_analysis(waterbodyPoly,"waterbodyBuffer",0.0 - shorelineBuffer)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your script you've told Buffer, the output will be called "waterbodyBuffer". I'm not entirely certain what happened when you ran this on Desktop, but it must have made output of some sort. Perhaps a shapefile?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, when the script gets published, decisions are made based on your script and your environment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;From the error it states: &lt;/SPAN&gt;&lt;STRONG&gt;IOError: "%scratchFolder%\waterbodyBuffer" does not exist&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I can tell that the publishing &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;thought&lt;/SPAN&gt;&lt;SPAN&gt; you wanted a shapefile, because it tried to place that output into a folder. However, you don't have .shp. So the output wont be valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The fix is easy enough. In your original script, I'd do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Buffer Waterbody inwards by shorelineBuffer waterbodyBuffer = "in_memory\\waterbody" arcpy.Buffer_analysis(waterbodyPoly,waterbodyBuffer,0.0 - shorelineBuffer) arcpy.AddMessage(str(arcpy.Describe(waterbodyBuffer).extent) + " of the waterbodyBuffer") #&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Noting that I turned your string "waterbodyBuffer" into a variable which points to in_memory\\waterbody and where it was used in Buffer and described, made that point to the variable.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Dec 2013 12:42:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-python-scripts-how-to-work-with/m-p/241935#M9338</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2013-12-02T12:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Python Scripts: How to work with directories and scratch?</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-python-scripts-how-to-work-with/m-p/241936#M9339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Kevin:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is all incredibly helpful. Thank you very much.&amp;nbsp; While my script does contain errors, your changes have pushed the bar down another 10 or so lines.&amp;nbsp; This is also another consideration when writing/changing my code to work properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the blog post as well. I didn't see that one before.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's great to begin a Monday morning with a plethora of possibility for fixing a very frustrating weekend error. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Dec 2013 12:47:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/geoprocessing-python-scripts-how-to-work-with/m-p/241936#M9339</guid>
      <dc:creator>AndrewBlakey</dc:creator>
      <dc:date>2013-12-02T12:47:15Z</dc:date>
    </item>
  </channel>
</rss>

