Hello all
I could not find any class or example for in memory workspace.
From the other hand there are many arcpy examples with in memory.
So (for example) if I run a GP tool from the SDK and let arcpy create a feature class in memory how do I access it from my code after it was created.
Thanks
Hi Mody,
I've been working with Nobbir Ahmed on your question.
There's no direct way to work with in-memory feature classes using the Pro SDK, but there is an indirect way.
When you run your geoprocessing tool with the Pro SDK, set it up to output your results to a map. If you do that, a FeatureLayer is added to the map. You can then call FeatureLayer.GetFeatureClass() to get a FeatureClass object. You should be able to treat that as a regular feature class. (Note that If you call FeatureClass.GetDatastore() you get back an object with type UnknownDatastore, which isn't especially useful).
I hope this helps,
--Rich
Hi @ModyBuchbinder ,
I just wanted to let you know that you will be able to directly create memory geodatabases and tables within them using the Pro SDK at 2.8.
--Rich
Where can I find example for this in 2.8?
Here is a snippet showing how to create a memory geodatabase.
Once you have created the geodatabase, here is a snippet showing how to create a feature class.
I hope this helps,
--Rich
Rich,
I am trying to create an in-memory feature class and then add it to my map. I believe I have the creation of the feature class working from the snippets that you have provided, but I can't seem to get a layer created. My code is
var featLayerCreateParams = new FeatureLayerCreationParams(new Uri(@"\\memory\SourcePackageFootprint"));
featLayerCreateParams.Name = "Source Package Footprint";
Layer layer = LayerFactory.Instance.CreateLayer<FeatureLayer>(featLayerCreateParams, MapView.Active.Map, LayerPosition.AddToTop);
However, this does not work. I get an error of "failed to add data, unsupported data type \\memory\SourcePackageFootprint". What am I doing wrong?
P.S. Thank you for the snippets. They were quite helpful in building the in memory feature class.
I'm not sure why the URI isn't accepted, but have you tried just creating the layer from the feature class itself?
--Rich
I followed the "Creating a Feature Class" snippet, but I don't see where an actual feature class object is created. I just get the success from calling schemaBuilder.Build(). That is how I assumed that the code was working.
I'm sorry, I forgot that step. After calling schemaBuilder.Build() you can get a FeatureClass pointer using Geodatabase.OpenDataset<FeatureClass>("SourcePackageFootprint").
That seems to have worked. Thank you. The only question that I have now is regarding the asynchronous aspect of this code. Should I bracket the entire subroutine into QueuedTask.Run() or just the CreateFeatureLayer portion?
The calls to the SchemaBuilder and the OpenDataset call should also be inside QueuedTask.Run()