Select to view content in your preferred language

Getting Statistics on a field

1863
12
11-24-2017 05:48 AM
BrianBulla
Regular Contributor II

In ArcObjects I would use Geodatabase.IDataStatistics to get stats on a field.  Does anyone know if an equivalent exists in ArcPro SDK??

Thanks,

0 Kudos
12 Replies
RichRuh
Esri Regular Contributor

@DaveFullerton No changes here. 

I'm not familiar with the CIM*** classes, but if you have a reproducible case you can share with tech support, they can send it to us for investigation.

--Rich

0 Kudos
DaveFullerton
Occasional Contributor III

Thanks @RichRuh .  It has been a while since I looked at this (was interrupted by other priorities).  I will probably contact tech support as you suggest.

0 Kudos
DaveFullerton
Occasional Contributor III

I have looked this over more carefully now and have worked around this as much as I think I need to.  I am just using it to get a unique list of values, so in case anyone else is trying to do that or anyone has any further insights that they would be able to share, this is what I have concluded so far:

 

It is not surprising that I was unable to use Rich Ruh’s code snippet with XY Event Layers since in the Pro GUI you cannot run the “Summarize Statistics'' tool on fields in these layers.  You get an error message about there being no OID field. 

 

You can run the “Summarize Statistics” tool on a field in a layer with a joined table.  However, for using the code snippet, FeatureClass.GetDefinition() and Table.GetDefinition() are expected to throw an exception if called when there is a table join.  This can be found in the API documentation here: 

 

https://pro.arcgis.com/en/pro-app/latest/3.2/api-reference/topic7713.html

 

https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic7014.html

 

So it seems that this is a known limitation and there is a reasonable sounding explanation provided for it, but since “Summarize Statistics” can be done through the Pro GUI when there is a joined table, it is surprising that we cannot do this using the SDK too. 

 

To be clear, in my code, I start with a BasicFeatureLayer, get a Table from it with GetTable() and then use Table.GetDefinition().

 

The thing that initially confused me was that Table.GetDefinition() didn’t throw an exception when the data source of the BasicFeatureLayer was a FGDB feature class and it was joined with a table within that same FGDB.

 

For now, I want to allow users the opportunity to use my addin in the above mentioned FGDB joined table case (or any case that Table.GetDefinition() happens to work), so I decided to do something like this at the beginning when getting the TableDefinition:

            Table table = myBasicFeatureLayer.GetTable();

            TableDefinition tableDefinition;
            try
            {
                tableDefinition = table.GetDefinition();
            }
            catch (Exception e)
            {
                 if (table.IsJoinedTable())
                {
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Won't work with join…");
                }
                else
                {
                    MessageBox.Show("Please contact GIS staff…" + e.ToString());
                }

                return;
            }

 

0 Kudos