Hi, I am trying to update a field with different values for each row in a feature class. I have already found a solution, but the performance is pretty slow for feature classes containing more than 10.000 Features. For instance, in a feature class with 100.000 features it may take approximately 3 minutes.
For the time being I am using a cursor obtained by calling the search function in the FeatureClass object.
using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(fgdbPath))))
{
using (FeatureClass table = geodatabase.OpenDataset<FeatureClass>(fcName))
{
var cursor = table.Search(new QueryFilter()
{
SubFields = "OBJECTID, field"
}, false);
while (cursor.MoveNext())
{
var row = cursor.Current;
row["field"] = dictionary[(long) row["OBJECTID"]];
row.Store();
}
}
}
Is there an alternative to update a field faster than Cursor or perhaps I am missing something in the way I use the cursor?.
I also tried running the geoprocess Join Field which runs way faster than using the cursor, but in that case an intermediate table must be created in first place and later replace the new field for the old field.
Any suggestion is welcome. Thanks!
Hi Eloy,
Is the feature class you are editing has any relationship classes with messaging enabled, you might want to use an edit session (i.e., Geodatabase.ApplyEdits). Otherwise, what you are doing is the fastest way currently. We are investigating creating an UpdateCursor class in a future version of Pro.
--Rich
Hi Rich,
Thanks for answering. The feature class has not relationship class with messaging enbled. An update cursor would be super userful.
Eloy.
I'd be curious what performance gains you'd get by moving from file geodatabase to a sqlite geodatabase, and using something like microsoft.data.sqlite to do the updates.