5

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)
  • Is the dataset called AND? Is that a keyword? like trying to create a folder in windows called 'con'. What data type is it? Is it going to be too big for the installed memory? – Michael Stimson Nov 27 '14 at 23:18
  • @MichaelMiles-Stimson My answer to the question should explain how "AND" came about as a feature class name in the work I was doing. It's easy to workaround but I wanted to save others the time of troubleshooting the cause if they ever encounter it. Perhaps Esri's Software Developers can trap for such names in their code and use a tempory alternative name during processing. – PolyGeo Nov 27 '14 at 23:31
15

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?).

  • Many thanks for the additional highly informative answer. When I read that you looking into this I thought the list might be a bit longer. Nice work! – PolyGeo Nov 28 '14 at 5:39
  • It's not finished yet, it's only completed the 3 letter words. I'll update on Monday when I get back in with a more comprehensive list. – Michael Stimson Nov 28 '14 at 5:41
  • 3
    Naming rules and restrictions are discussed at resources.arcgis.com/en/help/main/10.1/index.html#//… One of the specific, universal rules you didn't mention is no spaces either. But restricted words vary depending on the underlying DBMS - they will be different between say, a personal geodatabase (Access restricted words) and Oracle. They may even differ between versions. ArcGIS file geodatabase restriction list here. – Chris W Nov 28 '14 at 5:57
  • Yes, I forgot the 'no spaces' bit. It's not in my test code. I didn't get any problems with gdb_, sde_ or delta_ (yet). That particular article I have read and is a great general help but does not pertain to in_memory specifically... still if you follow those rules you're not likely to experience issues. – Michael Stimson Nov 30 '14 at 22:17
  • 1
    It did @Barbarossa but the results were as expected, all the SQL keywords couldn't be used. Thus it's impossible to create a table called 'select'.. such a list can be found msdn.microsoft.com/en-us/library/ms189822.aspx – Michael Stimson Mar 18 '16 at 2:14
6

The cause of this error appears to be the use of the word "AND" in the name of the in_memory feature class that is trying to be created. The name "AND" may be undesirable, but can arise when the names are being constructed from field values. For example, "AND" is the abbreviation for the country "Andorra" in at least one of the Natural Earth datasets.

To see that "AND" causes the error, when a string like "XXX" does not, run the test below which has no problem with "XXX" but produces the error when it tries to do the same thing involving a field value of "AND".

Most of the code is for creating suitable test data to reproduce the error.

import arcpy

if arcpy.Exists("C:/temp/test.gdb"):
    arcpy.Delete_management("C:/temp/test.gdb")
arcpy.CreateFileGDB_management("C:/temp","test.gdb")

arcpy.CreateFishnet_management(out_feature_class="C:/temp/test.gdb/FishnetFC",
                               origin_coord="0 0",y_axis_coord="0 1",
                               cell_width="1",cell_height="1",
                               number_rows="1",number_columns="1",
                               corner_coord="#",labels="NO_LABELS",
                               template="#",geometry_type="POLYGON")
arcpy.AddField_management(in_table="C:/temp/test.gdb/FishnetFC",
                          field_name="Name",field_type="TEXT",
                          field_precision="#",field_scale="#",
                          field_length="3",field_alias="#",
                          field_is_nullable="NULLABLE",
                          field_is_required="NON_REQUIRED",field_domain="#")
arcpy.CalculateField_management(in_table="C:/temp/test.gdb/FishnetFC",
                                field="Name",expression="'AND'",
                                expression_type="PYTHON",code_block="#")
arcpy.Copy_management(in_data="C:/temp/test.gdb/FishnetFC",
                      out_data="C:/temp/test.gdb/FishnetFC2",
                      data_type="FeatureClass")
arcpy.CalculateField_management(in_table="C:/temp/test.gdb/FishnetFC",
                                field="Name",expression="'XXX'",
                                expression_type="PYTHON",code_block="#")

arcpy.env.workspace = "C:/temp/test.gdb"
arcpy.env.overwriteOutput = True


# This CopyFeatures to in_memory WORKS when feature being copied is called XXX
with arcpy.da.SearchCursor("C:/temp/test.gdb/FishnetFC2",["Name","SHAPE@"]) as cursor:
    for row in cursor:
        in_memory_feature = "in_memory\\" + row[0]
        arcpy.CopyFeatures_management(row[1],in_memory_feature)

# This CopyFeatures to in_memory ERRORS when feature being copied is called AND
with arcpy.da.SearchCursor("C:/temp/test.gdb/FishnetFC",["Name","SHAPE@"]) as cursor:
    for row in cursor:
        in_memory_feature = "in_memory\\" + row[0]
        arcpy.CopyFeatures_management(row[1],in_memory_feature)

The error is:

Traceback (most recent call last):
  File "C:\polygeo\test.py", line 37, in <module>
    arcpy.CopyFeatures_management(row[1],in_memory_feature)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 2429, in CopyFeatures
    raise e
ExecuteError: ERROR 000210: Cannot create output in_memory\AND
Failed to execute (CopyFeatures).
  • I wonder how many other reserved words there are. There are usually name restrictions on data, for example: feature classes in a database cannot start with a number or underscore, shapefiles can only have alphanumeric characters and underscore in their name (though they work just fine if you put a dash in later, they can't be created with a dash). Databases don't allow feature classes with SQL reserved words for names, so I think it's a case like that but the docs don't say. Perhaps try a few more and publish a more comprehensive list. – Michael Stimson Nov 28 '14 at 0:17
  • Field called 'GRID_CODE' caused me troubles, e.g. feature to raster didn't work in 10.1 – FelixIP Nov 28 '14 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.