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
os.chdir("D:/R_working_directory/Connectivity/Ausgangsshapes/integrate")
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.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.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
exit()
And this is the error I get:D:\py_Files>C:\Python27\ArcGISx6410.1\python.exe erase_ArcGIS.pyTraceback (most recent call last): File "erase_ArcGIS.py", 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\analysis.py", line 205, in Erase raise earcgisscripting.ExecuteError: ERROR 000210: Cannot create output D:\R_working_directory\Connectivity\Ausgangsshapes\integrate\anthropogenic_temp_25832.shpFailed 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,Ludwig