Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

New Post: M Values for points or lines

$
0
0
The only reason I see for your M beeing NaN is that you didn't add it to your features. So change
Dim newpoint As DotSpatial.Topology.Point = New DotSpatial.Topology.Point(coord.X, coord.Y, coord.Z)
to
Dim newpoint As DotSpatial.Topology.Point = New DotSpatial.Topology.Point(coords(i).X, coords(i).Y, coords(i).Z, coords(i).M)
to include M. If you didn't remove something from your function creating coord is not nessessary.

The following code creates a shapefile that contains M and Z values.
  Private Function AddPointFeatureToShape() As FeatureSet
        Dim pointF As New FeatureSet(FeatureType.Point)
        Try

            Dim coords As New List(Of Coordinate)
            coords.Add(New Coordinate(1, 2, 3, 4))
            coords.Add(New Coordinate(4, 5, 6, 7))
            coords.Add(New Coordinate(7, 8, 9, 10))


            pointF.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984
            pointF.CoordinateType = CoordinateType.Z

            For i = 0 To coords.Count - 1
                Dim newpoint As DotSpatial.Topology.Point = New DotSpatial.Topology.Point(coords(i))
                Dim currentFeature As IFeature = pointF.AddFeature(newpoint)
            Next


            pointF.SaveAs("D:\test.shp", True)

            Return pointF

        Catch ex As Exception
            MsgBox(ex.Message & ex.StackTrace)
            Return Nothing
        End Try

    End Function

Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>