FieldStatOperations Class Reference

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

Collaboration diagram for FieldStatOperations:
Collaboration graph

Public Member Functions

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

Properties

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

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());
}
}
}
tkFieldStatOperation
Possible statistic operations for a field during grouping of shapes.
Definition: Enumerations.cs:1866
Defines group statistic operations for columns of shapefile attribute table.
Definition: FieldStatOperations.cs:49
Provides a functionality for accessing and editing ESRI shapefiles.
Definition: Shapefile.cs:72
New API 4.9.1:
Added in version 4.9.1

Member Function Documentation

◆ AddFieldIndex()

void FieldStatOperations.AddFieldIndex ( int  FieldIndex,
tkFieldStatOperation  Operation 
)

Adds statistic operation for a specified field.

Parameters
FieldIndexField index in input shapefile.
OperationOperation to calculate.

◆ AddFieldName()

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.

◆ Clear()

void FieldStatOperations.Clear ( )

Clears all previously added operations

◆ get_ErrorMsg()

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.

◆ get_FieldIndex()

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.

◆ get_FieldName()

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.

◆ get_Operation()

tkFieldStatOperation FieldStatOperations.get_Operation ( int  operationIndex)

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).

◆ get_OperationIsValid()

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.

◆ get_OperationIsValidReason()

tkFieldOperationValidity FieldStatOperations.get_OperationIsValidReason ( int  operationIndex)

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.

◆ Remove()

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.

◆ Validate()

bool FieldStatOperations.Validate ( Shapefile  sf)

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

◆ Count

int FieldStatOperations.Count
get

Gets the number of added operations.

◆ Key

string FieldStatOperations.Key
getset

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

◆ LastErrorCode

int FieldStatOperations.LastErrorCode
get

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