Public Member Functions | Properties
FieldStatOperations Class Reference

Defines group statistic operations for columns of shapefile attribute table. More...

List of all members.

Public Member Functions

void AddFieldIndex (int FieldIndex, tkFieldStatOperation Operation)
 Adds statistic operation for a specified field.
void AddFieldName (string Fieldname, tkFieldStatOperation Operation)
 Adds statistic operation for a specified field.
void Clear ()
 Clears all previously added operations.
string get_ErrorMsg (int ErrorCode)
 Gets the description of the specific error code.
int get_FieldIndex (int operationIndex)
 Gets field index for operation at specified position in the list.
string get_FieldName (int operationIndex)
 Gets field name for operation at specified position in the list.
tkFieldStatOperation get_Operation (int operationIndex)
 Gets operation at specified position in the list.
bool get_OperationIsValid (int operationIndex)
 Gets the value of IsValid flag for operation.
tkFieldOperationValidity get_OperationIsValidReason (int operationIndex)
 Gets a value indicating the reason why the specific operation is invalid.
bool Remove (int operationIndex)
 Removes operations with specified index.
bool Validate (Shapefile sf)
 Checks whether current list of operations is applicable for a given shapefile.

Properties

int Count [get]
 Gets the number of added operations.
string Key [get, set]
 A text string associated with object. Any value can be stored by developer in this property.
int LastErrorCode [get]
 Gets the code of last error which took place inside this object.

Detailed Description

Defines group statistic operations for columns of shapefile attribute table.

Multiple operations can be specified for each field. The results will be written to attribute table of resulting shapefile. An instance of this class is used as a parameter by Shapefile.AggregateShapesWithStats and Shapefile.DissolveWithStats methods. See code sample in description of Shapefile.DissolveWithStats method.

Validation of group operations against counties shapefiles and displaying report about validation:

 var operations = new FieldStatOperations();
 operations.AddFieldName("region", tkFieldStatOperation.fsoMin);
 operations.AddFieldName("population", tkFieldStatOperation.fsoAvg);
 
 string filename = @"d:\counties.shp";
 var sf = new Shapefile();
 if (sf.Open(filename, null))
 {
     operations.Validate(sf);
     for (int i = 0; i < operations.Count; i++)
     {
         if (operations.get_OperationIsValid(i))
         {
             Debug.Print("Operation {0} is valid.", operations.get_Operation(i).ToString());
         }
         else
         {
             Debug.Print("Operation {0} is not valid. Reason: {1}", operations.get_Operation(i).ToString(),  
                                                                    operations.get_OperationIsValidReason(i).ToString());
         }
     }
 }
New API 4.9.1:
Added in version 4.9.1

Member Function Documentation

void FieldStatOperations.AddFieldIndex ( int  FieldIndex,
tkFieldStatOperation  Operation 
)

Adds statistic operation for a specified field.

Parameters:
FieldIndexField index in input shapefile.
OperationOperation to calculate.
void FieldStatOperations.AddFieldName ( string  Fieldname,
tkFieldStatOperation  Operation 
)

Adds statistic operation for a specified field.

Parameters:
FieldnameName of field in input shapefile (case-insensitive)
OperationOperation to calculate.

Clears all previously added operations.

string FieldStatOperations.get_ErrorMsg ( int  ErrorCode)

Gets the description of the specific error code.

Parameters:
ErrorCodeThe error code returned by LastErrorCode property.
Returns:
String with the description.
int FieldStatOperations.get_FieldIndex ( int  operationIndex)

Gets field index for operation at specified position in the list.

Parameters:
operationIndexIndex of operation in list.
Returns:
Field index in input shapefile.
string FieldStatOperations.get_FieldName ( int  operationIndex)

Gets field name for operation at specified position in the list.

Parameters:
operationIndexIndex of operation in list.
Returns:
Field name in input shapefile.

Gets operation at specified position in the list.

Parameters:
operationIndexIndex of operation in list.
Returns:
Operation at specified position (fsoSum will be returned in case of invalid operation index).
bool FieldStatOperations.get_OperationIsValid ( int  operationIndex)

Gets the value of IsValid flag for operation.

The flag is set only after FieldStatOperations.Validate methods was called. The same list of operations may be valid for one shapefile and invalid for another.

Parameters:
operationIndexIndex of operation in list.
Returns:
True in case operation is valid.

Gets a value indicating the reason why the specific operation is invalid.

Parameters:
operationIndexIndex of operation to check the property for.
Returns:
Reason for invalidity or fovValid in operation is applicable.
bool FieldStatOperations.Remove ( int  operationIndex)

Removes operations with specified index.

Parameters:
operationIndexIndex of operation to remove.
Returns:
True on success, false if operation index is invalid.

Checks whether current list of operations is applicable for a given shapefile.

For invalid operations get_OperationIsValid flag and get_OperationIsValidReason property are set. Invalid operations will be skipped when when doing statistic calculations and no output fields will be created for them.

Parameters:
sfShapefile to validate operations list against.
Returns:
True if all operations are valid.

Property Documentation

Gets the number of added operations.

string FieldStatOperations.Key [get, set]

A text string associated with object. Any value can be stored by developer in this property.

Gets the code of last error which took place inside this object.

 All Classes Files Functions Enumerations Properties Events