Shapefile Class Reference

Provides a functionality for accessing and editing ESRI shapefiles. More...

Collaboration diagram for Shapefile:
Collaboration graph

Public Member Functions

Shapefile AggregateShapes (bool selectedOnly, int fieldIndex)
 Creates a new shapefile by creating multi-part shapes from shapes with the same value of specified attribute. More...
 
Shapefile AggregateShapesWithStats (bool selectedOnly, int fieldIndex=-1, FieldStatOperations statOperations=null)
 Creates a new shapefile by creating multi-part shapes from shapes with the same value of specified attribute. More...
 
bool BeginPointInShapefile ()
 Caches the coordinates of shapefile points for faster point in shape test. More...
 
Shapefile BufferByDistance (double distance, int nSegments, bool selectedOnly, bool mergeResults)
 Creates a new shapefile by building a buffer around the shapes of the input shapefile. More...
 
void ClearCachedGeometries ()
 Clears GEOS geometries cached during certain geoprocessing tasks. More...
 
Shapefile Clip (bool selectedOnlySubject, Shapefile sfOverlay, bool selectedOnlyOverlay)
 Clips current shapefile by the definition shapefile. More...
 
Shapefile Clone ()
 Creates a copy of the shapefile. More...
 
bool Close ()
 Closes shapefile and releases all the resources. More...
 
bool CreateNew (string shapefileName, ShpfileType shapefileType)
 Initializes in-memory shapefile of the specified type. More...
 
bool CreateNewWithShapeID (string shapefileName, ShpfileType shapefileType)
 Initializes in-memory shapefile of the specified type with unique index field. More...
 
bool CreateSpatialIndex (string shapefileName)
 Creates a new spatial index More...
 
void Deserialize (bool loadSelection, string newVal)
 Restores the state of shapefile from the string. More...
 
Shapefile Difference (bool selectedOnlySubject, Shapefile sfOverlay, bool selectedOnlyOverlay)
 Calculates difference of 2 shapefiles. More...
 
Shapefile Dissolve (int fieldIndex, bool selectedOnly)
 Merges shapes of the input shapefile based on specified attribute. More...
 
Shapefile DissolveWithStats (int fieldIndex, bool selectedOnly, FieldStatOperations statOperations=null)
 Merges shapes of the input shapefile based on specified attribute. More...
 
bool Dump (string shapefileName, ICallback cBack=null)
 Writes the contents of the shapefile to specified file. More...
 
int 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...
 
int EditAddShape (Shape shape)
 Adds a new shape to the shapefile. More...
 
bool 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 EditClear ()
 Deletes all the shapes from the shapefile. More...
 
bool 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 EditDeleteShape (int shapeIndex)
 Deletes a shape from the shapefile. More...
 
bool 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...
 
bool EditInsertShape (Shape shape, ref int shapeIndex)
 Inserts a new shape in the shapefile. More...
 
bool EditUpdateShape (int shapeIndex, Shape shpNew)
 Substitutes shape at specified index with another instance. More...
 
void EndPointInShapefile ()
 Clears the cached data allocated by Shapefile.BeginPointInShapefile. More...
 
Shapefile ExplodeShapes (bool selectedOnly)
 Creates a new instance of shapefile class with single-part shapes produced from the multi-part shapes of the input shapefile. More...
 
Shapefile ExportSelection ()
 Creates a new instance of the shapefile class and copies selected shapes of the input shapefile to it. More...
 
bool FixUpShapes (out Shapefile retval)
 Creates a new shapefile by fixing invalid shapes of the input shapefile. More...
 
bool FixUpShapes2 (bool selectedOnly, out Shapefile result)
 Fixes invalid shapes in the shapefile. More...
 
int GenerateLabels (int fieldIndex, tkLabelPositioning method, bool largestPartOnly=false, int offsetXFieldIndex=-1, int offsetYFieldIndex=-1)
 Generates labels for the shapefile based on values of the specified attribute. More...
 
bool get_CanUseSpatialIndex (Extents pArea)
 Gets the value which indicates whether spatial index will be used for displaying certain extents of the shapefile. More...
 
object get_CellValue (int fieldIndex, int shapeIndex)
 Gets the value of the specified field for the shape. More...
 
string get_ErrorMsg (int errorCode)
 Gets the description of the specific error code. More...
 
Field get_Field (int fieldIndex)
 Gets a specific field stored in the attribute table. More...
 
