Creating a Geoprocessing result in a Named MemoryConnectionProperties

248
2
07-29-2022 04:08 AM
dkuida
by
New Contributor II

Hello

When I creade a 

MemoryConnectionProperties("someInatcneName")

in DDL, how to pass connection a Geoprocessing to use that workspace, or feature classes to be created in that specific instance 

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

This is how I have used it to copy an existing feature class into the memory geodatabase

      MemoryConnectionProperties memoryConnectionProperties = new MemoryConnectionProperties();
      var results = await QueuedTask.Run(async () =>
      {
        using (Geodatabase geodatabase = SchemaBuilder.CreateGeodatabase(memoryConnectionProperties))
        {
          var copyResult = await CopyFeatureClass(SelectedFCFeatureLayer.GetFeatureClass(), "memory", "VirtualInputLayer");
          if (copyResult == null) return false;
          using (FeatureClass virtualFC = geodatabase.OpenDataset<FeatureClass>("VirtualInputLayer")) 
          //rest of code

--------functions---------

    public static async Task<IGPResult> CopyFeatureClass(FeatureClass InFC, string OutputPath, string OutputName, string SQLExpression = null, string FieldMap = null, string ConfigurationKeyword = null)
    {
      List<object> arguments = new List<object>
      {
        InFC, //Input features
        OutputPath, //Output location
        OutputName, //Output Name 
        SQLExpression, //Expression (optional)
        FieldMap, //Field Map optional)
        ConfigurationKeyword //Configuration Keyword (optional)
      };
      IGPResult result = await Geoprocessing.ExecuteToolAsync("conversion.FeatureClassToFeatureClass", Geoprocessing.MakeValueArray(arguments.ToArray()), null, null, null, GPExecuteToolFlags.None);
      return result;
    }

 

RichRuh
Esri Regular Contributor

Dkuida,

The Pro SDK allows you to create multiple memory geodatabases, each with an arbitrary name, as you have shown in your code above.

Geoprocessing, on the other hand, only supports one memory geodatabase, called "memory", which can be created with either of these two lines:

MemoryConnectionProperties()
MemoryConnectionProperties("memory")

Ken's reply shows how to create and use this memory geodatabase with geoprocessing.

--Rich

 

0 Kudos