SelectbyLocation has no result

412
1
09-12-2011 07:09 PM
JiefanYu
New Contributor
I cannot can the selectbylocation's result. When I just run copyfeature, it gets output. But if I add selectbylocation or select by attribute, nothing  export.

Codes:
# Create the Geoprocessor
import arcgisscripting, sys, os
gp = arcgisscripting.create()
gp.workspace = "C:\pro"

# Load required toolboxes
gp.AddToolbox("C:\ArcGIS\ArcToolbox\Toolboxes\Data Management Tools.tbx")

try:
    #Select all polygon that overlap the lines
    gp.SelectLayerByLocation_management("county.shp", "INTERSECT", "road.shp","", "NEW_SELECTION")

    # Within the selection (done above) further select only those attributes satisfy some requirement
    #gp.SelectLayerByAttribute_management("county.shp", "[area] > 13862709075", "road.shp")

   
    # Write the selected features to a new feature class
    gp.CopyFeatures_management("county.shp", "C:\pro\copyfeature.shp")
   

except:
    # If an error occurred, print the message to the screen
    print gp.GetMessages()


Anyone know why this is happening?
0 Kudos
1 Reply
JiefanYu
New Contributor
Never mind, I fixed it. Python and arcgis need every detail to be correct....

codes:

# Create the Geoprocessor
import arcgisscripting, sys, string, os
gp = arcgisscripting.create()
gp.workspace = "C:/pro"

# Load required toolboxes
gp.AddToolbox("C:/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")

try:
    # Process: Find all stream crossings (points)
    #gp.Intersect_analysis("county.shp ; road.shp ", "copyfeature.shp", "#", "", "line")
   
    #Select all polygon that overlap the lines
    gp.SelectLayerByLocation_management("county", "INTERSECT", "road")

    # Within the selection (done above) further select only those attributes satisfy some requirement
    gp.SelectLayerByAttribute_management("county", "NEW_SELECTION", "Shape_Area > 14954576441")

   
    # Write the selected features to a new feature class
    gp.CopyFeatures_management("county", "C:/pro/copyfeature.shp")
   

except:
    # If an error occurred, print the message to the screen
    print gp.GetMessages()
0 Kudos