Field get_FieldByName (string fieldname)
 Gets specific field stored in the attribute table. More...
 
int get_FieldIndexByName (string fieldName)
 Gets index of field with specified name. More...
 
int get_numPoints (int shapeIndex)
 Returns the number of points in the specified shape of the shapefile. More...
 
Shape get_Shape (int shapeIndex)
 Gets the reference to the specified shape. More...
 
int get_ShapeCategory (int shapeIndex)
 Gets the index of the visualization category which is used for the drawing of the specified shape. More...
 
string get_ShapeCategory2 (int shapeIndex)
 Get the name of the ShapefileCategory for the shape with specified index. More...
 
ShapefileCategory get_ShapeCategory3 (int shapeIndex)
 Gets the shapefile category for the shape with specified index. More...
 
bool get_ShapeIsHidden (int shapeIndex)
 Gets a value indicating whether a shape is hidden. More...
 
bool get_ShapeModified (int shapeIndex)
 Gets a value indicating whether particular shape was modified after shapefile was opened. More...
 
bool get_ShapeRendered (int shapeIndex)
 Gets a value indicating whether particular shape is currently displayed on the screen. More...
 
double get_ShapeRotation (int shapeIndex)
 Gets rotation angle for a shape. More...
 
bool get_ShapeSelected (int shapeIndex)
 Gets the state of selection for the specified shape. More...
 
bool get_ShapeVisible (int shapeIndex)
 Gets visibility of shape. More...
 
bool GetClosestSnapPosition (double x, double y, double maxDistance, int shapeIndex, ref double foundX, ref double foundY, ref double foundDistance)
 Calculates the closest snap point (taking the snap mode in account) on (the boundary of) a shape. More...
 
bool GetClosestVertex (double x, double y, double maxDistance, out int shapeIndex, out int pointIndex, out double distance)
 Gets the vertex closest to the specified point. More...
 
Shapefile GetIntersection (bool selectedOnlyOfThis, Shapefile sf, bool selectedOnly, ShpfileType fileType, ICallback cBack)
 Calculates intersection of 2 input shapefiles. More...
 
bool GetRelatedShapes (int referenceIndex, tkSpatialRelation relation, ref object resultArray)
 Gets shapes which are located at specified spatial relation to reference shape. More...
 
bool GetRelatedShapes2 (Shape referenceShape, tkSpatialRelation relation, ref object resultArray)
 Gets shapes which are located at specified spatial relation to reference shape. More...
 
bool HasInvalidShapes ()
 Checks whether there are invalid shapes within shapefile. More...
 
bool 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...
 
void InvertSelection ()
 Inverts selection of the shapefile, i.e. selection state of every shape is changed to the opposite value. More...
 
bool IsSpatialIndexValid ()
 Checks the validity of the spatial index. More...
 
bool LoadDataFrom (string shapefileName, ICallback cBack=null)
 Loads data into in-memory shapefile from the specified shapefile on the disk. More...
 
Shapefile Merge (bool selectedOnlyThis, Shapefile sf, bool selectedOnly)
 Creates a new instance of shapefile class which holds shapes from 2 input shapefiles. More...
 
bool Move (double xOffset, double yOffset)
 Moves shapefile at specified offset. More...
 
long 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 Open (string shapefileName, ICallback cBack)
 Opens shapefile from the disk. More...
 
bool PointInShape (int shapeIndex, double x, double y)
 Returns boolean value which indicates whether the given point is located within the specified shape. More...
 
int PointInShapefile (double x, double y)
 Returns a number which indicates the index of shapes within which a test point is situated. More...
 
Extents QuickExtents (int shapeIndex)
 Returns the extents of the shape with the given index. More...
 
Point QuickPoint (int shapeIndex, int pointIndex)
 Returns the specified point of shape. More...
 
System.Array QuickPoints (int shapeIndex, ref int numPoints)
 Returns an array with the coordinates of points of the specified shape. More...
 
bool RefreshExtents ()
 Refreshes extents of all shapes in the shapefile. More...
 
bool RefreshShapeExtents (int shapeId)
 Refreshes the extents of the particular shape in the shapefile. More...
 
bool RemoveSpatialIndex ()
 Removes spatial index associated with shapefile (.mwd and .mwx files). More...
 
Shapefile Reproject (GeoProjection newProjection, ref int reprojectedCount)
 Creates a new shapefile by re-projecting the current one. More...
 
