<?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 Clip Analysis Fail in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/clip-analysis-fail/m-p/224872#M17362</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import sys
import os
# Script to create Shapefiles of WP Infrastructure within a specified boundary
# Define variables
UserName = "n041871"
Shapefile = r"S:\SupportServices\Meet\Arc Gis\Planning Refs\Canning\20150107_CTLE.shp"
Suffix = "CTLE"
#Build Path name for workspace
SDEPre = "C:\Users"
SDEPost = "\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde"
SDE= os.path.join(SDEPre,UserName+SDEPost)
print "Using "+SDE+" as Geodatabase"
arcpy.AddMessage("Using " + str(SDE)+ " as Geodatabase")
arcpy.env.workspace = SDE
arcpy.env.overwriteOutput = True
#Define Layers to Clip
#1. Transmission feature classes
T330OH = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_330kV_OH_Carrier") 
T330UG = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_330kV_UG_Cable")
T220OV = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_220kV_OH_Carrier")
T132OH = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_132kV_OH_Carrier")
T132UG = os.path.join ("GISTRAN.Transmission" , "GISTRAN.Trans_132kV_UG_Cable")
T66OV = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_66kV_OH_Carrier")
T66UG = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_66kV_UG_Cable")
T33OH = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_33kV_OH_Carrier")
T33UG = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_33kV_UG_Cable")
TransStruc = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_Structure")
Substation = os.path.join ("GISTRAN.Transmission", "GISTRAN.Substation")
#Group Transmission Values:
Transmission = (T330OH, T330UG, T220OV, T132OH, T132UG, T66OV, T66UG, T33OH, T33UG, TransStruc, Substation)
 
