import arcpy, os inSHP = r"C:\tmp\myShapefile.shp" #shapefile name featName = os.path.basename(inSHP) #build path to in_memory feature clas inMemoryFC = os.path.join("in_memory",featName[:-4]) arcpy.CopyFeatures_management(inSHP, inMemoryFC) #OPTIONAL - check featCount = int(arcpy.GetCount_management(inMemoryFC).getOutput(0)) print featCount
Some more notes on in_memory:
The in_memory workspace is only valid for geoprocessing tools; it is not a general-purpose virtual directory when you can write any data.
Clean up after using "in_memory" using Delete_management
For example,
Projects = os.path.join("in_memory","Projects") arcpy.MakeFeatureLayer_management(<pathToFC>,"Proj_lyr") arcpy.CopyFeatures_management("Proj_lyr",Projects) arcpy.Delete_management("Proj_lyr") print("Projects Copied")
https://pro.arcgis.com/en/pro-app/latest/tool-reference/appendices/using-the-in-memory-output-workspace.htm
https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm
https://desktop.arcgis.com/en/arcmap/10.3/analyze/modelbuilder/the-in-memory-workspace.htm
https://gis.stackexchange.com/questions/35468/what-is-the-proper-syntax-and-usage-for-arcgis-in-memory-workspace
https://community.esri.com/t5/arcgis-pro-sdk-questions/in-memory-workspace/m-p/787036
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.