bool ReprojectInPlace (GeoProjection newProjection, ref int reprojectedCount)
 Reprojects shapes of the current shapefile. More...
 
bool Resource (string newShpPath)
 Changes file associated with the current instance of the shapefile class. More...
 
bool Save (ICallback cBack)
 Saves edits of the in-memory shapefile to the disk without closing editing mode. More...
 
bool SaveAs (string shapefileName, ICallback cBack)
 Saves in-memory shapefile to the disk. More...
 
bool SaveAsEx (string newFilename, bool stopEditing, bool unboundFile)
 Saves shapefile to the disk. More...
 
Shapefile Segmentize (double metersTolerance=0.0)
 Splits polylines at intersection with any other polylines. Works for polyline shapefile only. More...
 
void SelectAll ()
 Selects all the shapes in the shapefile More...
 
bool SelectByShapefile (Shapefile sf, tkSpatialRelation relation, bool selectedOnly, ref object result, ICallback cBack)
 aka SpatialQuery. Returns an array with indices of shapes of the current shapefile which are in the specified relation to the definition shapefile. More...
 
void SelectNone ()
 Clears selection from all shapes. More...
 
bool SelectShapes (Extents boundBox, double tolerance, SelectMode selectMode, ref object result)
 Returns an array with indices of shapes which are located inside specified bounds. More...
 
string Serialize (bool saveSelection)
 Saves the state of the shapefile in XML string. More...
 
string Serialize2 (bool saveSelection, bool serializeCategories)
 Serializes the state shapefile object, but not the data itself. More...
 
void set_ShapeCategory (int shapeIndex, int pVal)
 Sets the index of the visualization category to use for the drawing of the specified shape. More...
 
void set_ShapeCategory2 (int shapeIndex, string categoryName)
 Sets the shapefile category for the shape. More...
 
void set_ShapeCategory3 (int shapeIndex, ShapefileCategory category)
 Sets the shapefile category for the shape. More...
 
void set_ShapeIsHidden (int shapeIndex, bool pVal)
 When set to true prevents shape from being displayed. More...
 
void set_ShapeModified (int shapeIndex, bool newVal)
 Sets a value indicating whether particular shape was modified after shapefile was opened. More...
 
void set_ShapeRotation (int shapeIndex, double pVal)
 Sets rotation angle for a shape. More...
 
void set_ShapeSelected (int shapeIndex, bool pVal)
 Selects or deselects the specified shape. The _DMapEvents.SelectionChanged event is not fired. More...
 
Shapefile SimplifyLines (double tolerance, bool selectedOnly)
 Creates a new shapefile by removing excessive vertices from the current shapefile More...
 
Shapefile Sort (int fieldIndex, bool @ascending)
 Sorts shapes in the shapefile based on the specified attribute. More...
 
bool StartAppendMode ()
 Starts append mode for the shapefile. More...
 
bool StartEditingShapes (bool startEditTable, ICallback cBack)
 Starts editing mode for the shapefile. More...
 
bool StartEditingTable (ICallback cBack)
 Opens editing mode for the attribute table. More...
 
void StopAppendMode ()
 Stops append mode for the shapefile. More...
 
bool StopEditingShapes (bool applyChanges, bool stopEditTable, ICallback cBack)
 Stops editing modes for the shapefile and optionally saves the changes. More...
 
bool StopEditingTable (bool applyChanges, ICallback cBack)
 Closes the editing mode for the attribute table. More...
 
Shapefile SymmDifference (bool selectedOnlySubject, Shapefile sfOverlay, bool selectedOnlyOverlay)
 Calculates symmetrical difference of the 2 shapefiles. More...
 
Shapefile Union (bool selectedOnlySubject, Shapefile sfOverlay, bool selectedOnlyOverlay)
 Calculates union of 2 shapefiles. More...
 
void UpdateSortField ()
 The sorting of the shapefile will be reapplied before next redraw after calling this method. More...
 

Properties

bool AppendMode [get]
 Gets a value indicating whether shapefile is in append mode. Any shapes added with Shapefile.EditAddShape will be immediately written to the disk. More...
 
bool CacheExtents [get, set]
 Gets or sets a boolean value which indicates whether extents of shape will be recalculated before each redraw. More...
 
ShapefileCategories Categories [get, set]
 Gets or sets an instance of ShapefileCategories class associated with the shapefile. More...
 
