AnsweredAssumed Answered

Clip Loop through select feature classes in an SDE

Question asked by meethyl on Sep 24, 2014

Hi all - I am a python newbie

 

I need to loop a clip analysis through a select number of feature classes. I have tried the following code but it fails at the last stage.

What is going wrong? And how can I fix it?

 

import arcpy import sys import os # Script to create LGA Map with WP Infrastructure # Define variables arcpy.env.workspace = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde" arcpy.env.overwriteOutput = True #LGA = arcpy.GetParameterAsText(0) # Input Required Local Government Area LGA ="COOROW, SHIRE OF" #Define Layers to Intersect #1. Transmission Layers T330OH = arcpy.ListFeatureClasses("GISTRAN.Trans_330kV_OH_Carrier","All","GISTRAN.Transmission") T330UG = arcpy.ListFeatureClasses("GISTRAN.Trans_330kV_UG_Cable","All","GISTRAN.Transmission") T220OV = arcpy.ListFeatureClasses("GISTRAN.Trans_220kV_OH_Carrier","All","GISTRAN.Transmission") T132OH = arcpy.ListFeatureClasses("GISTRAN.Trans_132kV_OH_Carrier","All","GISTRAN.Transmission") T132UG = arcpy.ListFeatureClasses("GISTRAN.Trans_132kV_UG_Cable","All","GISTRAN.Transmission") T66OV = arcpy.ListFeatureClasses("GISTRAN.Trans_66kV_OH_Carrier","All","GISTRAN.Transmission") T66UG = arcpy.ListFeatureClasses("GISTRAN.Trans_66kV_UG_Cable","All","GISTRAN.Transmission") T33OH = arcpy.ListFeatureClasses("GISTRAN.Trans_33kV_OH_Carrier","All","GISTRAN.Transmission") T33UG = arcpy.ListFeatureClasses("GISTRAN.Trans_33kV_UG_Cable","All","GISTRAN.Transmission") TransStruc = arcpy.ListFeatureClasses("GISTRAN.Trans_Structure","All","GISTRAN.Transmission") Substation = arcpy.ListFeatureClasses("GISTRAN.Substation","All","GISTRAN.Transmission") #Group Transmission Values: Transmission = (T330OH, T330UG, T220OV, T132OH, T132UG, T66OV, T66UG, T33OH, T33UG, TransStruc, Substation) #2. Distrubution Layers POLES = arcpy.ListFeatureClasses("ARCFM.Pole","All","ARCFM.Structure") HVOH = arcpy.ListFeatureClasses("ARCFM.Conductor_HV","All","ARCFM.Distribution_HV") HVUG = arcpy.ListFeatureClasses("ARCFM.Cable_HV","All","ARCFM.Distribution_HV") LVOH = arcpy.ListFeatureClasses("ARCFM.Conductor_LV","All","ARCFM.Distribution_LV") LVUG = arcpy.ListFeatureClasses("ARCFM.Cable_LV","All","ARCFM.Distribution_LV") #Group Distribution Values Distribution = (POLES, HVOH, HVUG, LVOH, LVUG)                                     #Select Required LGA arcpy.MakeFeatureLayer_management("GISEXT.Local_Government_Authority", "LGAlyr") fieldName = "NAME" Query = "\""+fieldName+"\"='"+LGA+"'" arcpy.SelectLayerByAttribute_management ("LGAlyr", "NEW_SELECTION", Query) #arcpy.SelectLayerByAttribute_management ("LGAlyr", "NEW_SELECTION", """ "NAME" = 'ALBANY, CITY OF' """) - working code for Struc in Transmission:     outputPath = r"C:\Test"     basefileName = str(Struc)+str(LGA)     fileFormat= '.shp'     finalDest = os.path.join(outputPath,basefileName+fileFormat)     arcpy.Clip_analysis(Struc,"LGAlyr", finalDest) print "Process ended" 

  File "S:\SupportServices\Meet\Arc Gis\Scripts\LGA Maps.py", line 52, in <module>

    arcpy.Clip_analysis(Struc,"LGAlyr", finalDest)

  File "c:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\analysis.py", line 55, in Clip

    raise e

RuntimeError: Object: Error in executing tool

Outcomes