Select to view content in your preferred language

In memory workspace

9967
20
07-27-2020 02:53 AM
ModyBuchbinder
Esri Regular Contributor

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

0 Kudos
20 Replies
RichRuh
Esri Regular Contributor

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

RichRuh
Esri Regular Contributor

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

 

0 Kudos
Zoggo
by
Occasional Contributor

Where can I find example for this in 2.8?

0 Kudos
RichRuh
Esri Regular Contributor
0 Kudos
DaveLewis73
Regular Contributor

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.

0 Kudos
RichRuh
Esri Regular Contributor

I'm not sure why the URI isn't accepted, but have you tried just creating the layer from the feature class itself?

--Rich

0 Kudos
DaveLewis73
Regular Contributor

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.

0 Kudos
RichRuh
Esri Regular Contributor

I'm sorry, I forgot that step. After calling schemaBuilder.Build() you can get a FeatureClass pointer using Geodatabase.OpenDataset<FeatureClass>("SourcePackageFootprint").

0 Kudos
DaveLewis73
Regular Contributor

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?

0 Kudos
RichRuh
Esri Regular Contributor

The calls to the SchemaBuilder and the OpenDataset call should also be inside QueuedTask.Run()

0 Kudos