string CdlgFilter [get]
 Gets expression to be set for OpenFileDialog.Filter property to select ESRI shapefiles. More...
 
Charts Charts [get, set]
 Gets or sets an instance of Charts class associated with the shapefile. More...
 
tkCollisionMode CollisionMode [get, set]
 Gets or sets collision mode for point symbols for point and multi-point shapefiles. More...
 
ShapeDrawingOptions DefaultDrawingOptions [get, set]
 Gets or sets an instance of ShapeDrawingOptions class which holds default drawing options. More...
 
bool EditingShapes [get]
 Gets the value indicating whether editing operations are allowed for shapefile. More...
 
bool EditingTable [get]
 Gets the value indicating whether editing operations are allowed for shapefile attribute table. More...
 
Extents Extents [get]
 Gets bounding box which encompass all the shapes in the shapefile. More...
 
bool FastMode [get, set]
 Gets or sets the value which indicates whether fast mode will be used for the shapefile. More...
 
int FileHandle [get]
 Returns the handle of the shapefile. For inner use only. More...
 
string Filename [get]
 Gets the name of the file which is used as a source for this instance of Shapefile class. More...
 
tkGeometryEngine GeometryEngine [get, set]
 Gets or sets the engine (library) to use for geoprocessing operations. More...
 
GeoProjection GeoProjection [get, set]
 Get or sets an instance of GeoProjection class associated with the shapefile. More...
 
ICallback GlobalCallback [get, set]
 Gets or sets a Callback object which handles progress and error messages of the Shapefile class. More...
 
bool HasSpatialIndex [get, set]
 Gets the value indicating whether spatial index exists for the shapefile. More...
 
bool Identifiable [get, set]
 Gets or sets a value indicating whether this shapefile will be visible to cmIdentify tool. More...
 
bool InteractiveEditing [get, set]
 Gets or sets a value indicating whether a shapefile can be edited with built-in interactive tools. More...
 
string Key [get, set]
 A text string associated with the shapefile. Any value can be stored by developer in this property. More...
 
Labels Labels [get, set]
 Gets or sets the instance of the Labels class associated with the shapefile. More...
 
int LastErrorCode [get]
 Gets the code of last error which took place inside this object. More...
 
ShapeValidationInfo LastInputValidation [get]
 Gets results of input data validation for geoprocessing methods. More...
 
ShapeValidationInfo LastOutputValidation [get]
 Gets results of output data validation for geoprocessing methods. More...
 
int MinDrawingSize [get, set]
 Gets or sets the value which affects the drawing of small shapes on the screen. More...
 
int NumFields [get]
 Gets the number of fields in attribute table of the shapefile. More...
 
int NumSelected [get]
 Gets the number of selected shapes in the shapefile. More...
 
int NumShapes [get]
 Gets the number of shapes in the shapefile. More...
 
string Projection [get, set]
 Gets or sets the projection string for shapefile. String in proj4 and ESRI WKT formats are supported. More...
 
bool Selectable [get, set]
 Gets or sets a value indicating whether this shapefile will be selectable by the cmSelection and cmSelectByPolygon tool. More...
 
tkSelectionAppearance SelectionAppearance [get, set]
 Gets or sets the way shapefile selection will be displayed. More...
 
uint SelectionColor [get, set]
 The colour of the selected shapes. More...
 
ShapeDrawingOptions SelectionDrawingOptions [get, set]
 The drawing options used for visualization of the selected shapes. More...
 
byte SelectionTransparency [get, set]
 Gets or sets the value which defines the transparency of the selection. Values from 0 (transparent) to 255(opaque) are applicable. More...
 
ShpfileType ShapefileType [get]
 Gets the type of the shapefile. More...
 
ShpfileType ShapefileType2D [get]
 Gets "flattened" shapefile type, i.e. Z and M components will be ignored. More...
 
bool Snappable [get, set]
 Gets or sets a value indicating whether interactive editing tools can snap to vertices of the shapefile. More...
 
bool SortAscending [get, set]
 Gets or sets a value indicating whether shapes will be sorted in ascending order. More...
 
string SortField [get, set]
 The name of the field to be used to determine the drawing order of point shapes and labels. More...
 
tkShapefileSourceType SourceType [get]
 Gets the value which indicate the type the data used by shapefile object. More...
 
