Erase tool: Cannot create output

Discussion created by ludwighilger on Jun 7, 2013
Latest reply on Jun 9, 2013 by Wayne_Whitley
Hello everybody,
what follows are my very first steps in Python, so my mistake might be easy to find. I have 22 Shapefiles, some of the overlap and I want to clean this using the erase function on every shapefile with all others sequently as erase features, however I get the following error:

Here is my script:

#! /usr/bin/env python
# -*- coding: utf-8 -*-

# muss ausgeführt werden mit: "C:\Python27\ArcGISx6410.1\python.exe"
# Hilfe zu Funktionen: e.g. help("glob.glob")
# current directory: print os.getcwd()
import os, glob, sys, arcpy, re
from arcpy import env
arcpy.env.overwriteOutput = True

wdir = "D:/R_working_directory/Connectivity/Ausgangsshapes/integrate/"
shapes = glob.glob("./*.shp")
for j in list(xrange(len(shapes))): 
 erases = shapes[:j] + shapes[(j + 1):]
 input = shapes[j].split(".")[1]
 input = input.split("\\")[1]
 input = input + ".shp"
 output = wdir + input.split("_")[0] + "_temp_" + input.split("_")[1]
 for x in list(xrange(len(erases))):
  erase = erases[x].split("\\")[1]
  arcpy.Erase_analysis(in_features = wdir + input, erase_features = erase, out_feature_class = output, cluster_tolerance = 0)
  os.remove(wdir + input) # remove the old file
  os.renames(old = output, new = wdir + input) # rename produced file to the name of the old one

And this is the error I get:

Traceback (most recent call last):
  File "", line 22, in <module>
    arcpy.Erase_analysis(in_features = wdir + input, erase_features = erase, out
_feature_class = output, cluster_tolerance = 0)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\", line
205, in Erase
    raise e
arcgisscripting.ExecuteError: ERROR 000210: Cannot create output D:\R_working_di
Failed to execute (Erase).

I have been trying to solve this for several hours now, but obviously I miss something important. Any help would be very much appreciated.

Thanks and regards,