MapWinGIS:Shapefile EditDeleteShape

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy

EditDeleteShape

Deletes a shape from the shapefile. Note: Both the shapefile and the attribute table must be in editing mode to delete a shape from the shapefile.
Don't forget to start deleting with the highest shapeID (from bottom up)


VB.NET Usage

Function EditDeleteShape(ShapeIndex As Integer) As Boolean

            Parameters

ShapeIndex

The index of the shape to be deleted from the shapefile.
ReturnValue A boolean value representing the success or failure of deleting the shape from the shapefile.

Sample Code

    Private Sub EditDeleteShape()
        Dim sf As New MapWinGIS.Shapefile()
        'Switch the shapefile into editing mode
        sf.StartEditingShapes()
        'Delete shape 0 from the shapefile
        sf.EditDeleteShape(0)
    End Sub
  

VB 6 Usage
Function EditDeleteShape(ShapeIndex As Long) As Boolean
            Parameters

ShapeIndex

The index of the shape to be deleted from the shapefile.
ReturnValue A boolean value representing the success or failure of deleting the shape from the shapefile.

Sample Code

    Private Sub EditDeleteShape()
        Dim sf As New MapWinGIS.Shapefile
        'Switch the shapefile into editing mode
        sf.StartEditingShapes
        'Delete shape 0 from the shapefile
        sf.EditDeleteShape (0)
    End Sub


C# Usage
bool IShapefile.EditDeleteShape(int ShapeIndex)
            Parameters

ShapeIndex

The index of the shape to be deleted from the shapefile.
ReturnValue A boolean value representing the success or failure of deleting the shape from the shapefile.

Sample Code

 MapWinGIS.Shapefile sf = new MapWinGIS.Shapefile();
 if (!sf.Open(sfFilename, null))
 {
     throw new System.Exception("Error! sf.Open: " + sf.get_ErrorMsg(sf.LastErrorCode));
 }
 if (!sf.StartEditingShapes(true, null))
 {
     throw new System.Exception("Error! sf.StartEditingShapes: " + sf.get_ErrorMsg(sf.LastErrorCode));
 }
 
 for (int i = sf.NumShapes-1; i >= 0; i--)
 {
     if (!sf.EditDeleteShape(i))
     {
         throw new System.Exception("Error! sf.EditDeleteShape: " + sf.get_ErrorMsg(sf.LastErrorCode));
     }
 }
 if (!sf.StopEditingShapes(true, true, null))
 {
     throw new System.Exception("Error! sf.StopEditingShapes: " + sf.get_ErrorMsg(sf.LastErrorCode));
 }
 if (!sf.Close())
 {
     throw new System.Exception("Error! sf.Close: " + sf.get_ErrorMsg(sf.LastErrorCode));
 }

Retrieved from "http://mapwindow.org/wiki/index.php/MapWinGIS:Shapefile_EditDeleteShape"

This page has been accessed 2,121 times. This page was last modified on 9 November 2009, at 09:22.