i want to create a python scipt query using arpy in arcgis
i have one polyline shapefile and one polygon shapefile i want to choose(select) the polygons where contained within in the polylines shapefiles or there intersections and finaly i want that select polygons to export to new shapefile layer.
i use arcmap 10.1
my code is
# Import arcpy module
import arcpy
from arcpy.sa import *
arcpy.CheckOutExtension("spatial")
arcpy.env.overwriteOutput = True
try:
arcpy.env.workspace = root
root = arcpy.GetParameterAsText(0)
polygon = arcpy.GetParameterAsText(1)
line = arcpy.GetParameterAsText(2)
except:
arcpy.AddMessage(arcpy.GetMessages())
try:
arcpy.SelectLayerByLocation_management(polygon, "INTERSECT", line, "", "NEW_SELECTION")
arcpy.FeatureClassToShapefile_conversion("polygon", newpolygon)
newpolygon = root + "\\newpolygon"
except:
arcpy.AddMessage(arcpy.GetMessages())
i use that code but i dont take Correct Results my root workspace is empty
any idea ?
Best Answer
This script can be further edited but commonly this script should work
Thanks.