<?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: Having issues with arcpy.env.workspace. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255504#M19622</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Glad it worked.&amp;nbsp; As a matter of scripting style, I avoid using a + (plus) sign to concatenate variables.&amp;nbsp; For me the + sign is what you use when you are adding two or more numeric values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Since you are using 2.x Python, I'd recommend the format() function.&amp;nbsp; Once you start using 3.x you get the f string method which is even cooler.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;clipOutput = tempdata +'\Ogma_Clip'

#becomes

clipOutput = '{}\Ogma_Clip'.format(tempdata)&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:36:41 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2021-12-11T12:36:41Z</dc:date>
    <item>
      <title>Having issues with arcpy.env.workspace.</title>
      <link>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255499#M19617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have set my workspace, but when I run a simple clip. It just makes a shapefile in the folder location not the geodatabase I have set. The geodatabase is created in the location the user specifies. But it is dumping it into the folder not the geodatabase.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working pin Python 2.7, and ArcMap 10.6&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Seting up folder path parameters from ArcGIs Tool Box&lt;BR /&gt;FolderPath = arcpy.GetParameterAsText(4)&lt;/P&gt;&lt;P&gt;# Naming the Geodatabase for the user.&lt;BR /&gt;WorkGDB = "MTAP_Data"&lt;/P&gt;&lt;P&gt;tempdata = os.path.join(FolderPath, WorkGDB)&lt;/P&gt;&lt;P&gt;# Ensuring if rerun that the output can be overwritten&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;# make sure gdb does not already exist&lt;BR /&gt;if arcpy.Exists(tempdata):&lt;BR /&gt; arcpy.env.workspace = tempdata&lt;BR /&gt;else:&lt;BR /&gt;# Create the new file geodatabase and or overwrite if there is one in place already&lt;BR /&gt; arcpy.CreateFileGDB_management(FolderPath, WorkGDB)&lt;/P&gt;&lt;P&gt;# Set the working environment for Project&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = tempdata&lt;/P&gt;&lt;P&gt;# set up outputwork space outWS&lt;BR /&gt;outWS = tempdata&lt;/P&gt;&lt;P&gt;# Send Arcpy message to verify workspace has been set.&lt;BR /&gt;arcpy.AddMessage("Workspace has been set to: " + str(arcpy.env.workspace))&lt;/P&gt;&lt;P&gt;# Message for tool box outputs - shows location of folder to user&lt;BR /&gt;arcpy.AddMessage("Geodatabase has been created here:" + FolderPath)&lt;/P&gt;&lt;P&gt;# ----------------- End of Geodatabase and folder creation --------------------#&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# -------------Gather Global base data and Clip to user areas -----------------#&lt;BR /&gt;## Issue with workspace - it is not saving into the workspace, as well as it is not saving the right name.&lt;BR /&gt;# User defined input for clipping the regions. (can be Operating areas, or one Op Area&lt;BR /&gt;# clipInput = arcpy.GetParameterAsText(1)&lt;BR /&gt;clipInput = r'\\scripts\Data\Data.gdb\AOI'&lt;/P&gt;&lt;P&gt;OLD = r'Database Connections\my.sde\'OLDData'&lt;/P&gt;&lt;P&gt;arcpy.Clip_analysis(OLD,clipInput,outWS)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2020 04:57:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255499#M19617</guid>
      <dc:creator>AndrewSmith</dc:creator>
      <dc:date>2020-10-22T04:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues with arcpy.env.workspace.</title>
      <link>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255500#M19618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure this is related, but what are you expecting this string be, i.e., print out as?&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;OLD = r'Database Connections\my.sde\'OLDData'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2020 15:45:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255500#M19618</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-10-22T15:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues with arcpy.env.workspace.</title>
      <link>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255501#M19619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have cleaned it up a bit last night to work when I put the direct path for the output but when I switch it over to the variable it no longers works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import os, arcpy, time&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#------------------- Set up File Geodatabase for Project work -----------------#&lt;/P&gt;&lt;P&gt;# Setting up folder path parameters from ArcGIs Tool Box&lt;BR /&gt;FolderPath = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;# Naming the Geodatabase foe the user.&lt;BR /&gt;WorkGDB = "MTAP_Data.gdb"&lt;/P&gt;&lt;P&gt;# Ensuring if rerun that the output can be over written&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;# Create the new file geodatabase and or over write if there is one in place already&lt;BR /&gt;arcpy.CreateFileGDB_management(FolderPath, WorkGDB)&lt;/P&gt;&lt;P&gt;# Set the working environment for MTAP Project&lt;BR /&gt;tempdata = os.path.join(FolderPath, WorkGDB)&lt;BR /&gt;arcpy.env.workspace = tempdata&lt;/P&gt;&lt;P&gt;# Send Arcpy message to verify workspace has been set.&lt;BR /&gt;arcpy.AddMessage("Workspace has been set to: " + str(arcpy.env.workspace))&lt;/P&gt;&lt;P&gt;# Message for tool box outputs - shows location of folder to user&lt;BR /&gt;arcpy.AddMessage("Geodatabase has been created here:" + FolderPath)&lt;/P&gt;&lt;P&gt;# ----------------- End of Geodatabase and folder creation --------------------#&lt;/P&gt;&lt;P&gt;# -------------Gather Global base data and Clip to user areas -----------------#&lt;/P&gt;&lt;P&gt;# User defined input for clipping the regions. (can be Operating areas, or one Op Area&lt;BR /&gt;# clipInput = arcpy.GetParameterAsText(1)&lt;BR /&gt;clipInput = r'\\Data\Data.gdb\AOI'&lt;/P&gt;&lt;P&gt;OLD = r'\\Data\Data.gdb\AREA'&lt;/P&gt;&lt;P&gt;clipOutput = r'\\Data\MTAP_Data.gdb'&lt;BR /&gt;# arcpy.Clip_analysis(OLD,clipInput,clipOutput)&lt;BR /&gt;arcpy.Clip_analysis(OLD, clipInput, clipOutput, '#')&lt;BR /&gt;arcpy.AddMessage("! Script Completed !")&lt;BR /&gt;print( "! Script completed !")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2020 16:15:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255501#M19619</guid>
      <dc:creator>AndrewSmith</dc:creator>
      <dc:date>2020-10-22T16:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues with arcpy.env.workspace.</title>
      <link>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255502#M19620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the &lt;A href="https://pro.arcgis.com/en/pro-app/tool-reference/analysis/clip.htm"&gt;syntax of Clip&lt;/A&gt;:&amp;nbsp; it appears that your clipOutput variable is set to a geodatabase and not a feature class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2020 17:43:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255502#M19620</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2020-10-22T17:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues with arcpy.env.workspace.</title>
      <link>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255503#M19621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for pointing me that way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I did to fix this issue&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;clipOutput = tempdata +'\Ogma_Clip'&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;arcpy.Clip_analysis(OGMA, clipInput, clipOutput, '#')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this then created the resultant into my geodatabase.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2020 18:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255503#M19621</guid>
      <dc:creator>AndrewSmith</dc:creator>
      <dc:date>2020-10-22T18:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Having issues with arcpy.env.workspace.</title>
      <link>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255504#M19622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Glad it worked.&amp;nbsp; As a matter of scripting style, I avoid using a + (plus) sign to concatenate variables.&amp;nbsp; For me the + sign is what you use when you are adding two or more numeric values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Since you are using 2.x Python, I'd recommend the format() function.&amp;nbsp; Once you start using 3.x you get the f string method which is even cooler.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;clipOutput = tempdata +'\Ogma_Clip'

#becomes

clipOutput = '{}\Ogma_Clip'.format(tempdata)&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:36:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/having-issues-with-arcpy-env-workspace/m-p/255504#M19622</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-12-11T12:36:41Z</dc:date>
    </item>
  </channel>
</rss>

