Shapefile attribute table

Functions

int Shapefile.EditAddField (string name, FieldType type, int precision, int width)
 Adds a field to the attribute table of the shapefile. The table must be in editing mode. More...
 
bool Shapefile.EditCellValue (int fieldIndex, int shapeIndex, object newVal)
 Sets the new value for particular cell in attribute table. The table must be in editing mode. More...
 
bool Shapefile.EditDeleteField (int fieldIndex, ICallback cBack)
 Deletes a field with the specified index from the attribute table. The table must be in editing mode. More...
 
bool Shapefile.EditInsertField (Field newField, ref int fieldIndex, ICallback cBack)
 Inserts a new field in the shapefile attribute table. The table must be in editing mode. More...
 
object Shapefile.get_CellValue (int fieldIndex, int shapeIndex)
 Gets the value of the specified field for the shape. More...
 
Field Shapefile.get_Field (int fieldIndex)
 Gets a specific field stored in the attribute table. More...
 
Field Shapefile.get_FieldByName (string fieldname)
 Gets specific field stored in the attribute table. More...
 
int Shapefile.get_FieldIndexByName (string fieldName)
 Gets index of field with specified name. More...
 
bool Shapefile.HasOgrFidMapping ()
 For OGR-derived Shapefiles, indicates whether or not an internal mapping exists from the constant OGR FID value to the currently assigned Shape Index. More...
 
long Shapefile.OgrFid2ShapeIndex (long OgrFid)
 For OGR-derived Shapefiles, you can use this function to get the Shape Index that is currently associated with the specified OGR FID value (which is constant for each row). More...
 
bool Shapefile.StartEditingTable (ICallback cBack)
 Opens editing mode for the attribute table. More...
 
bool Shapefile.StopEditingTable (bool applyChanges, ICallback cBack)
 Closes the editing mode for the attribute table. More...
 

Properties

bool Shapefile.EditingTable [get]
 Gets the value indicating whether editing operations are allowed for shapefile attribute table. More...
 
int Shapefile.NumFields [get]
 Gets the number of fields in attribute table of the shapefile. More...
 
Table Shapefile.Table [get]
 Gets the reference to the attribute table associated with the shapefile. More...
 

Detailed Description

Here is a list of properties and methods to for interaction with attribute table associated with a shapefile. This module is a part of the documentation of Shapefile class.

dot_inline_dotgraph_26.png

Graph description

Function Documentation

◆ EditAddField()

int Shapefile.EditAddField ( string  name,
FieldType  type,
int  precision,
int  width 
)

Adds a field to the attribute table of the shapefile. The table must be in editing mode.

Parameters
nameThe name of field.
typeThe type of field.
precisionThe precision of field.
widthThe width of field.
Returns
The index of the new field or -1 on failure.
Examples
AddCategoryRange.cs, CreateBuffer.cs, RemoveShape.cs, and Segmentation.cs.

◆ EditCellValue()

bool Shapefile.EditCellValue ( int  fieldIndex,
int  shapeIndex,
object  newVal 
)

Sets the new value for particular cell in attribute table. The table must be in editing mode.

Parameters
fieldIndexThe index of field in attribute table.
shapeIndexThe index of shape (row number in attribute table).
newValThe variant value to be passed (integer, double and string values are accepted depending on field type).
Returns
True on success and false otherwise.
Examples
AddCategoryRange.cs, CalculateArea.cs, CreateBuffer.cs, EditAttributes.cs, IntersectionLength.cs, MinimalDistance.cs, and Segmentation.cs.

◆ EditDeleteField()

bool Shapefile.EditDeleteField ( int  fieldIndex,
ICallback  cBack 
)

Deletes a field with the specified index from the attribute table. The table must be in editing mode.

Parameters
fieldIndexAn index of field to be deleted.
cBackAn instance of class implementing ICallback interface. It's recommended to pass NULL and use Shapefile.GlobalCallback property instead.
Returns
Returns true on success and false otherwise

◆ EditInsertField()

bool Shapefile.EditInsertField ( Field  newField,
ref int  fieldIndex,
ICallback  cBack 
)

Inserts a new field in the shapefile attribute table. The table must be in editing mode.

Parameters
newFieldA new instance of field object to insert.
fieldIndexA position to insert the new field. An invalid index will be automatically substituted with 0 or Shapefile.NumFields.
cBackAn instance of class implementing ICallback interface. It's recommended to pass NULL and use Shapefile.GlobalCallback property instead.
Returns
True on success and false otherwise.
Examples
IntersectionLength.cs, and MinimalDistance.cs.

