Editing features very slow

2111
11
01-25-2022 08:12 PM
JoeMadrigal
New Contributor III

I'm looking for a way to save feature attributes a fast as possible.  The two methods I have tried are pretty slow.  I have a feature dataset in a geodatabase (also tried shapefile) that I am applying a spatial intersect and editing those features that fall in my polygon.  I have tried the EditOperation and also the Inspector shown below.  I'm editing (changing attributes) over 27,000 features.  The modifyoperation takes 10 minutes and the Inspector code takes 23 minutes, which both seem way to slow.  I'm doing this in release mode (debug mode takes way too long).

 

 

 

// Using Edit Operation
var modifyOp = new ArcGIS.Desktop.Editing.EditOperation();
modifyOp.Name = "my edit";

// Create an extent rectangle
SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter
{
    FilterGeometry = CreateDomainPolygon(X, Y, length),
    SpatialRelationship = SpatialRelationship.Intersects
};
using (RowCursor fCursor = pFClass.Search(spatialQueryFilter, false))
{
    while (fCursor.MoveNext())
    {
       using (Row row = fCursor.Current)
       {
            nameVal = (string)row.GetOriginalValue(nameIndex);
            modifyOp.Modify(row, "fieldName1", dict[nameVal]);
            modifyOp.Modify(row, "fieldName2", dict[nameVal]);
       }
    }
}
modifyOp.Execute();

// Inspector inside rowcursor (slower!)
using (Feature pFeature = (Feature)fCursor.Current)
{
    nameVal = (string)pFeature.GetOriginalValue(nameIndex);
    insp.Load(pLayer, pFeature.GetObjectID());
    insp["fieldName1"] = dict[nameVal];
    insp["fieldName2"] = dict[nameVal];
    insp.Apply();
}

 

 

 

 I am wanting to get these down to a minute if possible.  Is there a faster/better way to edit feature attributes?

0 Kudos
11 Replies
Kevin_Andras
New Contributor III

In my situation, I have very large polyline feature classes representing river networks.  I run executables (FORTRAN!!!) to get model results - e.g. fish habitat - in tabular format for each feature.   Here's what I've done to speed things up to a marginally acceptable level:

  • Add attribute indexes to the fields that are getting updated
  • Check if the new field value is different than the old value; only store if it's changed
0 Kudos
MK13
by
Occasional Contributor

Next time I will try adding attribute indeces to see if it improves performance. My work around was to copy my sde data to memory, perform all updates there and then transfer the updates back to the sde data using a spatial unique identifier.

I always assumed that EditOperation.Execute() only made updates if the values were different so that check could be redundant but I am not 100% sure on that.

0 Kudos