The ArcGIS for Desktop "ERROR 000210: Cannot create output" has been reported on this site a number of times but an in_memory workspace seems to have been implicated only once:
ERROR 000210: Cannot create output in_memory
which was in Getting 000210 Error trying to wirte output to in_memory workspace in ModelBuilder?
I have just encountered the same error message from ArcPy, using ArcGIS 10.2.2 for Desktop both in a Python script tool and from IDLE.
I have determined the cause and so I am asking a question in order to provide an answer to anyone who may encounter it in future.
What causes the error message below from ArcPy?
ExecuteError: ERROR 000210: Cannot create output in_memory\AND
Failed to execute (CopyFeatures)
Answer
Not wishing to detract from PolyGeo's excellent answer I wanted to know what other words can't be used for creating feature classes. To this end I wrote a simple script in python to try every alphanumeric combination and found some interesting results:
- Names cannot start with a number
- Dashes are not allowed
At the risk of putting the 'horse before the cart' I think it's worthwhile to review the results before disclosing the code:
- is a bad name
0 is a bad name
1 is a bad name
2 is a bad name
3 is a bad name
4 is a bad name
5 is a bad name
6 is a bad name
7 is a bad name
8 is a bad name
9 is a bad name
by is a bad name (copy)
in is a bad name (copy)
is is a bad name (copy)
or is a bad name (copy)
add is a bad name (copy)
and is a bad name (copy)
for is a bad name (copy)
not is a bad name (copy)
set is a bad name (copy)
drop is a bad name (copy)
from is a bad name (copy)
into is a bad name (copy)
like is a bad name (copy)
null is a bad name (copy)
It is interesting that feature classes can be created with 'bad' names using CreateFeatureClass but when using CopyFeatures certain names are not allowed; also, interestingly, names can start with underscores - perhaps then we should be prepending with underscore (for example: "in_memory\\_" + name
) to 'sanitise' names before using.
The code:
import arcpy
inFC = r'D:\Name\masked\for\anonymity.shp'
LogFileName ="d:\\Name\\masked\\for\\anonymity\\BadNameLog.txt"
def LogResults(input):
arcpy.AddMessage(input)
LogFile = open(LogFileName,'a')
LogFile.write(input + "\n")
LogFile.close() # flush and write
alphaRange=range(97,123) # a to z
alphaRange.append(95) # underscore
alphaRange.append(45) # dash, found to be never valid
numericRange=range(48,58) # numbers
# add the range of numbers to the characters
alphaRange.extend(numericRange)
# single character names
for a in alphaRange:
outName = chr(a)
try:
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name")
# at this point we determine that names can't start with numbers or a dash, so remake the list
# for the 2nd and subsequent characters to avoid starting with numbers or dash
startAlphaRange=range(97,123) # a to z
alphaRange.append(95) # underscore
# also, it is determined that dash is not valid, every name containing it
# comes back as bad so remake the list without the dash
# two character names
for a in startAlphaRange:
for b in alphaRange:
outName = chr(a) + chr(b)
try:
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (create)")
outName = chr(a) + chr(b)
try:
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (copy)")
LogResults("End two character names")
# three character names
for a in startAlphaRange:
for b in alphaRange:
for c in alphaRange:
outName = chr(a) + chr(b) + chr(c)
try:
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (create)")
outName = chr(a) + chr(b) + chr(c)
try:
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (copy)")
LogResults("End three character names")
# four character names
for a in startAlphaRange:
for b in alphaRange:
for c in alphaRange:
for d in alphaRange:
outName = chr(a) + chr(b) + chr(c) + chr(d)
try:
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (create)")
outName = chr(a) + chr(b) + chr(c) + chr(d)
try:
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (copy)")
LogResults("End four character names")
# five character names
for a in startAlphaRange:
for b in alphaRange:
for c in alphaRange:
for d in alphaRange:
for e in alphaRange:
outName = chr(a) + chr(b) + chr(c) + chr(d) + chr(e)
try:
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (create)")
outName = chr(a) + chr(b) + chr(c) + chr(d) + chr(e)
try:
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (copy)")
LogResults("End five character names")
# six character names
for a in startAlphaRange:
for b in alphaRange:
for c in alphaRange:
for d in alphaRange:
for e in alphaRange:
for f in alphaRange:
outName = chr(a) + chr(b) + chr(c) + chr(d) + chr(e) + chr(f)
try:
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (create)")
outName = chr(a) + chr(b) + chr(c) + chr(d) + chr(e) + chr(f)
try:
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (copy)")
LogResults("End six character names")
# seven character names
for a in startAlphaRange:
for b in alphaRange:
for c in alphaRange:
for d in alphaRange:
for e in alphaRange:
for f in alphaRange:
for g in alphaRange:
outName = chr(a) + chr(b) + chr(c) + chr(d) + chr(e) + chr(f) + chr(g)
try:
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CreateFeatureclass_management("in_memory",outName,"POINT")
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (create)")
outName = chr(a) + chr(b) + chr(c) + chr(d) + chr(e) + chr(f) + chr(g)
try:
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
outName = outName.upper()
arcpy.CopyFeatures_management(inFC,"in_memory\\" + outName)
arcpy.Delete_management("IN_MEMORY\\" + outName) # clean up
except:
LogResults (outName + " is a bad name (copy)")
LogResults("End seven character names")
The code incrementally tries every character combination (lower then upper) and logs the name when the operation fails; it will take a long time to run but in the end every plausible combination from one to seven characters will be tried. Note: I have not included punctuation or non-keyboard characters. Other language sets may have different words that are bad, based on the findings the bad words are SQL keywords and they're all English (aren't they?).
No comments:
Post a Comment