This project is read-only.

How to make a shapefile polyline non-multipart

Sep 14, 2012 at 12:18 AM
Edited Sep 14, 2012 at 12:19 AM
This code below makes a shape but the lines appear being one multipart shape but i want to have it in lines... each line is a sole polyline.... Any way to accomplisch this?
    Private Sub MaakShapeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MaakShapeButton.Click
            Dim rnd As New Random()
            Dim filename As String = txtPadFileNaam.Text & "testPoint.shp"
            Dim f As New Feature()
            Dim fs As New FeatureSet(f.FeatureType)
            fs.Projection = myVenster.Projection
            For ir As Integer = 0 To 39
                Dim coord As Coordinate() = New Coordinate(35) {}
                For i As Integer = 0 To 35
                    coord(i) = New Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90)
                Dim ls As New LineString(coord)
                f = New Feature(ls)
            fs.SaveAs(filename, True)
        Catch ex As Exception
            MsgBox(ex.ToString, MsgBoxStyle.Critical, "Fout in MaakShapeButton_Click")
        End Try
    End Sub
Sep 14, 2012 at 9:05 PM

I decided to solve it in a different way and output polylines with this code BUT problem now is   i cant figure out how to output a set of single lines as this code below generates 2 lines at the same spot...

What the code does is....generate a set of loose polylines into one shape where its coordinates is based on coordinates from a list... BakjesLijst... 

The red part must be 2 coordinates as 1 only generates errors... (ofcourse)... but in this code it generates two lines at the same spot....  Any idea how to generate loose -1line-polylines into 1 shapefile....?

    Private Sub Maak_BakjesShape(ByVal sFilename)
        REM ***************************************************************
        REM * Maak van de as een shapefile en voeg hem toe aan de layers
        REM ***************************************************************
            Dim count As Long
            Dim filename As String = Form1.txtPadFileNaam.Text & sFilename & "_DMC_bakjes.shp"
            Dim f As New Feature()
            Dim fs As New FeatureSet(f.FeatureType)
            'Voeg kolommen toe
            fs.DataTable.Columns.Add(New DataColumn("ID", GetType(System.Int32)))
            fs.DataTable.Columns.Add(New DataColumn("REDlinks", GetType(System.Int32)))
            fs.DataTable.Columns.Add(New DataColumn("REDrechts", GetType(System.Int32)))
            'Set projection
            fs.Projection = Form1.myVenster.Projection
            'FOr all polylines
            For count = 0 To BakjesLijst.Count - 1
                Dim coord As Coordinate() = New Coordinate(1) {}
                'Per polyline
                For i As Integer = 0 To 0
                    coord(i) = New Coordinate(BakjesLijst(count).X1bakje, BakjesLijst(count).Y1bakje)
                    coord(i + 1) = New Coordinate(BakjesLijst(count).X2bakje, BakjesLijst(count).Y2bakje)
                Dim ls As New LineString(coord)
                f = New Feature(ls)
                ' now the resulting features knows what columns it has
                ' add values for the columns
                Dim feature As IFeature = fs.AddFeature(ls)
                Feature.DataRow("ID") = 1
                feature.DataRow("REDlinks") = 200
                feature.DataRow("REDrechts") = 23000
            fs.SaveAs(filename, True)