Sample code that demonstrates how to calculate the length of a linestring.

Imports DotSpatial.Geometries
Imports DotSpatial.Topology.Geometries

		Private Sub btnLength_Click(sender As Object, e As EventArgs)
				'Creates a coordinate arrary
				Dim coords As Coordinate() = New Coordinate(35) {}
				'Creates a random number generator
				Dim rnd As New Random()
				'A for loop that will generate random coordinate's and add those coordinates to the array
				For i As Integer = 0 To 35

					coords(i) = New Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90)
				'Creates a linestring from the array of coordinates
				Dim ls As New LineString(coords)
				'Calculates the length of the linestring
				Dim length As [Double]
				length = ls.Length
			Catch ex As Exception
			End Try
		End Sub

Last edited Jul 13, 2010 at 2:39 PM by AlamoMan, version 4