#Code For Clip and Buffer Feature Geoprocessing Script #Created By : Mehraj Qureshi #GIS Anslyst # mehraj.quarish@gmial.com #Date 13-7-2012 ''' This script will perform The ArcGIS clip and Buffer routine for a specified set of features ''' import arcpy,sys,traceback # import modules arcpy.env.workspace = "D:\\PERSONAL\\P\\Pypr\\Chapter04\\Data\\" #create Variable Declaration for Geoprocessing Function outPath = "D:\\PERSONAL\\P\\Pypr\\Chapter04\\MyData\\" inFeature ="City_Facilities.shp" clipFeature = "Central_City_CommPlan.shp" outfile = outPath+"City_Facilities_Clip.shp" bufFeature = "D:\\PERSONAL\\P\\Pypr\\Chapter04\\MyData\\City_Facilities_Clip_buffer.shp" try: if arcpy.Exists(outfile): arcpy.Delete_management(outfile) #delete if the output already Exists print "Starting Clip routine" #parameters using variables arcpy.Clip_analysis(inFeature,clipFeature,outfile) print "Finished Clip Routine" if arcpy.Exists(bufFeature): #delete if the output already Exists arcpy.Delete_management(bufFeature) print "starting Buffer routine" #parameters using variables arcpy.Buffer_analysis(outfile, bufFeature, "100 FEET" ,"","") print "Finished Buffer Routine" except: tb =sys.exc_info()[2] tbinfo =traceback.format_tb(tb) [0] pymsg ="python erros:\n" +tbinfo+ "\nError info:\n" msgs = "Arcpy Errors:\n" +arcpy.GetMessages(2) + "\n" #print error messages in the priocess Dialoge arcpy.AddError(msgs) arcpy.AddError(pymsg) #Print messges to python shell print msgs print pymsg arcpy.AddMessage(arcpy.GetMessages(1)) print arcpy.GetMessages(1)
... View more