This project is read-only.

HOW TO add or lower the Z of a polyline Z line...

Oct 21, 2014 at 12:23 AM
Dear reader

I want to lower or add height to the Z of a polyline anyone knows how to access this Z-value?
Nov 6, 2014 at 1:38 AM
anyone? how to access the Z value of a line shape?
Nov 6, 2014 at 8:47 AM
Hi Joska,

I don't know how it works with Z values, but the following sample code seems to work...
        Dim flayer As FeatureLayer
        flayer = TryCast(Map1.Layers.SelectedLayer, FeatureLayer)

        Dim k As Integer = 0
        For i As Integer = 0 To flayer.FeatureSet.Z.Count - 1
            'For j As Integer = 0 To fef.FeatureSet.Features.Count - 1
            flayer.FeatureSet.Z(i) = ZZZZZ 'your desired Z value
            'Next
        Next
        flayer.DataSet.Save()
It seems that the Z attribute is an array of Z coordinates for all of the points in your polyline shapefile. To me it seems that if you have 2 features, the first one with 4 coordinates and the second one with 10 coordinates, the Z array will contains 14 values, the former 4 related to the first feature, the latter 10 to the second

Don't know if this answers your needs.
Ciao
Oscar
Nov 6, 2014 at 2:10 PM
Thanx Oscar....

I will try to puzzle with that a bit.... SO that gives me access to each vertices-point of the polyline?

What I also want is to make a CSV exports of a polyline Z

So lets say the polyline is
x1 y1 z1 m1
x2 y2 z2 m2
x3 y3 z3 m3
and a second line is
xa ya za ma
xb yb zb mb
xc yc zc mc

than the output i wanna make is like this
x1 y1 z1 m1 x2 y2 z2 m2
x2 y2 z2 m2 x3 y3 z3 m3
xa ya za ma xb yb zb mb
xb yb zb mb xc yc zc mc

so will i be able to retrieve the individual Z and M from the shape...?
Nov 6, 2014 at 3:11 PM
Hi Joska,

if what I wrote at the bottom of my last answer is correct I think it is possible. Here a sample code for doing the first part of the output:
        FileOpen(100, "coordinates.txt", OpenMode.Output)
        Dim x, y, z, m As Double
        Dim count As Integer = 0
        Dim ifeat As Integer = 0
        For Each f As Feature In flayer.FeatureSet.Features
            PrintLine(100, "feature " & ifeat)
            ifeat = ifeat + 1
            For Each coord As Coordinate In f.BasicGeometry.Coordinates
                x = coord.X
                y = coord.Y
                z = flayer.FeatureSet.Z(count)
                m = flayer.FeatureSet.M(count)
                PrintLine(100, x, y, z, m)
                count = count + 1
            Next
        Next
        FileClose(100)
with that you should get

feature 0
x1 y1 z1 m1
x2 y2 z2 m2
x3 y3 z3 m3
feature 1
xa ya za ma
xb yb zb mb
xc yc zc mc

then you can play with them to get the second part you need

Ciao
Oscar
Nov 6, 2014 at 11:09 PM
Edited Nov 7, 2014 at 12:01 AM
it produces an error...

system.index.outofrangeexception

index is outside the matrixboundaries...

It cant read the Z value when i disable the z and the m it goes well.... i think it doesnt recognise that teh shape is a polylineZ type?
...

ha now i see it it can not read the M-value.... it reads teh Z-value which i need...

But the documentation gives teh impression the M-value should be accessible too....
Nov 7, 2014 at 2:03 AM
Furthermore with large files it produces an outofmemory exception. The error points to the first line in this code suggesting that the Int32 capacity is a problem....

I have a shape with 70k polylines... 60k doesnt work either but 38k lines does...

Anyone, any idea whats going on?
            For Each f As Feature In flayer.FeatureSet.Features
                Dim countZ As Long = 0
                For Each coord As Coordinate In f.BasicGeometry.Coordinates
                    If countZ = 0 Then
                        HulpX = Round(100 * coord.X, 0)
                        HulpY = Round(100 * coord.Y, 0)
                        HulpZ = Round(100 * flayer.FeatureSet.Z(countZ), 0)
                    Else
                        BodemlijnX1 = HulpX
                        BodemlijnY1 = HulpY
                        BodemlijnZ1 = HulpZ
                        BodemlijnM1 = Round(0, 0)
                        BodemlijnX2 = Round(100 * coord.X, 0)
                        BodemlijnY2 = Round(100 * coord.Y, 0)
                        BodemlijnZ2 = Round(100 * flayer.FeatureSet.Z(countZ), 0)
                        BodemlijnM2 = Round(0, 0)
                        Bodemlijn = New Class_Bodemlijn(BodemlijnX1, BodemlijnY1, BodemlijnX2, BodemlijnY2, BodemlijnZ1, BodemlijnM1, BodemlijnZ2, BodemlijnM2)
                        BodemlijnLijst.Add(Bodemlijn)
                        HulpX = BodemlijnX2
                        HulpY = BodemlijnY2
                        HulpZ = BodemlijnZ2
                    End If
                    countZ = countZ + 1
                Next
                countLine = countLine + 1
                Me.ProgressBar.Value = 90 * (countLine / TotaalAantalPolyLines + 1)
            Next
Nov 7, 2014 at 8:03 AM
If it is a memory limit it should work if you compile 64 bit and use Long instead of Integer

Oscar
Nov 12, 2014 at 12:47 AM
I noticed something went wrong in my original code.... it seems the Z is listed as a long string so outside the loop it must be set to zero and in the loop it must get increased every loop..... now this code works...
 Dim countLine As Long = 0
            Dim countZ As Long = 0
            For Each f As Feature In flayer.FeatureSet.Features
                Dim countA As Long = 0
                For Each coord As Coordinate In f.BasicGeometry.Coordinates
                    If countA = 0 Then
                        HulpX = Round(1000 * coord.X, 0)
                        HulpY = Round(1000 * coord.Y, 0)
                        HulpZ = Round(1000 * flayer.FeatureSet.Z(countZ), 0)
                    Else
                        BodemlijnX1 = HulpX
                        BodemlijnY1 = HulpY
                        BodemlijnZ1 = HulpZ
                        BodemlijnM1 = Round(0, 0)
                        BodemlijnX2 = Round(1000 * coord.X, 0)
                        BodemlijnY2 = Round(1000 * coord.Y, 0)
                        BodemlijnZ2 = Round(1000 * flayer.FeatureSet.Z(countZ), 0)
                        BodemlijnM2 = Round(0, 0)
                        Bodemlijn = New Class_Bodemlijn(BodemlijnX1, BodemlijnY1, BodemlijnX2, BodemlijnY2, BodemlijnZ1, BodemlijnM1, BodemlijnZ2, BodemlijnM2)
                        BodemlijnLijst.Add(Bodemlijn)
                        HulpX = BodemlijnX2
                        HulpY = BodemlijnY2
                        HulpZ = BodemlijnZ2
                    End If
                    countZ = countZ + 1
                    countA = countA + 1
                Next
                countLine = countLine + 1
                Me.ProgressBar.Value = 90 * (countLine / (TotaalAantalPolyLines + 1))
            Next