double SpatialIndexMaxAreaPercent [get, set]
 Gets or sets the value which affects the usage of spatial index. More...
 
IStopExecution StopExecution [set]
 Sets an object which implements IStopExecution interface and facilitates stopping of the geoprocessing operations. More...
 
Table Table [get]
 Gets the reference to the attribute table associated with the shapefile. More...
 
bool UseQTree [get, set]
 Gets or sets a value which indicates whether built-in quad-tree spatial index should be used for shapefile. More...
 
bool UseSpatialIndex [get, set]
 Gets or sets a value which indicates whether spatial index should be used while working with shapefile. More...
 
string VisibilityExpression [get, set]
 Gets or sets the expression which defines shapes to be visible on the map. More...
 
bool Volatile [get, set]
 Gets or sets a value indicating whether shapefile can be redrawn without redrawing other layer on the map. More...
 

Detailed Description

Provides a functionality for accessing and editing ESRI shapefiles.

A class which encapsulates all the operation with ESRI shapefiles, for both file-based and in-memory mode. Facilitates creation, editing, querying and geoprocessing of shapefiles. Shapefile holds geometry of objects (.shp and .shx part) and their attribute values (.dbf part)

Here is a diagram for the Shapefile class.

dot_inline_dotgraph_60.png

Graph description

Here are groups of API members for Shapefile class:

dot_shapefilegroups.png
Graph description

Examples
AddCategoryRange.cs, AddLayers.cs, CalculateArea.cs, CreateBuffer.cs, CreatePointShapefile.cs, CreatePolygonShapefile.cs, EditAttributes.cs, GenerateLabelsManually.cs, IntersectionLength.cs, LabelSelection.cs, LinePattern.cs, MarkPoints.cs, MinimalDistance.cs, PointIcons.cs, PolygonsWithHoles.cs, RemoveShape.cs, Segmentation.cs, SelectBox.cs, SelectByDistance.cs, SelectByQuery.cs, ShapefileToDrawingLayer.cs, ShowAttributes.cs, SortLayers.cs, SplitByAttribute.cs, ToolTip.cs, TrackCars.cs, Tracking.cs, and ZoomToValues.cs.

Member Function Documentation

◆ Deserialize()

void Shapefile.Deserialize ( bool  loadSelection,
string  newVal 
)

Restores the state of shapefile from the string.

Parameters
loadSelectionThe value which indicates whether selection state of individual shapes should be restored.
newValA string with state information generated by Shapefile.Serialize method.
New API 4.8:
Added in version 4.8

◆ FixUpShapes2()

bool Shapefile.FixUpShapes2 ( bool  selectedOnly,
out Shapefile  result 
)

Fixes invalid shapes in the shapefile.

Parameters
selectedOnlyOnly selected shapes will be fixed.
resultThe resulting shapefile.
Returns
True if the operations was successful.
New API 4.9.4:
Added in version 4.9.4

◆ GenerateLabels()

int Shapefile.GenerateLabels ( int  fieldIndex,
tkLabelPositioning  method,
bool  largestPartOnly = false,
int  offsetXFieldIndex = -1,
int  offsetYFieldIndex = -1 
)

Generates labels for the shapefile based on values of the specified attribute.

Parameters
fieldIndexThe index of field in the attribute table to take the values from.
methodThe method for calculation of label positions.
largestPartOnlyA value which indicates whether all the parts of a multi-part shape should be supplied with individual labels or only the largest (longest) one.
offsetXFieldIndexThe field index used to populate the labels' x offsets
offsetYFieldIndexThe field index used to populate the labels' y offsets
Returns
The number of labels generated. Normally it is equal to the number of shapes. Labels of the multi-part shape are treated like a single label.
New API 4.8:
Added in version 4.8

◆ get_ErrorMsg()

string Shapefile.get_ErrorMsg ( int  errorCode)

Gets the description of the specific error code.

Parameters
errorCodeThe error code returned by Shapefile.LastErrorCode.
Returns
The string with the description.

◆ get_Shape()

Shape Shapefile.get_Shape ( int  shapeIndex)

Gets the reference to the specified shape.

In the disk-based mode (Shapefile.SourceType = sstDiskBased) a new instance of the Shape class will be created on each call of this property which is time consuming. Try to avoid calling this property in large cycles or open editing mode prior such cycles. In editing mode shape objects stored in memory, so there is no overhead in passing the reference.

