I'm currently using ArcGIS 10.2.1. In previous custom geoprocessing tools, I've used the following code to create a feature class in-memory, and set the spatial reference using an existing layer in ArcMap:

polygon = arcpy.GetParameterAsText(0)

mem_point = arcpy.CreateFeatureclass_management("in_memory", "mem_point", "POINT", "", "DISABLED", "DISABLED", polygon)

Where polygon is a layer in the ArcMap TOC. This has always worked in the past, but I just went to use one of the tools, and I got the following error:

Traceback (most recent call last):   File "", line 23, in <module>
     mem_point = arcpy.CreateFeatureclass_management("in_memory", mem_name, "POINT", "", "DISABLED", "DISABLED", polygon)   File "",
line 1800, in CreateFeatureclass
     raise e ExecuteError: ERROR 000622: Failed to execute (Create Feature Class). Parameters are not valid. ERROR 000628: Cannot set
input into parameter spatial_reference.

Did this just recently change?

  • I just ran this at 10.2.2 and it worked. Are you able to successfully run the CreateFeatureClass tool in the python window by dragging and dropping the polygon layer from the TOC into its appropriate parameter?
    – Adam
    Jan 20, 2015 at 21:03
  • @amarinel No, I get the same error. Weird...
    – ianbroad
    Jan 20, 2015 at 21:05
  • 1
    I tried looking up any bugs at 10.2.1 but could find anything relevant.
    – Adam
    Jan 20, 2015 at 21:05
  • 1
    This is the command I am running in the python window of ArcMap. My point layer in the table of contents is named CommonLocations. arcpy.CreateFeatureclass_management("in_memory", "mem_point", "POINT", "#", "DISABLED", "DISABLED", 'CommonLocations')
    – Adam
    Jan 20, 2015 at 21:19
  • Why don't you just use arcpy.SpatialReference(WKID)?
    – MrBubbles
    Jan 25, 2015 at 20:28

1 Answer 1


As I read the Help at 10.2, you need to provide a path to an existing prj file, feature class or dataset, or set a spatial reference. There's no mention of using a layer file from the TOC. The Help seems to be the same back to 10.0; 9.3 help is different, but not as clear to me. If you set the workspace to wherever your Polygon layer is (assuming that's not it's actual name) your code may work.

  • Yeah, I know for a fact that this worked in at least 10.1. I recently updated to 10.2.1, so that must have done it. I have quite a few tools to fix. I guess I don't see why the path to the feature class works, but the ArcMap layer doesn't now. It was just a really nice, easy way to get the spatial reference.
    – ianbroad
    Jan 20, 2015 at 20:59
  • I agree that the 10.2 help does not mention the ability to use a TOC layer...but after a quick test, I can confirm that this works at version 10.2.2.
    – Adam
    Jan 20, 2015 at 21:04

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.