AnsweredAssumed Answered

Fast Insertion of Multiple Features

Question asked by mattrjackson on Mar 11, 2019
Latest reply on Mar 13, 2019 by RRuh-esristaff

This may be a duplicate of Writing Features into FGDB very slow, but since the answer to that is over a year old, I thought it'd be worth seeing if there is a solution to the issue, since the final post from ESRI stated it would be re-evaluated after 2.2 was released.

 

I am currently working on an arcgis pro plugin (v. 2.3) that will be placing a number of features into a feature class (somewhere in the range of 50-1000 features), and then onto the map. When I tested adding features with the ArcGIS Pro SDK, I used the following code snippet:

await QueuedTask.Run(async () =>
{

var geodb = new ArcGIS.Core.Data.Geodatabase(new ArcGIS.Core.Data.FileGeodatabaseConnectionPath(new Uri(mypath)));

 

var fc = geodb.OpenDataset<FeatureClass>("MyVector");
for (int i = 0; i < 1000; ++i)
{
     var buffer = fc.CreateRowBuffer();
     buffer["name"] = "a name";
     buffer["widget_count"] = i;
     var f = fc.CreateRow(buffer);
     f.SetShape(ArcGIS.Core.Geometry.MapPointBuilder.CreateMapPoint(i * .01, 0));
}

fc.Dispose();

geodb.Dispose();

});

 

Unfortunately, it's taking ~10 sec to complete this simple set of inserts on a fairly high-end development machine. Just to make sure it wasn't due to the debugger, I then ran the add-in without the debugger, and verified I got the the same rough time.  When I execute the same task with GDAL/OGR in C# using the ESRI FileGDB driver, it consistently completes in 0.5 sec. Is there a more performant way to do this using the ArcGIS Pro SDK API? 

 

Along those lines, every time I'm executing an arcgis pro toolbox method, let's say for example, "Add Field", is it behind the scenes merely spawning a python process and running the function? If I am using multiple toolbox methods sequentially, would I expect better performance wrapping these calls inside a single python script instead?

 

Thanks for your time,

 

Matt

Outcomes