Provides a functionality for accessing and editing ESRI shapefiles. More...
Public Member Functions | |
| Shapefile | AggregateShapes (bool SelectedOnly, int FieldIndex) |
| Creates a new shapefile by merging shapes with the same value of the specified attribute. | |
| bool | BeginPointInShapefile () |
| Caches the coordinates of shapefile points for faster point in shape test. | |
| 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. | |
| Shapefile | Clip (bool SelectedOnlySubject, Shapefile sfOverlay, bool SelectedOnlyOverlay) |
| Clips current shapefile by the definition shapefile. | |
| Shapefile | Clone () |
| Creates a copy of the shapefile. | |
| bool | Close () |
| Closes shapefile and releases all the resources. | |
| bool | CreateNew (string ShapefileName, ShpfileType ShapefileType) |
| Initializes in-memory shapefile of the specified type. | |
| bool | CreateNewWithShapeID (string ShapefileName, ShpfileType ShapefileType) |
| Initializes in-memory shapefile of the specified type with unique index field. | |
| bool | CreateSpatialIndex (string ShapefileName) |
| Creates a new spatial index. | |
| void | Deserialize (bool LoadSelection, string newVal) |
| Restores the state of shapefile from the string. | |
| Shapefile | Difference (bool SelectedOnlySubject, Shapefile sfOverlay, bool SelectedOnlyOverlay) |
| Calculates difference of 2 shapefiles. | |
| Shapefile | Dissolve (int FieldIndex, bool SelectedOnly) |
| Merges shapes of the input shapefile based on specified attribute. | |
| 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. | |
| int | EditAddShape (Shape Shape) |
| Adds a new shape to the shapefile. | |
| 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. | |
| bool | EditClear () |
| Deletes all the shapes from the shapefile. | |
| bool | EditDeleteField (int FieldIndex, ICallback cBack) |
| Deletes a field with the specified index from the attribute table. The table must be in editing mode. | |
| bool | EditDeleteShape (int ShapeIndex) |
| Deletes a shape from the shapefile. | |
| 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. | |
| bool | EditInsertShape (Shape Shape, ref int ShapeIndex) |
| Inserts a new shape in the shapefile. | |
| void | EndPointInShapefile () |
| Clears the cached data allocated by Shapefile.BeginPointInShapefile. | |
| 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. | |
| Shapefile | ExportSelection () |
| Creates a new instance of the shapefile class and copies selected shapes of the input shapefile to it. | |
| bool | FixUpShapes (out Shapefile retval) |
| Creates a new shapefile by fixing invalid shapes of the input shapefile. | |
| int | GenerateLabels (int FieldIndex, tkLabelPositioning Method, bool LargestPartOnly) |
| Generates labels for the shapefile based on values of the specified attribute. | |
| bool | get_CanUseSpatialIndex (Extents pArea) |
| Gets the value which indicates whether spatial index will be used for displaying certain extents of the shapefile. | |
| object | get_CellValue (int FieldIndex, int ShapeIndex) |
| Gets the value of the specified field for the shape. | |
| string | get_ErrorMsg (int ErrorCode) |
| Gets the description of the specific error code. | |
| Field | get_Field (int FieldIndex) |
| Gets a specific field stored in the attribute table. | |
| Field | get_FieldByName (string Fieldname) |
| Gets specific field stored in the attribute table. | |
| int | get_numPoints (int ShapeIndex) |
| Returns the number of points in the specified shape of the shapefile. | |
| Shape | get_Shape (int ShapeIndex) |
| Gets the reference to the specified shape. | |
| int | get_ShapeCategory (int ShapeIndex) |
| Gets the index of the visualization category which is used for the drawing of the specified shape. | |
| bool | get_ShapeSelected (int ShapeIndex) |
| Gets the state of selection for the specified shape. | |
| Shapefile | GetIntersection (bool SelectedOnlyOfThis, Shapefile sf, bool SelectedOnly, ShpfileType fileType, ICallback cBack) |
| Calculates intersection of 2 input shapefiles. | |
| void | InvertSelection () |
| Inverts selection of the shapefile, i.e. selection state of every shape is changed to the opposite value. | |
| bool | IsSpatialIndexValid () |
| Checks the validity of the spatial index. | |
| Shapefile | Merge (bool SelectedOnlyThis, Shapefile sf, bool SelectedOnly) |
| Creates a new instance of shapefile class which holds shapes from 2 input shapefiles. | |
| bool | Open (string ShapefileName, ICallback cBack) |
| Opens shapefile from the disk. | |
| bool | PointInShape (int ShapeIndex, double x, double y) |
| Returns boolean value which indicates whether the given point is located whithin the specified shape. | |
| int | PointInShapefile (double x, double y) |
| Returns a number which indicates the index of shapes within which a test point is situated. | |
| Extents | QuickExtents (int ShapeIndex) |
| Returns the extents of the shape with the given index. | |
| Point | QuickPoint (int ShapeIndex, int PointIndex) |
| Returns the specified point of shape. | |
| System.Array | QuickPoints (int ShapeIndex, ref int numPoints) |
| Returns an array with the coordiantes of points of the specified shape. | |
| bool | RefreshExtents () |
| Refreshes extents of all shapes in the shapefile. | |
| bool | RefreshShapeExtents (int ShapeId) |
| Refreshes the extents of the particular shape in the shapefile. | |
| Shapefile | Reproject (GeoProjection newProjection, ref int reprojectedCount) |
| Creates a new shapefile by reprojecting the current one. | |
| bool | ReprojectInPlace (GeoProjection newProjection, ref int reprojectedCount) |
| Reprojects shapes of the current shapefile. | |
| bool | Resource (string newShpPath) |
| Changes file associated with the current instance of the shapefile class. | |
| bool | Save (ICallback cBack) |
| Saves edits of the in-memory shapefile to the disk without closing editing mode. | |
| bool | SaveAs (string ShapefileName, ICallback cBack) |
| Saves in-memory shapefile to the disk. | |
| void | SelectAll () |
| Selects all the shapes in the shapefile. | |
| 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. | |
| void | SelectNone () |
| Clears selection from all shapes. | |
| bool | SelectShapes (Extents BoundBox, double Tolerance, SelectMode SelectMode, ref object Result) |
| Returns an array with indices of shapes which are located inside specified bounds. | |
| string | Serialize (bool SaveSelection) |
| Saves the state of the shapefile in XML string. | |
| void | set_ShapeCategory (int ShapeIndex, int pVal) |
| Sets the index of the visualization category to use for the drawing of the specified shape. | |
| void | set_ShapeSelected (int ShapeIndex, bool pVal) |
| Selects or deselects the specified shape. | |
| Shapefile | SimplifyLines (double Tolerance, bool SelectedOnly) |
| Creates a new shapefile by removing excessive vertices from the current shapefile. | |
| Shapefile | Sort (int FieldIndex, bool Ascending) |
| Sorts shapes in the shapefile based on the specified attribute. | |
| bool | StartEditingShapes (bool StartEditTable, ICallback cBack) |
| Starts editing mode for the shapefile. | |
| bool | StartEditingTable (ICallback cBack) |
| Opens editing mode for the attribute table. | |
| bool | StopEditingShapes (bool ApplyChanges, bool StopEditTable, ICallback cBack) |
| Stops editing modes for the shapefile and optionally saves the changes. | |
| bool | StopEditingTable (bool ApplyChanges, ICallback cBack) |
| Closes the editing mode for the attribute table. | |
| Shapefile | SymmDifference (bool SelectedOnlySubject, Shapefile sfOverlay, bool SelectedOnlyOverlay) |
| Calculates symmetrical difference of the 2 shapefiles. | |
| Shapefile | Union (bool SelectedOnlySubject, Shapefile sfOverlay, bool SelectedOnlyOverlay) |
| Calculates union of 2 shapefiles. | |
Properties | |
| bool | CacheExtents [get, set] |
| Gets or sets a boolean value which indicates whether extents of shape will be recalculated before each redraw. | |
| ShapefileCategories | Categories [get, set] |
| Gets or sets an instance of ShapefileCategories class associated with the shapefile. | |
| string | CdlgFilter [get] |
| Gets expression to be set for OpenFileDialog.Filter property to select ESRI shapefiles. | |
| Charts | Charts [get, set] |
| Gets or sets an instance of Charts class associated with the shapefile. | |
| tkCollisionMode | CollisionMode [get, set] |
| Sets collision mode for labels of the shapefile. | |
| ShapeDrawingOptions | DefaultDrawingOptions [get, set] |
| Gets or sets an instance of ShapeDrawingOptions class which holds default drawing options. | |
| bool | EditingShapes [get] |
| Gets the value indicating whether editing operations are allowed for shapefile. | |
| bool | EditingTable [get] |
| Gets the value indicating whether editing operations are allowed for shapefile attribute table. | |
| Extents | Extents [get] |
| Gets bounding box which encompass all the shapes in the shapefile. | |
| bool | FastMode [get, set] |
| Gets or sets the value which indicates whether fast mode will be used for the shapefile. | |
| int | FileHandle [get] |
| Returns the handle of the shapefile. For inner use only. | |
| string | Filename [get] |
| Gets the name of the file which is used as a source for this instance of Shapefile class. | |
| tkGeometryEngine | GeometryEngine [get, set] |
| Gets or sets the engine (library) to use for geoprocessing operations. | |
| GeoProjection | GeoProjection [get, set] |
| Get or sets an instance of GeoProjection class associated with the shapefile. | |
| ICallback | GlobalCallback [get, set] |
| Gets or sets a Callback object which handles progress and error messages of the Shapefile class. | |
| bool | HasSpatialIndex [get, set] |
| Gets the value indicating whether spatial index exists for the shapefile. | |
| string | Key [get, set] |
| A text string associated with the shapefile. Any value can be stored by developer in this property. | |
| Labels | Labels [get, set] |
| Gets or sets the instance of the Labels class associated with the shapefile. | |
| int | LastErrorCode [get] |
| Gets the code of last error which took place inside this instance of Shapefile class. | |
| int | MinDrawingSize [get, set] |
| Gets or sets the value which affects the drawing of small shapes on the screen. | |
| int | NumFields [get] |
| Gets the number of fields in attribute table of the shapefile. | |
| int | NumSelected [get] |
| Gets the number of selected shapes in the shapefile. | |
| int | NumShapes [get] |
| Gets the number of shapes in the shapefile. | |
| string | Projection [get, set] |
| Gets or sets the projection string for shapefile. String in proj4 and ESRI WKT formats are supported. | |
| tkSelectionAppearance | SelectionAppearance [get, set] |
| Gets or sets the way shapefile selection will be displayed. | |
| uint | SelectionColor [get, set] |
| The color of the selected shapes. | |
| ShapeDrawingOptions | SelectionDrawingOptions [get, set] |
| The drawing options used for visualization of the selected shapes. | |
| 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. | |
| ShpfileType | ShapefileType [get] |
| Gets the type of the shapefile. | |
| tkShapefileSourceType | SourceType [get] |
| Gets the value which indicate the type the data used by shapefile object. | |
| double | SpatialIndexMaxAreaPercent [get, set] |
| Gets or sets the value which affects the usage of spatial index. | |
| IStopExecution | StopExecution [set] |
| Sets an object which implements IStopExecution interface and facilitates stopping of the geoprocessing operations. | |
| Table | Table [get] |
| Gets the refererence to the attribute table associated with the shapefile. | |
| bool | UseQTree [get, set] |
| Gets or sets a value which indicates whether built-in quad-tree spatial index should be used for shapefile. | |
| bool | UseSpatialIndex [get, set] |
| Gets or sets a value which indicates whether spatial index should be used while working with shapefile. | |
| string | VisibilityExpression [get, set] |
| Gets or sets the expression which defines shapes to be visible on the map. | |
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, quering 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.
Graph description
Here are groups of API members for Shapefile class:
| void Shapefile.Deserialize | ( | bool | LoadSelection, |
| string | newVal | ||
| ) |
Restores the state of shapefile from the string.
| LoadSelection | The value which indicates whether selection state of individual shapes should be restored. |
| newVal | A string with state information generated by Shapefile.Serialize method. |
| int Shapefile.GenerateLabels | ( | int | FieldIndex, |
| tkLabelPositioning | Method, | ||
| bool | LargestPartOnly | ||
| ) |
Generates labels for the shapefile based on values of the specified attribute.
| FieldIndex | The index of field in the attribute table to take the values from. |
| Method | The method for calculation of label positions. |
| LargestPartOnly | A value which indicates whether all the parts of a multi-part shape should be supplied with individual labels or only the largest (longest) one. |
| string Shapefile.get_ErrorMsg | ( | int | ErrorCode | ) |
Gets the description of the specific error code.
| ErrorCode | The error code returned by Shapefile.LastErrorCode. |
| 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.
| ShapeIndex | The index of shape to retrieve. |
| int Shapefile.get_ShapeCategory | ( | int | ShapeIndex | ) |
Gets the index of the visualization category which is used for the drawing of the specified shape.
| ShapeIndex | The index of the shape. |
| 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.
| SaveSelection | The value which indicates whether selection state of individual shapes should be saved. |
| void Shapefile.set_ShapeCategory | ( | int | ShapeIndex, |
| int | pVal | ||
| ) |
Sets the index of the visualization category to use for the drawing of the specified shape.
| ShapeIndex | The index of the shape. |
| pVal | The index of the visualization category. |
ShapefileCategories Shapefile.Categories [get, set] |
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).
string Shapefile.CdlgFilter [get] |
Gets expression to be set for OpenFileDialog.Filter property to select ESRI shapefiles.
Charts Shapefile.Charts [get, set] |
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).
tkCollisionMode Shapefile.CollisionMode [get, set] |
Sets collision mode for labels of the shapefile.
See tkCollisionMode enumeration.
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).
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.
int Shapefile.FileHandle [get] |
Returns the handle of the shapefile. For inner use only.
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 Shapefile.GeoProjection [get, set] |
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).
ICallback Shapefile.GlobalCallback [get, set] |
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.
string Shapefile.Key [get, set] |
A text string associated with the shapefile. Any value can be stored by developer in this property.
Labels Shapefile.Labels [get, set] |
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).
int Shapefile.LastErrorCode [get] |
Gets the code of last error which took place inside this instance of Shapefile class.
To retrieve text description of error, use Shapefile.get_ErrorMsg(Shapefile.LastErrorCode). Check this value if a certain method has failed.
int Shapefile.NumShapes [get] |
Gets the number of shapes in the shapefile.
string Shapefile.Projection [get, set] |
Gets or sets the projection string for shapefile. String in proj4 and ESRI WKT formats are supported.
Gets the type of the shapefile.
It is not possible to change the type of the shapefile without closing it.
Gets the value which indicate the type the data used by shapefile object.
See details in the description of tkShapefileSourceType enumeration.
IStopExecution Shapefile.StopExecution [set] |
Sets an object which implements IStopExecution interface and facilitates stopping of the geoprocessing operations.
string Shapefile.VisibilityExpression [get, set] |
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.
1.7.6.1