jiefanyu

How to export a new layer by python after select by location?

Discussion created by jiefanyu on Aug 29, 2011
Latest reply on Aug 31, 2011 by jiefanyu
My mission is to select some polygons by location ( intersect with existing lines), and then export the result as a new shape file layer. I have been trying different ways and search for helps but it ended to nothing yet. So please help if you know. Following is my current codes:
    # Import system modules
    import sys, string, os, arcgisscripting
    # Create the Geoprocessor object
    gp = arcgisscripting.create()
    # Load required toolboxes
    gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management.tbx")

try:
    # Set the workspace (to avoid having to type in the full path to the data every time)
    gp.Workspace = "C:\temp"
    gp.overwriteOutput = 1
    outFolder = r???C:\Temp???
    outFile = ???Polygon.shp???
    gp.workspace = outFolder
   
 
    gp.CreateFeatureClass (outFolder, outFile, ???Polygon???, ???#???,???#???,???#???, "#")
    # Script arguments...
    Output_Feature_Class = outFile
    Input_Features = sys.argv[1]
   
   
    # Process: Find all stream crossings (points)
    gp.SelectLayerByLocation(Input_Features, "intersect", Output_Feature_Class)

except:
    # If an error occurred while running a tool, print the messages.
    print gp.GetMessages()

Outcomes