Select to view content in your preferred language

Load feature class in memory

5222
3
Jump to solution
09-20-2017 06:27 AM
by Anonymous User
Not applicable

Let's assume I have a geodatabase "database.gdb", and inside this database there is a feature class called "feature".

How can I load this feature in memory using arcpy? I have searched into the arcpy docs and couldn't find anything useful.

I tried to use Copy_management and CreateFeatureclass_management but its look like these methods expects files instead of variables.

0 Kudos
1 Solution

Accepted Solutions
JamesCrandall
MVP Frequent Contributor

Untested

inputFc = r"C:/database.gdb/inputFeatureClass"
outputFc = r"in_memory/inMemoryFeatureClass"
arcpy.CopyFeatures_management(inputFc, outputFc)
‍‍‍

View solution in original post

3 Replies
JamesCrandall
MVP Frequent Contributor

Untested

inputFc = r"C:/database.gdb/inputFeatureClass"
outputFc = r"in_memory/inMemoryFeatureClass"
arcpy.CopyFeatures_management(inputFc, outputFc)
‍‍‍
by Anonymous User
Not applicable

I worked! Thanks a lot! I've lost a day trying to solve this.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Just be aware that in_memory doesn't always mean in memory.  I know, why label something "in_memory" if it doesn't mean it will always be in memory?  If you are running a script outside of ArcGIS Desktop (ArcMap or Pro), then it is actually in memory.  If you run a script from the interactive Python window or a script tool within ArcGIS Desktop, sometimes the output is actually a temporary data set on disk.

For example, with some tools like Create Table and Create Feature Class, in_memory will output to disk if "Background Processing" is enabled:

>>> tbl = arcpy.CreateTable_management("in_memory","test_table")
>>> tbl
<Result 'C:\\Users\\jack\\AppData\\Local\\Temp\\1\\arc3BB1\\j078ec6ad6c664d989a5b08b638ae9acd.gdb\\test_table'>
>>> 

Although a bit dated, most of the information from blogs posts I wrote a few years ago still applies to ArcMap today: