Functions
Shapefile open and close
Shapefile modules

Functions

Shapefile Shapefile.Clone ()
 Creates a copy of the shapefile.
bool Shapefile.Close ()
 Closes shapefile and releases all the resources.
bool Shapefile.CreateNew (string ShapefileName, ShpfileType ShapefileType)
 Initializes in-memory shapefile of the specified type.
bool Shapefile.CreateNewWithShapeID (string ShapefileName, ShpfileType ShapefileType)
 Initializes in-memory shapefile of the specified type with unique index field.
bool Shapefile.Open (string ShapefileName, ICallback cBack)
 Opens shapefile from the disk.
bool Shapefile.Resource (string newShpPath)
 Changes file associated with the current instance of the shapefile class.
bool Shapefile.Save (ICallback cBack)
 Saves edits of the in-memory shapefile to the disk without closing editing mode.
bool Shapefile.SaveAs (string ShapefileName, ICallback cBack)
 Saves in-memory shapefile to the disk.

Detailed Description

Here is a list of methods which affect the state of the shapefile. This module is a part of the documentation of Shapefile class.

dot_inline_dotgraph_27.png

Graph description


Function Documentation

Creates a copy of the shapefile.

Output shapefile will have the same type, projection and fields of the attribute table, while shapes and the records of the attribute table aren't copied. For complete copy of the shapefile use Shapefile.SelectAll() and Shapefile.ExportSelection().

New API 4.8:
Added in version 4.8
Examples:
CreateBuffer.cs, IntersectionLength.cs, and SplitByAttribute.cs.
bool Shapefile.Close ( )

Closes shapefile and releases all the resources.

In case shapefile is in editing mode (Shapefile.EditingShapes = true) all the edits will be discarded.

Returns:
This value should not be analyzed.
Examples:
CalculateArea.cs.
bool Shapefile.CreateNew ( string  ShapefileName,
ShpfileType  ShapefileType 
)

Initializes in-memory shapefile of the specified type.

Shapefile.EditingShapes property for the new shapefile will be set to true. Any shapefile opened in this instance of class before this call, will be closed without saving the changes.

Parameters:
ShapefileNameThe name of the new shapefile. An empty string should be passed here.
ShapefileTypeType of the shapefile to create.
Returns:
Returns true on success and false otherwise.

Use Shapefile.ErrorMsg(Shapefile.LastErrorCode) to find out the reason of failure.

Examples:
LinePattern.cs.
bool Shapefile.CreateNewWithShapeID ( string  ShapefileName,
ShpfileType  ShapefileType 
)

Initializes in-memory shapefile of the specified type with unique index field.

MWShapeID field will be added to the attribute table. An increasing unique positive integer value will be set in this field for each shape added to the shapefile. The field with MWShapeID name created manually will be treated in the same way.

Parameters:
ShapefileNameThe name of the new shapefile. An empty string should be passed here.
ShapefileTypeType of the shapefile to create.
Returns:
Returns true on success and false otherwise.
Examples:
CreatePointShapefile.cs, CreatePolygonShapefile.cs, MarkPoints.cs, PolygonsWithHoles.cs, and Segmentation.cs.
bool Shapefile.Open ( string  ShapefileName,
ICallback  cBack 
)

Opens shapefile from the disk.

Any other shapefile currently opened will be closed wihout saving the changes. Shapefile.SourceType property will be set to sstDiskBased.

Parameters:
ShapefileNameThe name of the file to open (.shp extention).
cBackA callback object to report errors and progress information.
Returns:
True on success and false otherwise. Use Shapefile.get_ErrorMsg(Shapefile.LastErrorCode) to find out the reason of failure.
Examples:
AddCategoryRange.cs, AddLayers.cs, CalculateArea.cs, CreateBuffer.cs, EditAttributes.cs, GenerateLabelsManually.cs, IntersectionLength.cs, LabelSelection.cs, MinimalDistance.cs, PointIcons.cs, RemoveShape.cs, Segmentation.cs, SelectBox.cs, SelectByDistance.cs, SelectByQuery.cs, ShapefileToDrawingLayer.cs, SplitByAttribute.cs, ToolTip.cs, Tracking.cs, and ZoomToValues.cs.
bool Shapefile.Resource ( string  newShpPath)

Changes file associated with the current instance of the shapefile class.

It is equivalent to consequent calling of Shapefile.Close and Shapefile.Open.

Parameters:
newShpPathThe filename of the new shapefile to be opened.
Returns:
True on successful opening of the new shapefile or false otherwise.
bool Shapefile.Save ( ICallback  cBack)

Saves edits of the in-memory shapefile to the disk without closing editing mode.

Applicable only when Shapefile.EditingShapes = true.

Parameters:
cBackA callback object to report errors and progress information.
Returns:
True on successful saving and false otherwise.
bool Shapefile.SaveAs ( string  ShapefileName,
ICallback  cBack 
)

Saves in-memory shapefile to the disk.

Parameters:
ShapefileNameThe name of the file to save data in.
cBackA callback object to report errors and progress information.
Returns:
True on successful saving and false otherwise.
Examples:
PolygonsWithHoles.cs.
 All Classes Files Functions Enumerations Properties