Select to view content in your preferred language

Erase tool: Cannot create output

1242
1
06-07-2013 01:31 PM
LudwigHilger
Deactivated User
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.py
Traceback (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 e
arcgisscripting.ExecuteError: ERROR 000210: Cannot create output D:\R_working_di
rectory\Connectivity\Ausgangsshapes\integrate\anthropogenic_temp_25832.shp
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,
Ludwig
Tags (2)
0 Kudos
1 Reply
T__WayneWhitley
Honored Contributor
Not sure if this is your only problem, but think your shapefile name is too long--- according to the below shapefile specification, it must adhere to an 8.3 convention, i.e. 8 alphanumeric characters for the name portion (excluding the extension)...

In your error, the following output name is quoted, which obviously exceeds this limitation:
anthropogenic_temp_25832.shp


"All file names adhere to the 8.3 naming convention. The main file, the index file, and the
dBASE file have the same prefix. The prefix must start with an alphanumeric character
(a�??Z, 0�??9), followed by zero or up to seven characters (a�??Z, 0�??9, _, -)."
http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf


Also this:
Geoprocessing considerations for shapefile output
Geodata » Data types
http://resources.arcgis.com/en/help/main/10.1/index.html#//005600000013000000

ERROR 000210: Cannot create output ... WORKAROUND
http://forums.arcgis.com/threads/58946-ERROR-000210-Cannot-create-output-...-WORKAROUND


Enjoy,
Wayne
0 Kudos