Parameters
shapeIndexThe index of shape to retrieve.
Returns
The reference to the shape or NULL reference on invalid index.

◆ get_ShapeCategory()

int Shapefile.get_ShapeCategory ( int  shapeIndex)

Gets the index of the visualization category which is used for the drawing of the specified shape.

Parameters
shapeIndexThe index of the shape.
Returns
The index of the category. -1 will be returned in case no category is set to the shape or invalid shape index was passed.
See also
Shapefile.Categories
New API 4.8:
Added in version 4.8

◆ get_ShapeCategory2()

string Shapefile.get_ShapeCategory2 ( int  shapeIndex)

Get the name of the ShapefileCategory for the shape with specified index.

Parameters
shapeIndexIndex of shape.
Returns
The name of the category.
New API 4.9.1:
Added in version 4.9.1

◆ get_ShapeCategory3()

ShapefileCategory Shapefile.get_ShapeCategory3 ( int  shapeIndex)

Gets the shapefile category for the shape with specified index.

Parameters
shapeIndexIndex of shape.
Returns
Shapefile category, or null if no category for the shape was set.
New API 4.9.1:
Added in version 4.9.1

◆ get_ShapeIsHidden()

bool Shapefile.get_ShapeIsHidden ( int  shapeIndex)

Gets a value indicating whether a shape is hidden.

Even when this property is set to false, the shape may still be invisible because of other settings. Use Shapefile.get_ShapeVisible to check if it will actually be displayed on the screen when corresponding portion of map is rendered.

Parameters
shapeIndexIndex of shape.
Returns
True in case shape is hidden.
New API 4.9.3:
Added in version 4.9.3

◆ get_ShapeRendered()

bool Shapefile.get_ShapeRendered ( int  shapeIndex)

Gets a value indicating whether particular shape is currently displayed on the screen.

Parameters
shapeIndex
Returns

This property is set during the core rendering process, therefore it accounts for all possible ways for a certain shape to be hidden, like collision avoidance for point symbols or dynamic visibility for categories.

New API 4.9.3:
Added in version 4.9.3

◆ get_ShapeRotation()

double Shapefile.get_ShapeRotation ( int  shapeIndex)

Gets rotation angle for a shape.

Parameters
shapeIndexIndex of shape.
Returns
Angle in degrees (0-360).

This value will be applied to point shapefiles only. Values other then 0.0 will override ShapeDrawingOptions.PointRotation property for shapefile and categories.

New API 4.9.2:
Added in version 4.9.2

◆ get_ShapeVisible()

bool Shapefile.get_ShapeVisible ( int  shapeIndex)

Gets visibility of shape.

Parameters
shapeIndexIndex of shape.
Returns
True if shape is visible.

The property takes into account Shapefile.VisibilityExpression, Shapefile.get_ShapeIsHidden, ShapeDrawingOptions.Visible

New API 4.9.2:
Added in version 4.9.2

◆ Move()

bool Shapefile.Move ( double  xOffset,
double  yOffset 
)

Moves shapefile at specified offset.

Shapefile must be in editing mode in order for this method to succeed.

Parameters
xOffsetX component of offset.
yOffsetY component of offset.
Returns
True on success.
New API 4.9.3:
Added in version 4.9.3

◆ Serialize()

string Shapefile.Serialize ( bool  saveSelection)

Saves the state of the shapefile in XML string.

Serialization covers shapefile properties and all child classes (drawing options, labels, charts, categories). Geometry of shapes and values of attribute table will not be serialized.

Parameters
saveSelectionThe value which indicates whether selection state of individual shapes should be saved.
Returns
A string with serialized state or empty string on failure. Use Shapefile.ErrorMsg(Shapefile.LastErrorCode) to find out the reason of failure.
New API 4.8:
Added in version 4.8

◆ Serialize2()

string Shapefile.Serialize2 ( bool  saveSelection,
bool  serializeCategories 
)

Serializes the state shapefile object, but not the data itself.

Parameters
saveSelectionTrue is selection on per-shape basis should be serialized.
serializeCategoriesTrue if categories should be serialize on per-shape basis. The option should be used when categories were applied manually with Shapefile.put_ShapeCategory.
Returns
XML string with serialized state.
See also
Shapefile.Serialize
New API 4.9.3:
Added in version 4.9.3

◆ set_ShapeCategory()

void Shapefile.set_ShapeCategory ( int  shapeIndex,
int  pVal 
)

