# Script Name: Clip Multiple Feature Classes # Description: Clips one or more shapefiles # from a folder and places the clipped # feature classes into a geodatabase. # Created By: Me. # Date: 082711. # Import ArcPy site-package and os modules # import arcpy import os # Set the input workspace # arcpy.env.workspace = arcpy.GetParameterAsText(0) # Set the clip featureclass # clipFeatures = arcpy.GetParameterAsText(1) # Set the output workspace # outWorkspace = arcpy.GetParameterAsText(2) # Set the XY tolerance # clusterTolerance = arcpy.GetParameterAsText(3) try: # Get a list of the featureclasses in the input folder # fclist = ("S_R04_FIF.ActivityPolygon","S_R04_FIF.GeosciSri") for fc in fclist: # Validate the new feature class name for the output workspace. # featureClassName = arcpy.ValidateTableName(fc + "_Clip", outWorkspace) outFeatureClass = os.path.join(outWorkspace, featureClassName) # Clip each feature class in the list with the clip feature class. # Do not clip the clipFeatures, it may be in the same workspace. # if fc != os.path.basename(clipFeatures): arcpy.Clip_analysis(fc, clipFeatures, outFeatureClass, clusterTolerance) except: arcpy.AddMessage(arcpy.GetMessages(2)) print arcpy.GetMessages(2)
C:\>python Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel) Type "help", "copyright", "credits" or "license" for more information. >>>
python myClip.py
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.