<?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: Clipping multiple feature classes from one input feature. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/clipping-multiple-feature-classes-from-one-input/m-p/1005358#M59160</link>
    <description>&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;I'd suggest adding the '.gdb' extension to your variable denoting the file geodatabase you create a few lines later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;WorkGDB = "MTAP_Data.gdb"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm only saying this because the doc relating to&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/create-file-gdb.htm" target="_blank" rel="noopener"&gt;CreateFileGDB&lt;/A&gt; mentions this file extension in the examples.&lt;/P&gt;&lt;P&gt;Also, you point to a new variable&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;outWS = tempdata&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;outWS, which is a path concatenation of the folder and file gdb.&lt;/P&gt;&lt;P&gt;There seems to be a double up/clash here where the paths to the fileGDB are joined (outWS is already a path to the workGDB so maybe remove the second param 'workGDB' below?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;clipfc = os.path.join(outWS,WorkGDB, os.path.basename(fc.split('.')[0]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's really helpful to run each tool you use to build your script in arcPro on some data and copy the python snippet from the result, pasting it into your IDE. That way you see what syntax arcpy 'likes' and then structure your params similarly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
    <pubDate>Sun, 29 Nov 2020 11:03:01 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2020-11-29T11:03:01Z</dc:date>
    <item>
      <title>Clipping multiple feature classes from one input feature.</title>
      <link>https://community.esri.com/t5/python-questions/clipping-multiple-feature-classes-from-one-input/m-p/427625#M33614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to get this code to work.&lt;/P&gt;&lt;P&gt;What is does is the user assigns a shape or feature class to clip sever pre-defined layers, and rename those layers according to the listed layers.&amp;nbsp; Such as clip the layers from area of Interest (AOI) and rename them in the new geodatabase as per the original name in the list.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I keep getting an error such as:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ARCPY ERRORS:&lt;BR /&gt;ERROR 000210: Cannot create output \\Workspace\\scripts\P_2020\Data\P_Data\P_Data\bctsdata&lt;BR /&gt;Failed to execute (Clip).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PYTHON ERRORS:&lt;BR /&gt;Traceback Info:&lt;BR /&gt; File "\\Workspace\P_2020\scripts\P_Project2020_V2.py", line 143, in &amp;lt;module&amp;gt;&lt;BR /&gt; arcpy.Clip_analysis(fc,clipInput,clipfc)&lt;/P&gt;&lt;P&gt;Error Info:&lt;BR /&gt; &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000210: Cannot create output \\Workspace\scripts\P_2020\Data\P_Data\MTAP_Data\data&lt;BR /&gt;Failed to execute (Clip).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is my code. Thank you in advance:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#---------------------------MTAP Script Main Body ------------------------------&lt;BR /&gt;#======================= GDB and Folder Set Up (STEP 1)========================#&lt;BR /&gt;# Seting up folder path peramters 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;# Ensureing if re-run 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 enviroment for MTAP Project&lt;BR /&gt;tempdata = os.path.join(FolderPath, WorkGDB)&lt;/P&gt;&lt;P&gt;# make sure gdb does not already exist&lt;BR /&gt;if arcpy.Exists(tempdata):&lt;BR /&gt; arcpy.Delete_management(tempdata)&lt;BR /&gt; arcpy.env.workspace = tempdata&lt;BR /&gt;else:&lt;BR /&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, 'CURRENT')&lt;BR /&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) + '\n')&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 + '\n')&lt;/P&gt;&lt;P&gt;# ============ End of Geodatabase and folder creation (STEP 1) =============== #&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# ========= Gather Global base data and Clip to user areas (STEP 2) ========== #&lt;/P&gt;&lt;P&gt;# set constant vaiblaes for layers for data prep:&lt;BR /&gt;clip_lyr = 'Clip_area_lyr'&lt;/P&gt;&lt;P&gt;# Global varibles for MTAP operations ---------&lt;/P&gt;&lt;P&gt;FC1 = r'\\Data\Data.gdb\AREA_R'&lt;BR /&gt;FC2 = r'\\Data\Data.gdb\Net_Downs_G'&lt;BR /&gt;FC3 = r'\\\Data\Data.gdb\TAM_G'&lt;BR /&gt;FC4 = r'\\Data\Data.gdb\Woodshed_LU'&lt;BR /&gt;FC5 = r'\\Data\Data.gdb\TRIM750M'&lt;/P&gt;&lt;P&gt;FCList = [FC1, FC2, FC3, FC4, FC5]&lt;/P&gt;&lt;P&gt;# ------USER DEFINED VAIBLES --------------------------------------------------#&lt;BR /&gt;# AOI (Area of interest for clipping data from&lt;BR /&gt;clipInput = arcpy.GetParameterAsText(5)&lt;/P&gt;&lt;P&gt;# Query if needed for selecting from AOI&lt;BR /&gt;query = arcpy.GetParameterAsText(6)&lt;BR /&gt;# -----------------------------------------------------------------------------#&lt;/P&gt;&lt;P&gt;# ensure Clip layer does not already exist in the geodatabase.&lt;BR /&gt;try:&lt;BR /&gt; if arcpy.Exists(clip_lyr):&lt;BR /&gt; arcpy.Delete_management(clip_lyr)&lt;/P&gt;&lt;P&gt;# make new layer the selected feature to clip from ( user input clipInput to make Clip_Lyr)&lt;BR /&gt; arcpy.MakeFeatureLayer_management(clipInput, clip_lyr, query)&lt;BR /&gt; result = int(arcpy.GetCount_management(clip_lyr).getOutput(0))&lt;/P&gt;&lt;P&gt;# loop through multiple feature classes and clip&lt;BR /&gt; for fc in FCList:&lt;BR /&gt; clipfc = os.path.join(outWS,WorkGDB, os.path.basename(fc.split('.')[0]))&lt;BR /&gt; arcpy.Clip_analysis(fc,clipInput,clipfc)&lt;BR /&gt; arcpy.AddMessage('Clipped: ' + os.path.basename(fc))&lt;/P&gt;&lt;P&gt;arcpy.AddMessage("! Script Completed !" + '\n')&lt;BR /&gt; print( "! Script completed !" + '\n')&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;except:&lt;/P&gt;&lt;P&gt;tb = sys.exc_info()[2]&lt;BR /&gt; tbinfo = traceback.format_tb(tb)[0]&lt;BR /&gt; pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n " +\&lt;BR /&gt; str(sys.exc_type) + ": " + str(sys.exc_value) + "\n"&lt;BR /&gt; msgs = "ARCPY ERRORS:\n" + arcpy.GetMessages(2) + "\n"&lt;/P&gt;&lt;P&gt;arcpy.AddError(msgs)&lt;BR /&gt; arcpy.AddError(pymsg)&lt;/P&gt;&lt;P&gt;print msgs&lt;BR /&gt; print pymsg&lt;/P&gt;&lt;P&gt;arcpy.AddMessage(arcpy.GetMessages(1))&lt;BR /&gt; print arcpy.GetMessages(1)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 23:34:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-multiple-feature-classes-from-one-input/m-p/427625#M33614</guid>
      <dc:creator>AndrewSmith</dc:creator>
      <dc:date>2020-11-02T23:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Clipping multiple feature classes from one input feature.</title>
      <link>https://community.esri.com/t5/python-questions/clipping-multiple-feature-classes-from-one-input/m-p/1005358#M59160</link>
      <description>&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;I'd suggest adding the '.gdb' extension to your variable denoting the file geodatabase you create a few lines later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;WorkGDB = "MTAP_Data.gdb"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm only saying this because the doc relating to&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/create-file-gdb.htm" target="_blank" rel="noopener"&gt;CreateFileGDB&lt;/A&gt; mentions this file extension in the examples.&lt;/P&gt;&lt;P&gt;Also, you point to a new variable&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;outWS = tempdata&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;outWS, which is a path concatenation of the folder and file gdb.&lt;/P&gt;&lt;P&gt;There seems to be a double up/clash here where the paths to the fileGDB are joined (outWS is already a path to the workGDB so maybe remove the second param 'workGDB' below?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;clipfc = os.path.join(outWS,WorkGDB, os.path.basename(fc.split('.')[0]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's really helpful to run each tool you use to build your script in arcPro on some data and copy the python snippet from the result, pasting it into your IDE. That way you see what syntax arcpy 'likes' and then structure your params similarly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 11:03:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-multiple-feature-classes-from-one-input/m-p/1005358#M59160</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-29T11:03:01Z</dc:date>
    </item>
  </channel>
</rss>