#2. Distrubution feature classes
POLES = os.path.join("ARCFM.Structure", "ARCFM.Pole")
HVOH = os.path.join("ARCFM.Distribution_HV", "ARCFM.Conductor_HV")
HVUG = os.path.join("ARCFM.Distribution_HV", "ARCFM.Cable_HV")
LVOH = os.path.join("ARCFM.Distribution_LV", "ARCFM.Conductor_LV")
LVUG = os.path.join("ARCFM.Distribution_LV", "ARCFM.Cable_LV")
#Group Distribution Values
Distribution = (POLES, HVOH, HVUG, LVOH, LVUG)
#Future Infrastructure Shapefiles
ISubstation = r"S:\SupportServices\SPIDA Projects\Transmission\Sub-Regional Structure Planning\WP Future Infrastructure\Version 1\WP_New_Sub_stations_20130807.shp"
ILine = r"S:\SupportServices\SPIDA Projects\Transmission\Sub-Regional Structure Planning\WP Future Infrastructure\Version 1\WP_New_Power_Lines_20130807.shp"
#Group New Infrastructure
NewI = (ISubstation, ILine)
#Select Required LOCALITY
arcpy.MakeFeatureLayer_management(Shapefile, "lyr")
#Set Ouput Directory
outputPath = "S:\\SupportServices\\SPIDA Projects\\Infrastructure Shapefiles\\Custom\\"+ str(Suffix)
# Clip Transmission Feature Classes with LOCALITY Layer
for StrucT in Transmission:
&amp;nbsp;&amp;nbsp;&amp;nbsp; basefileName = arcpy.Describe(StrucT).baseName.replace('.','_') + Suffix
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileFormat= '.shp'
&amp;nbsp;&amp;nbsp;&amp;nbsp; finalDest = os.path.join(outputPath,basefileName+fileFormat)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(StrucT,Shapefile,finalDest)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print StrucT + "Shapefile Created"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(StrucT)+" Shapefile Created")
# Clip Distriution Feature Classes with LOCALITY Layer
for StrucD in Distribution:
&amp;nbsp;&amp;nbsp;&amp;nbsp; basefileName = arcpy.Describe(StrucD).baseName.replace('.','_') + Suffix
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileFormat= '.shp'
&amp;nbsp;&amp;nbsp;&amp;nbsp; finalDest = os.path.join(outputPath,basefileName+fileFormat)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(StrucD,Shapefile,finalDest)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print StrucD + " Shapefile created"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(StrucD)+" Shapefile Created")
#Clip New Infrastructure
for Struc in NewI:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not os.path.exists(outputPath):os.makedirs(outputPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; basefileName = arcpy.Describe(Struc).baseName.replace('.','_') + Suffix
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileFormat= '.shp'
&amp;nbsp;&amp;nbsp;&amp;nbsp; finalDest = os.path.join(outputPath,basefileName+fileFormat)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(Struc,Shapefile,finalDest)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print Struc + " Shapefile created"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(Struc)+" Shapefile Created")
#Find empty shapefiles and delete them
arcpy.env.workspace = outputPath
shapefiles = arcpy.ListFeatureClasses()
for shapefile in shapefiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; layerName = arcpy.Describe(shapefile).baseName
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(layerName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management (shapefile, layerName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetCount_management(layerName).getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; if int(arcpy.GetCount_management(layerName).getOutput(0)) == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(shapefile)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print shapefile + " deleted"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(shapefile)+" Deleted")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "All empty shapefiles have been deleted"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("All empty shapefiles have been deleted")
print "process complete"&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am&amp;nbsp; getting the following error:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "S:\SupportServices\Meet\Arc Gis\Scripts\WP_Infrastructure_Shapefile_Cut.py", line 71, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(StrucT,"lyr",finalDest)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\Program Files (x86)\ArcGIS\Desktop10.0\ArcPy\arcpy\analysis.py", line 55, in Clip&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000210: Cannot create output S:\SupportServices\SPIDA Projects\Infrastructure Shapefiles\Custom\CTLE\GISTRAN_Trans_330kV_OH_CarrierCTLE.shp&lt;/P&gt;&lt;P&gt;Failed to execute (Clip).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:57:22 GMT</pubDate>
    <dc:creator>MittRamgobin</dc:creator>
    <dc:date>2021-12-11T10:57:22Z</dc:date>
    <item>
      <title>Clip Analysis Fail</title>
      <link>https://community.esri.com/t5/python-questions/clip-analysis-fail/m-p/224872#M17362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import sys
import os
# Script to create Shapefiles of WP Infrastructure within a specified boundary
# Define variables
UserName = "n041871"
Shapefile = r"S:\SupportServices\Meet\Arc Gis\Planning Refs\Canning\20150107_CTLE.shp"
Suffix = "CTLE"
#Build Path name for workspace
SDEPre = "C:\Users"
SDEPost = "\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde"
SDE= os.path.join(SDEPre,UserName+SDEPost)
print "Using "+SDE+" as Geodatabase"
arcpy.AddMessage("Using " + str(SDE)+ " as Geodatabase")
arcpy.env.workspace = SDE
arcpy.env.overwriteOutput = True
#Define Layers to Clip
#1. Transmission feature classes
T330OH = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_330kV_OH_Carrier") 
T330UG = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_330kV_UG_Cable")
T220OV = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_220kV_OH_Carrier")
T132OH = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_132kV_OH_Carrier")
T132UG = os.path.join ("GISTRAN.Transmission" , "GISTRAN.Trans_132kV_UG_Cable")
T66OV = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_66kV_OH_Carrier")
T66UG = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_66kV_UG_Cable")
T33OH = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_33kV_OH_Carrier")
T33UG = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_33kV_UG_Cable")
TransStruc = os.path.join ("GISTRAN.Transmission", "GISTRAN.Trans_Structure")
Substation = os.path.join ("GISTRAN.Transmission", "GISTRAN.Substation")
#Group Transmission Values:
Transmission = (T330OH, T330UG, T220OV, T132OH, T132UG, T66OV, T66UG, T33OH, T33UG, TransStruc, Substation)
 
#2. Distrubution feature classes
POLES = os.path.join("ARCFM.Structure", "ARCFM.Pole")
HVOH = os.path.join("ARCFM.Distribution_HV", "ARCFM.Conductor_HV")
HVUG = os.path.join("ARCFM.Distribution_HV", "ARCFM.Cable_HV")
LVOH = os.path.join("ARCFM.Distribution_LV", "ARCFM.Conductor_LV")
LVUG = os.path.join("ARCFM.Distribution_LV", "ARCFM.Cable_LV")
#Group Distribution Values
Distribution = (POLES, HVOH, HVUG, LVOH, LVUG)
#Future Infrastructure Shapefiles
ISubstation = r"S:\SupportServices\SPIDA Projects\Transmission\Sub-Regional Structure Planning\WP Future Infrastructure\Version 1\WP_New_Sub_stations_20130807.shp"
ILine = r"S:\SupportServices\SPIDA Projects\Transmission\Sub-Regional Structure Planning\WP Future Infrastructure\Version 1\WP_New_Power_Lines_20130807.shp"
#Group New Infrastructure
NewI = (ISubstation, ILine)
#Select Required LOCALITY
arcpy.MakeFeatureLayer_management(Shapefile, "lyr")
#Set Ouput Directory
outputPath = "S:\\SupportServices\\SPIDA Projects\\Infrastructure Shapefiles\\Custom\\"+ str(Suffix)
# Clip Transmission Feature Classes with LOCALITY Layer
for StrucT in Transmission:
&amp;nbsp;&amp;nbsp;&amp;nbsp; basefileName = arcpy.Describe(StrucT).baseName.replace('.','_') + Suffix
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileFormat= '.shp'
&amp;nbsp;&amp;nbsp;&amp;nbsp; finalDest = os.path.join(outputPath,basefileName+fileFormat)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(StrucT,Shapefile,finalDest)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print StrucT + "Shapefile Created"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(StrucT)+" Shapefile Created")
# Clip Distriution Feature Classes with LOCALITY Layer
for StrucD in Distribution:
&amp;nbsp;&amp;nbsp;&amp;nbsp; basefileName = arcpy.Describe(StrucD).baseName.replace('.','_') + Suffix
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileFormat= '.shp'
&amp;nbsp;&amp;nbsp;&amp;nbsp; finalDest = os.path.join(outputPath,basefileName+fileFormat)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(StrucD,Shapefile,finalDest)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print StrucD + " Shapefile created"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(StrucD)+" Shapefile Created")
#Clip New Infrastructure
for Struc in NewI:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not os.path.exists(outputPath):os.makedirs(outputPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; basefileName = arcpy.Describe(Struc).baseName.replace('.','_') + Suffix
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileFormat= '.shp'
&amp;nbsp;&amp;nbsp;&amp;nbsp; finalDest = os.path.join(outputPath,basefileName+fileFormat)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(Struc,Shapefile,finalDest)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print Struc + " Shapefile created"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(Struc)+" Shapefile Created")
#Find empty shapefiles and delete them
arcpy.env.workspace = outputPath
shapefiles = arcpy.ListFeatureClasses()
for shapefile in shapefiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; layerName = arcpy.Describe(shapefile).baseName
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(layerName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management (shapefile, layerName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetCount_management(layerName).getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; if int(arcpy.GetCount_management(layerName).getOutput(0)) == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(shapefile)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print shapefile + " deleted"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(shapefile)+" Deleted")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "All empty shapefiles have been deleted"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("All empty shapefiles have been deleted")
print "process complete"&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am&amp;nbsp; getting the following error:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "S:\SupportServices\Meet\Arc Gis\Scripts\WP_Infrastructure_Shapefile_Cut.py", line 71, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(StrucT,"lyr",finalDest)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\Program Files (x86)\ArcGIS\Desktop10.0\ArcPy\arcpy\analysis.py", line 55, in Clip&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000210: Cannot create output S:\SupportServices\SPIDA Projects\Infrastructure Shapefiles\Custom\CTLE\GISTRAN_Trans_330kV_OH_CarrierCTLE.shp&lt;/P&gt;&lt;P&gt;Failed to execute (Clip).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:57:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clip-analysis-fail/m-p/224872#M17362</guid>
      <dc:creator>MittRamgobin</dc:creator>
      <dc:date>2021-12-11T10:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Clip Analysis Fail</title>
      <link>https://community.esri.com/t5/python-questions/clip-analysis-fail/m-p/224873#M17363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't spot anything immediately obvious about the output path. If you search desktop help the error code states:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="font-size: 10pt;"&gt;Description&lt;/SPAN&gt;&lt;/H2&gt;&lt;DIV class="gpmsg_desc"&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The output cannot be created. Potential reasons include data locking, an incorrect path, and limited access rights.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;H2&gt;&lt;SPAN style="font-size: 10pt;"&gt;Solution&lt;/SPAN&gt;&lt;/H2&gt;&lt;DIV class="gpmsg_soln"&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Confirm that the data is not locked by another user or application and that you have full rights to the workspace being used. Check to make sure that the path to the data is correct (check for typos in the folder path). Try creating the output in a new location.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would start with say writing to a local c:\temp to confirm that its not a write permissions issues, if that works it would suggest the data has an issue. Try running the clip tool by itself with those datasets to see if the error occurs then?&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jan 2015 11:14:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clip-analysis-fail/m-p/224873#M17363</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2015-01-07T11:14:21Z</dc:date>
    </item>
  </channel>
</rss>

