Is there a way to create a subfolder in memory in ArcPy?

For example, instead of temporarily saving a dataset under:


I would like to save it under:


This spits out an error message, of course. But is there a way to still achieve the same effect?

Background: I am working on a tool that create a lot of intermediate data that does not need to be saved. Right now I am saving each intermediate output into separate folders, which makes it easier to check out the outputs during testing, and it avoids the annoyance of filtering when using things like arcpy.ListFeatureClasses() (that is actually the number one reason for using all these subfolders):

enter image description here

Now that I know that I am getting the correct results I would like to save most of these steps in_memory, to speed up the tool. It would be ideal if I could just adopt this structure and change a few paths in my script instead of adding a lot of filter logic.

  • 2
    why not simply write your path with an "_" if you want a track of the structure ? in_memory/buffer_bufferone – radouxju Aug 24 '15 at 13:25
  • This is exactly what I needed! So simple, yet I would not have thought of it! You should post this as an answer, so I can mark it. – BritishSteel Aug 24 '15 at 13:45
  • Or create python lists of feature classes you want lumped together as you work with them... a_firstBuff = [fc1, fc12, fc25], etc. – Emil Brundage Aug 24 '15 at 14:29
  • I did this before but I ran into an issue at some point; cannot remember why. But I read today that appending to a list can be exhaustive when used in a loop with big datasets. I am trying to keep as much out of my loops as possible, as Arc is already having trouble with my script. – BritishSteel Aug 24 '15 at 15:37

No - in_memory workspaces are only similar to and not identical to geodatabase workspaces. They support feature classes but not feature datasets.

This is documented on the Using in-memory workspace help page:

Feature datasets or folders cannot be created in the in-memory workspace.

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.