Sets the index of the visualization category to use for the drawing of the specified shape.

Parameters
shapeIndexThe index of the shape.
pValThe index of the visualization category.
See also
Shapefile.Categories
New API 4.8:
Added in version 4.8

◆ set_ShapeCategory2()

void Shapefile.set_ShapeCategory2 ( int  shapeIndex,
string  categoryName 
)

Sets the shapefile category for the shape.

Parameters
shapeIndexIndex of shape.
categoryNameName of the category. Category must be created first. Name comparison is case-sensitive.
New API 4.9.1:
Added in version 4.9.1

◆ set_ShapeCategory3()

void Shapefile.set_ShapeCategory3 ( int  shapeIndex,
ShapefileCategory  category 
)

Sets the shapefile category for the shape.

Parameters
shapeIndexIndex of shape.
categoryShapefile category to set. The category must be added to shapefile beforehand.
New API 4.9.1:
Added in version 4.9.1

◆ set_ShapeIsHidden()

void Shapefile.set_ShapeIsHidden ( int  shapeIndex,
bool  pVal 
)

When set to true prevents shape from being displayed.

This property is used internally by interactive editing tools.

Parameters
shapeIndexIndex of shape.
pValValue indicating whether the shape is hidden.
New API 4.9.3:
Added in version 4.9.3

◆ set_ShapeRotation()

void Shapefile.set_ShapeRotation ( int  shapeIndex,
double  pVal 
)

Sets rotation angle for a shape.

Parameters
shapeIndexIndex of shape.
pValAngle in degrees (0-360).

This value will be applied to point shapefiles only. Values other then 0.0 will override ShapeDrawingOptions.PointRotation property for shapefile and categories.

New API 4.9.2:
Added in version 4.9.2

◆ StartAppendMode()

bool Shapefile.StartAppendMode ( )

Starts append mode for the shapefile.

Returns
True on success
New API 4.9.4:
Added in version 4.9.4

◆ StopAppendMode()

void Shapefile.StopAppendMode ( )

Stops append mode for the shapefile.

New API 4.9.4:
Added in version 4.9.4

◆ UpdateSortField()

void Shapefile.UpdateSortField ( )

The sorting of the shapefile will be reapplied before next redraw after calling this method.

New API 4.9.4:
Added in version 4.9.4

Property Documentation

◆ AppendMode

bool Shapefile.AppendMode
get

Gets a value indicating whether shapefile is in append mode. Any shapes added with Shapefile.EditAddShape will be immediately written to the disk.

New API 4.9.4:
Added in version 4.9.4

◆ Categories

ShapefileCategories Shapefile.Categories
getset

Gets or sets an instance of ShapefileCategories class associated with the shapefile.

The property can't be set to NULL (there is always an instance ShapefileCategories class associated with the Shapefile).

New API 4.8:
Added in version 4.8
Examples
AddCategoryRange.cs, CreateBuffer.cs, MinimalDistance.cs, PointIcons.cs, and SplitByAttribute.cs.

◆ CdlgFilter

string Shapefile.CdlgFilter
get

Gets expression to be set for OpenFileDialog.Filter property to select ESRI shapefiles.

◆ Charts

Charts Shapefile.Charts
getset

Gets or sets an instance of Charts class associated with the shapefile.

The property can't be set to NULL (there is always an instance of Charts class associated with shapefile).

New API 4.8:
Added in version 4.8
Examples
IntersectionLength.cs, and Segmentation.cs.

◆ CollisionMode

tkCollisionMode Shapefile.CollisionMode
getset

Gets or sets collision mode for point symbols for point and multi-point shapefiles.

See tkCollisionMode enumeration.

New API 4.8:
Added in version 4.8
Examples
TrackCars.cs.

◆ DefaultDrawingOptions

ShapeDrawingOptions Shapefile.DefaultDrawingOptions
getset

Gets or sets an instance of ShapeDrawingOptions class which holds default drawing options.

Default options are applied to every shape, which doesn't belong to a shapefile category. The property can't be set to NULL (there is always an instance ShapeDrawingOptions class associated with shapefile).

New API 4.8:
Added in version 4.8
Examples
AddCategoryRange.cs, CreateBuffer.cs, IntersectionLength.cs, MinimalDistance.cs, PointIcons.cs, Segmentation.cs, ShapefileToDrawingLayer.cs, SplitByAttribute.cs, and Tracking.cs.

