Skip to main content
Solved

How to generate height lines with the same X, Y only in the third dimension using differences in Z coordinates?

  • October 25, 2022
  • 1 reply
  • 23 views

Forum|alt.badge.img

I have two polyline features. One which is on the ground surface and one below the ground surface on the exact same location. I want to generate height lines for each Vertex generated by the differences in Z-coordinates of the corresponding vertices of the 2 polyline features.

Best answer by markatsafe

@sibe​ For each line, you can use CoordinateConcatenator to generate a comma separated list of the Z values and then use AttributeSplitter to generate a list attribute. Aggregate the two lines. You can the pass the two list attributes into a short PythonCaller script - something along the lines off:

import fme
import fmeobjects
 
def processFeature(feature):
    # initialize the python lists with FME lists
    _Z1 = feature.getAttribute('_Z1{}')
    _Z2 = feature.getAttribute('_Z2{}')
    
    _diffZ = []
    for i in range(len(_Z2)):
        _diff = float(_Z2[i]) - float(_Z1[i])
        _diffZ.append(_diff)
    # output the FME lists
    feature.setAttribute('_diffZ{}', _diffZ)

Force the Geometry to 2D (2DForcer) and then use FMEFunctionCaller to call:

@ZValue(_diffZ{})

as described by @Takashi Iijima​ here. For this to work your vertices have to line up, so you might have to use Intersector or Snapper  before hand

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

Forum|alt.badge.img+2
  • 1891 replies
  • Best Answer
  • October 25, 2022

@sibe​ For each line, you can use CoordinateConcatenator to generate a comma separated list of the Z values and then use AttributeSplitter to generate a list attribute. Aggregate the two lines. You can the pass the two list attributes into a short PythonCaller script - something along the lines off:

import fme
import fmeobjects
 
def processFeature(feature):
    # initialize the python lists with FME lists
    _Z1 = feature.getAttribute('_Z1{}')
    _Z2 = feature.getAttribute('_Z2{}')
    
    _diffZ = []
    for i in range(len(_Z2)):
        _diff = float(_Z2[i]) - float(_Z1[i])
        _diffZ.append(_diff)
    # output the FME lists
    feature.setAttribute('_diffZ{}', _diffZ)

Force the Geometry to 2D (2DForcer) and then use FMEFunctionCaller to call:

@ZValue(_diffZ{})

as described by @Takashi Iijima​ here. For this to work your vertices have to line up, so you might have to use Intersector or Snapper  before hand