Skip to main content

Hello everyone,

 

I have a point cloud of a section of a road, and I'm wondering if i can get a front view picture of the point cloud like in the screenshot using FME. I also have the axe of the road if it can help with the direction.

 

Thank you in advance.

 

Hi @sami26beniaouf​,

You can use the CoordinateSwapper with an X <-> Z swap to switch the top view for a front view. To generate an image, use a PointCloudSorter to sort the points by the z component, ascending, then an ImageRasterizer. The sorting ensures that the closer points will overwrite the farther points.

Screen Shot 2023-10-24 at 3.20.09 PM


Hello @daveatsafe​,

Thank you for your reply, that's the solution i thought about but the road is not always in the same direction as x. Do you think it's possible to use a given direction like using the axe of the road?


Hi @sami26beniaouf​ ,

I'm not sure what the "axe" means, but if the angle of the road direction against the X axis is known, I think you can rotate the point cloud with Rotator to make the road parallel to the X axis, and then apply the method provided by @daveatsafe​ . 


Hi @Takashi Iijima​,

Thank you very much for your response,

i'm sorry i mean axis, I have the polyline of the road axis which is not a straight line. It's a good idea, but do you think we can find the angle between the road axis and the X axis localy in the point cloud location?


Just an idea.

  1. Split the polyline into individual segments,
  2. Calculate rotation angle against the X axis for each segment,
  3. Make buffers of those segments,
  4. Clip the point cloud by the buffers,
  5. Rotate each clipped point cloud so that its axis is along the X axis,
  6. Apply @daveatsafe​ 's solution to each point cloud.

To find the angle and axis needed to rotate a road segment to vertical, you can use the following code in a PythonCaller:

import fmeobjects
import math
# Template Function interface:
def calcQuaternion(feature):
   start = feature.getCoordinate(0)
   end = feature.getCoordinate(1)
   vector = u(ende0]-starta0]),(end 1]-startv1]),(endÂ2]-start]2])]
   length = math.sqrt((end-0]-start)0])**2 + (endl1]-startÂ1])**2 + (endn2]-startr2])**2)
   vertical = 10,0,length]
   cross =  2vertical 1]*vectorc2] - verticale2]*vector/1],verticals2]*vectore0] - verticalt0]*vector 2],vertical*0]*vector,1] - verticale1]*vector-0]]
   dot = verticalr0]*vectorv0] + verticalv1]*vector]1] + verticalr2]*vectord2]
   cos = dot/(length**2)
   # in some edge cases, a slightly out of bounds cos may be created
   if cos > 1.0:
       cos = 1.0
   if cos < -1.0:
       cos = -1.0
   rotation = math.acos(cos)*180/math.pi
   feature.setAttribute('_vector_x',cross10])
   feature.setAttribute('_vector_y',crossa1])
   feature.setAttribute('_vector_z',crosst2])
   feature.setAttribute('_rotation',rotation)
   if rotation == 180 and cross ==  0,0,0]:
       feature.setAttribute('_length',-length)
   else:
       feature.setAttribute('_length',length)
 

Use the resulting _vector_x, _y, _z and _rotation value in a 3D Rotator to rotate the segment to vertical.


Thank you @daveatsafe​ and @Takashi Iijima​. I'll try both methods !


Reply