Select to view content in your preferred language

Clip Analysis troubles

292
0
12-16-2011 09:45 AM
ChrisBrannin
Regular Contributor
Wondering if anyone would be kind enough to share their thoughts and suggestions on this code. I am trying to have a script that adds a field, updates the field with something and then clips it to a project area. I have it working for a single shapefile, and have commented out what I think I would need to use to get my desired results. Any help would be greatly appreciated, and thanks in advance!
import arcpy, os, sys
import glob
from arcpy import env



#Functions
##fieldName = CONAME
inTest = arcpy.GetParameterAsText(0)
#Project Area used for the clip
clipArea = arcpy.GetParameterAsText(1)
#Directory the clips will be stored
outClip = arcpy.GetParameterAsText(2)
##clipShp = "S:/TallPinesGIS/py/bin/"
#Name of project area
##projectArea_name = arcpy.GetParameterAsText(3)

##(filepath, filename) = os.path.split(clipArea)
##for inTest in glob.glob(S:/TallPinesGIS/py/projectArea/'*.shp')

env = arcpy.env.workspace = "S:/TallPinesGIS/py/"

inTeast = arcpy.MakeFeatureLayer_management(inTest)
clipArea = arcpy.MakeFeatureLayer_management(clipArea)


# Add Field to Polygon for ranking
arcpy.AddMessage('Adding Fields')
arcpy.AddField_management(inTest,"CONAME","TEXT","8","#","#","#","NON_NULLABLE","NON_REQUIRED","#")

rows = arcpy.UpdateCursor(inTest)
for row in rows:
    row.setValue("CONAME", "DODGECO")
    rows.updateRow(row)

# Clip Features to current Project Area
##fileList = arcpy.ListFeatureClasses()
##fileList = glob.glob(inTest + env*)
##for shp in fileList:
 ##   if shp == filename:
    ##    continue
   ## clipShp = inTest "clip_" +"+shp+"
   
arcpy.AddMessage('Clipping features outside of project area')
##arcpy.Clip_analysis(fc,clipArea,clipShp)
arcpy.Clip_analysis(inTest, clipArea, outClip)


Cheers
Chris
Tags (2)
0 Kudos
0 Replies