Shapefile open and close

Functions

Shapefile Shapefile.Clone ()
 Creates a copy of the shapefile. More...
 
bool Shapefile.Close ()
 Closes shapefile and releases all the resources. More...
 
bool Shapefile.CreateNew (string shapefileName, ShpfileType shapefileType)
 Initializes in-memory shapefile of the specified type. More...
 
bool Shapefile.CreateNewWithShapeID (string shapefileName, ShpfileType shapefileType)
 Initializes in-memory shapefile of the specified type with unique index field. More...
 
bool Shapefile.Dump (string shapefileName, ICallback cBack=null)
 Writes the contents of the shapefile to specified file. More...
 
bool Shapefile.LoadDataFrom (string shapefileName, ICallback cBack=null)
 Loads data into in-memory shapefile from the specified shapefile on the disk. More...
 
bool Shapefile.Open (string shapefileName, ICallback cBack)
 Opens shapefile from the disk. More...
 
bool Shapefile.Resource (string newShpPath)
 Changes file associated with the current instance of the shapefile class. More...
 
bool Shapefile.Save (ICallback cBack)
 Saves edits of the in-memory shapefile to the disk without closing editing mode. More...
 
bool Shapefile.SaveAs (string shapefileName, ICallback cBack)
 Saves in-memory shapefile to the disk. More...
 
bool Shapefile.SaveAsEx (string newFilename, bool stopEditing, bool unboundFile)
 Saves shapefile to the disk. More...
 

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_29.png

Graph description

Function Documentation

◆ Clone()

Shapefile Shapefile.Clone ( )

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.

◆ Close()

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

◆ CreateNew()

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.

◆ CreateNewWithShapeID()

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
Segmentation.cs.

◆ Dump()

bool Shapefile.Dump ( string  shapefileName,
ICallback  cBack = null 
)

Writes the contents of the shapefile to specified file.

Parameters
shapefileNameFilename to write shapefile data to.
cBackCallback interface.
Returns
True on success and false otherwise.

The state of shapefile won't be affected, i.e. in-memory shapefile will remain in-memory one.

New API 4.9.1:
Added in version 4.9.1

◆ LoadDataFrom()

bool Shapefile.LoadDataFrom ( string  shapefileName,
ICallback  cBack = null 
)

Loads data into in-memory shapefile from the specified shapefile on the disk.

Parameters
shapefileNameFilename of the shapefile to load from.
cBackCallback interface.
Returns
True on success and false otherwise.

The shapefile object with remain in in-memory state.

New API 4.9.1:
Added in version 4.9.1

◆ Open()

bool Shapefile.Open ( string  shapefileName,
ICallback  cBack 
)

Opens shapefile from the disk.

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

Parameters
shapefileNameThe name of the file to open (.shp extension).
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, IntersectionLength.cs, LabelSelection.cs, MinimalDistance.cs, PointIcons.cs, Segmentation.cs, SelectBox.cs, ShapefileToDrawingLayer.cs, ShowAttributes.cs, SplitByAttribute.cs, ToolTip.cs, TrackCars.cs, and Tracking.cs.

◆ Resource()

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.

◆ Save()

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.

◆ SaveAs()

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.

◆ SaveAsEx()

bool Shapefile.SaveAsEx ( string  newFilename,
bool  stopEditing,
bool  unboundFile 
)

Saves shapefile to the disk.

Parameters
newFilenameThe new filename.
stopEditingIf set to true the editing for shapefile will be stopped.
unboundFileIf set to true the file will not be assigned as a source of this instance.
Returns
True on success.
New API 4.9.4:
Added in version 4.9.4