◆ Extents

Extents Shapefile.Extents
get

Gets bounding box which encompass all the shapes in the shapefile.

When fast mode is set on, Shapefile.RefreshExtents call is needed to get the correct extents after edits where made.

Examples
EditAttributes.cs, and ShapefileToDrawingLayer.cs.

◆ FileHandle

int Shapefile.FileHandle
get

Returns the handle of the shapefile. For inner use only.

◆ Filename

string Shapefile.Filename
get

Gets the name of the file which is used as a source for this instance of Shapefile class.

The property should be used for disk-based shapefiles only (see Shapefile.SourceType property).

◆ GeoProjection

GeoProjection Shapefile.GeoProjection
getset

Get or sets an instance of GeoProjection class associated with the shapefile.

The property can't be set to NULL (there is always an instance of GeoProjection class associated with the shapefile).

New API 4.8:
Added in version 4.8
Examples
Segmentation.cs, and ShapefileToDrawingLayer.cs.

◆ GlobalCallback

ICallback Shapefile.GlobalCallback
getset

Gets or sets a Callback object which handles progress and error messages of the Shapefile class.

It's recommended to set it in case time consuming operation will be used (geoprocessing, generation of labels, etc). The property is equal to NULL by default.

Deprecated:
v4.9.3 Use GlobalSettings.ApplicationCallback instead.
Examples
CreateBuffer.cs.

◆ Identifiable

bool Shapefile.Identifiable
getset

Gets or sets a value indicating whether this shapefile will be visible to cmIdentify tool.

See also
AxMap.CursorMode
New API 4.9.3:
Added in version 4.9.3

◆ Key

string Shapefile.Key
getset

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

◆ Labels

Labels Shapefile.Labels
getset

Gets or sets the instance of the Labels class associated with the shapefile.

The property can't be set to NULL (there is always an instance Labels class associated with shapefile).

New API 4.8:
Added in version 4.8
Examples
EditAttributes.cs, LabelSelection.cs, MinimalDistance.cs, RemoveShape.cs, SelectBox.cs, SelectByQuery.cs, ToolTip.cs, TrackCars.cs, Tracking.cs, and ZoomToValues.cs.

◆ LastErrorCode

int Shapefile.LastErrorCode
get

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

To retrieve text description of error, use Shapefile.get_ErrorMsg(Shapefile.LastErrorCode). Check this value if a certain method has failed.

Examples
AddLayers.cs, CalculateArea.cs, MarkPoints.cs, PointIcons.cs, RemoveShape.cs, SelectBox.cs, and ToolTip.cs.

◆ NumShapes

◆ Projection

string Shapefile.Projection
getset

Gets or sets the projection string for shapefile. String in proj4 and ESRI WKT formats are supported.

Deprecated:
v 4.8 Use Shapefile.GeoProjection property instead.

◆ ShapefileType

ShpfileType Shapefile.ShapefileType
get

Gets the type of the shapefile.

It is not possible to change the type of the shapefile without closing it.

Examples
ShapefileToDrawingLayer.cs, and SortLayers.cs.

◆ ShapefileType2D

ShpfileType Shapefile.ShapefileType2D
get

Gets "flattened" shapefile type, i.e. Z and M components will be ignored.

New API 4.9.3:
Added in version 4.9.3

◆ SortAscending

bool Shapefile.SortAscending
getset

Gets or sets a value indicating whether shapes will be sorted in ascending order.

See also
SortField
New API 4.9.4:
Added in version 4.9.4

◆ SortField

string Shapefile.SortField
getset

The name of the field to be used to determine the drawing order of point shapes and labels.

New API 4.9.4:
Added in version 4.9.4

◆ SourceType

tkShapefileSourceType Shapefile.SourceType
get

Gets the value which indicate the type the data used by shapefile object.

See details in the description of tkShapefileSourceType enumeration.

New API 4.8:
Added in version 4.8

◆ StopExecution

IStopExecution Shapefile.StopExecution
set

Sets an object which implements IStopExecution interface and facilitates stopping of the geoprocessing operations.

New API 4.8:
Added in version 4.8

◆ VisibilityExpression

string Shapefile.VisibilityExpression
getset

Gets or sets the expression which defines shapes to be visible on the map.

In case of empty or invalid string all the shapes will be visible.

New API 4.8:
Added in version 4.8
Examples
MinimalDistance.cs.