Hi everyone,This is the second post I have made on this subject.....I couldnt find the old post. Here is my script. Everything seems to be in order however when the clip function runs, it clips features by the window extent...however it produces and empty shape file. Any ideas?Thanks!
#DESCRIPTION:
#-clips Hydro and trapper features by data frame window extent
#-dissolves hyrdro layer to simplify line work
#-densify's both features to create more detailed line work
#-matches the trapper lines accordingly with the water features
#Import arcpy modules
import arcpy
#import operating system-level tools - usefull when working with paths
import os
#displays location of python script
home = os.getcwd()
#Declare Water feature variable
Hydro = "G:/Data/GIS/ArcGIS_Mapping/Hydrography.gdb/Watercourse_Poly"
#Provides access to map document
mxd = arcpy.mapping.MapDocument("CURRENT")
#Directs output shapefile to specified folder
arcpy.env.workspace = "C:/Users/DJenkins/Desktop/Temp_Folder Apr2012 - Present/Python/Trapper Script/Output Shape"
#Allows data to be overwritten
arcpy.env.overwriteOutput = True
#Makes a copy of original Trapper Line Data
arcpy.CopyFeatures_management("LINE DATA & DISPOSITIONS/Trapper Lines","Trapper_copy")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
extent = df.extent
array = arcpy.Array()
array.add(extent.lowerLeft)
array.add(extent.lowerRight)
array.add(extent.upperRight)
array.add(extent.upperLeft)
array.add(extent.lowerLeft)
poly = arcpy.Polygon(array)
#Clip Trapper feature by window extent
arcpy.Clip_analysis("Trapper_copy",poly,"Trapper_Extent")
#Clip Hydro feature by window extent
arcpy.Clip_analysis(Hydro,poly,"Hydro_extent")
#Dissolve Hydro_copy
arcpy.Dissolve_management("Hydro_extent","Hydro_Dissolve","FID")
#Find the number of features in the the trapper_extent & Hydro_copy
arcpy.GetCount_management("Trapper_Extent")
arcpy.GetCount_management("Hydro_Dissolve")
try:
#Add more points along trapper/Hydro features
arcpy.Densify_edit("Trapper_Extent", "DISTANCE", "25 meters")
arcpy.Densify_edit("Hydro_Dissolve", "DISTANCE", "25 meters")
#Snap the trapper points to match the Hydro features
arcpy.Snap_edit("Trapper_Extent", [["Hydro_Dissolve","EDGE", "250 meters"]])
except:
#Print the results
print arcpy.GetMessages(2)
else:
print "Congradulations! The script finished successfully. Your trapper lines now match with the hydro features."
del mxd