2

I am running a script that is working (see below) - it pulls a file from a folder, clips from that file based on an intersection with another file, and creates a new shapefile in a new folder. It has been working, except that it generates empty outputs for only some of the inputs.

With some research I've tried the following fixes to no avail:

  1. Check extent and projection of Clipping feature to match that of the Input features.
  2. Shorten output file name (hence the awkward string parsing in the output)
  3. Standard re-boot of computer, programs.
  4. [edit] Also convert Clipping file from Multi-Part to Single-Part Polygon.

Any ideas? Do you see quirks with my script? Are there quirks of Clip tool? Thanks!

#Script - Clip selected buffer circles from WEA areas.
#Input: VTRX_1_distX_sel.shp
#Clip: WEA file
#Send output to clip folder 

import arcpy import sys import os from arcpy import env

#Set overwrite arcpy.env.overwriteOutput = True print arcpy.env.overwriteOutput

#Set workspace workspace = "C:\\BOEM\\circle_areas\\" arcpy.env.workspace = workspace sel_files = workspace+"selectedcirc\\"

fileList = [] count = 0

directorypath = "C:\\BOEM\\circle_areas\\selectedcirc\\"

for dirname, dirnames, filenames in os.walk(directorypath):
    for filename in filenames:
        if filename.endswith("1_sel.shp"):
         #   filename = "VTR10_1_dist1_sel.shp"
            print "___"
            print "Clipping from " + filename
            print "___"
            in_features = sel_files+filename
            clip_features = "C:\\BOEM\\circle_areas\\WEA_proj_sing.shp"
            out_features = workspace+"clip\\"+filename[0:5]+"_"+filename[11:13]+"c.shp"
            print "Input file " + in_features
            print "Output file " + out_features

            #Clip
            arcpy.Clip_analysis(in_features, clip_features, out_features,"")
            print arcpy.GetMessages()
            print "___"
            print "___"
            print "___"
            ##
3
  • Have you tried doing the clip in ArcMap? Is so, what were your results?
    – Jamie
    Commented Mar 28, 2013 at 15:13
  • Ah, just saw your comment...same answer applies.....at least one of the input files that produced and empty output when processed in the script do in fact produce a proper output when processed "by hand" with the Clip tool outside the script.
    – SharonB
    Commented Mar 28, 2013 at 15:14
  • After additional tests, one script-failing input works outside the script; another does not. Very confusing.
    – SharonB
    Commented Mar 28, 2013 at 15:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.