开发者

selecting row among duplicated ones in VBA

开发者 https://www.devze.com 2022-12-31 17:42 出处:网络
ArcGIS 9.3 Arcobject I wanna select one row of each duplicated SIDs in a field below. (an attribute table of a shape file)

ArcGIS 9.3 Arcobject

I wanna select one row of each duplicated SIDs in a field below. (an attribute table of a shape file)

The priority is R > S = 开发者_C百科I > 0

Therefore, among SID 87, FID1 will be selected.

(SID 88, STATUS will be S+I)

(SID 89, FID 6 will be chosen)

Please kindly advise VBA cord to run the selection and thanks.

FID    SID    STATUS 
 1     87       R
 2     87       O
 3     88       I
 4     88       S
 5     89       I
 6     89       R      
 7     89       I
 8     89       S


This might not be the optimal way, but you could try something like this:

  1. Use ITable.Search with a null QueryFilter to open a cursor of all rows in the table.
  2. Create a DataStatistics object, and pass the the cursor to the IDataStatistics.Cursor property.
  3. Use the IDataStatistics.UniqueValues property to get the set of unique SID values in the table.
  4. For each unique SID value, use ITable.Search to open a cursor containing all rows having the SID.
  5. Using the logic you described, determine the FID of the row that should be added to the selection for the specific SID.
  6. Create a SelectionSet object, setting your table as an object. Use either the Add method to add a single row or the AddList method to add a list of rows to the selection set.
  7. Use this SelectionSet to set the IFeatureSelection.SelectionSet property on the shapefile.

Sorry, because I'm new, I can't post hyperlinks to the help, but here's the starting page to the VB6 help for ArcObjects 9.3:

http://resources.esri.com/help/9.3/arcgisengine/com_cpp/vb6_start.htm

0

精彩评论

暂无评论...
验证码 换一张
取 消