AnsweredAssumed Answered

Multiple clip using a feature class in a geodatabase

Question asked by abejerman on Sep 24, 2015
Latest reply on Sep 25, 2015 by wwmiller68

Hello everybody,I´m a student and new in python. As an excercise I have to create an script, which, using a feature class existing in a geodatabase, should clip other featureclasses existing in the same geodatabase (but not clipping itself) and add the prefix "NewFile" to the feature classes that were clipped, however, I arrive to some point where I´m lost and don´t know exactly how to finish the script, can somebody help me with that?

Thank you in advance!

 

import arcpy, os

from arcpy import env

arcpy.env.workspace = arcpy.GetParameterAsText(0)

clipFeatures = 'D:\\datosvalle\\Valle.mdb\\Santiago_de_cali'

outWorkspace = 'D:\\datosvalle\\Valle.mdb'

clusterTolerance = ""

try:

    fcs = arcpy.ListFeatureClasses()

    for fc in fcs:

        featureClassName = arcpy.ValidateTableName("Newfile_"+fc, outWorkspace)

        outFeatureClass = os.path.join(outWorkspace, featureClassName)

        if fc <> os.path.basename (clipFeatures):

            arcpy.Clip_analysis(fc, clipFeatures, outFeatureClass, clusterTolerance)

except: arcpy.AddMessage(arcpy.GetMessages(2))

print "The files were correctly clipped"

Attachments

Outcomes