◆ get_CellValue()

object Shapefile.get_CellValue ( int  fieldIndex,
int  shapeIndex 
)

Gets the value of the specified field for the shape.

The value will be returned as VARIANT data type. When passing to then .NET it will be converted to either integer, double or string data type depending on the type of field.

Parameters
fieldIndexThe index of field.
shapeIndexThe index of shape.
Returns
The value stored in the field.
Examples
ShowAttributes.cs, and ZoomToValues.cs.

◆ get_Field()

Field Shapefile.get_Field ( int  fieldIndex)

Gets a specific field stored in the attribute table.

Parameters
fieldIndexThe index of the field to be retrieved.
Returns
Reference to the field object or NULL reference on failure.

◆ get_FieldByName()

Field Shapefile.get_FieldByName ( string  fieldname)

Gets specific field stored in the attribute table.

Parameters
fieldnameThe name of the Field to be retrieved. The comparison of the names is case insensitive.
Returns
Reference to the Field object or NULL reference on failure.

◆ get_FieldIndexByName()

int Shapefile.get_FieldIndexByName ( string  fieldName)

Gets index of field with specified name.

Parameters
fieldNameField name.
Returns
Index of field in attribute table or -1 if no such field is found.
New API 4.9.3:
Added in version 4.9.3

◆ HasOgrFidMapping()

bool Shapefile.HasOgrFidMapping ( )

For OGR-derived Shapefiles, indicates whether or not an internal mapping exists from the constant OGR FID value to the currently assigned Shape Index.

If the associated OGR Layer has an FID field, an internal mapping is built automatically and is available for the purpose of resolving a volatile Shape Index from a fixed FID value. This is because the Shape Index for a given shape is not guaranteed to be the same each time the OGR layer is reloaded. This is particularly true in a multi-user database environment.

Returns
True if the internal mapping exists, otherwise false
See also
Shapefile.OgrFid2ShapeIndex
New API 5.2:
Added in version 5.2

◆ OgrFid2ShapeIndex()

long Shapefile.OgrFid2ShapeIndex ( long  OgrFid)

For OGR-derived Shapefiles, you can use this function to get the Shape Index that is currently associated with the specified OGR FID value (which is constant for each row).

Parameters
OgrFidFID field value from OGR data source

If the associated OGR Layer has an FID field, an internal mapping is built automatically and is available for the purpose of resolving a volatile Shape Index from a fixed FID value. This is because the Shape Index for a given shape is not guaranteed to be the same each time the OGR layer is reloaded. This is particularly true in a multi-user database environment.

Returns
The Shape Index that is currently associated with the specified OGR FID value
See also
Shapefile.HasOgrFidMapping
New API 5.2:
Added in version 5.2

◆ StartEditingTable()

bool Shapefile.StartEditingTable ( ICallback  cBack)

Opens editing mode for the attribute table.

Parameters
cBackA callback object to report errors and progress information.
Returns
True on success and false otherwise.
Examples
AddCategoryRange.cs, and CalculateArea.cs.

◆ StopEditingTable()

bool Shapefile.StopEditingTable ( bool  applyChanges,
ICallback  cBack 
)

Closes the editing mode for the attribute table.

Parameters
applyChangesA boolean value which indicates whether changes made to the memory version of table should be saved to the drive.
cBackA callback object to report errors and progress information.
Returns
True on success and false otherwise.
Examples
CalculateArea.cs.

Properties

◆ EditingTable

bool Shapefile.EditingTable
get

Gets the value indicating whether editing operations are allowed for shapefile attribute table.

Use Shapefile.StartEditingTable and Shapefile.StopEditingTable to control editing mode.

Examples
CalculateArea.cs.

◆ NumFields

int Shapefile.NumFields
get

Gets the number of fields in attribute table of the shapefile.

Examples
EditAttributes.cs, MinimalDistance.cs, and ShowAttributes.cs.

◆ Table

Table Shapefile.Table
get

Gets the reference to the attribute table associated with the shapefile.

Examples
AddCategoryRange.cs, CalculateArea.cs, EditAttributes.cs, PointIcons.cs, SelectBox.cs, ShowAttributes.cs, SplitByAttribute.cs, and ToolTip.cs.