Solved

Create a line perpendicular to another, starting from a given point

  • 26 September 2018
  • 9 replies
  • 39 views

Hello,

I have some points, and those points have a POINT_NUMBER attribute. POINT_NUMBER is not unique.

I have some lines, and those lines have a LINE_NUMBER attribute. LINE_NUMBER is not unique.

For each point, I have to search for the closest line where POINT_NUMBER=LINE_NUMBER.

Then I have to draw a perpendicular segment from the point to the corresponding line, ending on the line.

Thank you for your help

icon

Best answer by david_r 26 September 2018, 17:19

View original

9 replies

Userlevel 4

The NeighborFinder would be a good option. My recommendation would be to rename both POINT_NUMBER and LINE_NUMBER to e.g. ID and then use "ID" as a Group By-clause (the attribute name has to be identical between all the incoming objects). Make sure to set a sufficiently large maximum distance (ground units).

On the Matched output port, connect a VertexCreator to add the coordinates from _closest_candidate_x and _closest_candidate_y to create the line.

Hi David, Thank you for your answer.

Actually, I already tried that, and it was not working so I thought that the method was wrong.

Both IDs where renamed ID, and then I have a neighbourFinder with the lines as Base, the points as candidates, group by ID, Input Bases and candidates, no parallelism, 1 neighbour to find, 50m for the distance, insert vertex=No (or yes, no difference).

On the output port the Matched features are the lines that are closest to the points.

When I add a Vertex creator, mode Add point and closest candidates coordinates, I obtained some lines, but those resulting lines are connecting my initial points to some vertexes in the initial lines. Sometimes the start point and the end point, sometimes only one of them, and the distance doesn't seem to be a criteria so I don't understand.

What I need is to create a new point on the initial line, and the distance between the initial point and the resulting point must be minimum (the segment is perpendicular)

 

Userlevel 4

What may be a bit unclear unless you read the docs carefully, is that the Matched output port actually means "MatchedBase". Which means that if your base features are lines, then the Matched output features will be your lines, which will give you an unexpected result when you add another vertex.

So basically you need to send the points to Base, and the lines to Candidate, see attached template:

neighborfinder.fmwt

 

 

Badge +3

There might not be e perpendicular line possible, as you are talking about "line pieces" rather than (mathematical lines) lines (which are infinite). In those cases the nearest neighbor usually is the begin or end of the line.

Apart from neighbourfinding:

You can achieve all perpendiculars by calculating the smallest distance between point and line (basic goniometry with some differential calculus)

Or you can merge the line and points using on the ID. Move the line to the point location and then rotate it 90 degrees.

Hi David,

If I put the lines as candidates, the results are points, as you said, and those points are at the exact location of the initial points, not on the lines, so it does not help me.

Hi gio,

In my case I should always have a result because I'm working on streets and center of parcels. It's possible that in two or three cases the street is too short but I can treat them manually after that :)

 

Move the line to the point and rotate it is a great idea. I will try this on Monday. I'm thinking of using thoses transformers :

CoordinateExtractor to get the coordinates of the first point of the line

ExpressionEvaluator to make the difference between the coordinate of the line and the corrdinate of the point and then Offseter to move the line to the point ? and Rotator to rotate ?

 

I think it will be complicated because I will never be sure to move the line in the right direction and to rotate in the right direction too. Is there a way to do it simplier ? (I'm quite a beginner with FME)

I know thgere are some transformer to calculate the smallest distance between a line and a point (I don't remember exactly which one but I saw it I can retrieve it) but I don't understand after that how I create the point at the right place. By creating a cercle with the point as center and the smallest distance as radius ? And then calculating the intersection between the circle and the line ? Isn't it too complicated ?

Thank you both for your answers.

Userlevel 2
Badge +17

Hi David,

If I put the lines as candidates, the results are points, as you said, and those points are at the exact location of the initial points, not on the lines, so it does not help me.

Hi gio,

In my case I should always have a result because I'm working on streets and center of parcels. It's possible that in two or three cases the street is too short but I can treat them manually after that :)

 

Move the line to the point and rotate it is a great idea. I will try this on Monday. I'm thinking of using thoses transformers :

CoordinateExtractor to get the coordinates of the first point of the line

ExpressionEvaluator to make the difference between the coordinate of the line and the corrdinate of the point and then Offseter to move the line to the point ? and Rotator to rotate ?

 

I think it will be complicated because I will never be sure to move the line in the right direction and to rotate in the right direction too. Is there a way to do it simplier ? (I'm quite a beginner with FME)

I know thgere are some transformer to calculate the smallest distance between a line and a point (I don't remember exactly which one but I saw it I can retrieve it) but I don't understand after that how I create the point at the right place. By creating a cercle with the point as center and the smallest distance as radius ? And then calculating the intersection between the circle and the line ? Isn't it too complicated ?

Thank you both for your answers.

This is the translation result from @david_r's workspace example.

 

  • Blue: Point entered into the NeighborFinder via the Base port
  • Green: Line entered into the NeighborFinder via the Candidate port
  • Red: Resulting line connecting between the Base point and the closest point on the line
Isn't this your desired result?

 

 

Userlevel 4

Hi David,

If I put the lines as candidates, the results are points, as you said, and those points are at the exact location of the initial points, not on the lines, so it does not help me.

Hi gio,

In my case I should always have a result because I'm working on streets and center of parcels. It's possible that in two or three cases the street is too short but I can treat them manually after that :)

 

Move the line to the point and rotate it is a great idea. I will try this on Monday. I'm thinking of using thoses transformers :

CoordinateExtractor to get the coordinates of the first point of the line

ExpressionEvaluator to make the difference between the coordinate of the line and the corrdinate of the point and then Offseter to move the line to the point ? and Rotator to rotate ?

 

I think it will be complicated because I will never be sure to move the line in the right direction and to rotate in the right direction too. Is there a way to do it simplier ? (I'm quite a beginner with FME)

I know thgere are some transformer to calculate the smallest distance between a line and a point (I don't remember exactly which one but I saw it I can retrieve it) but I don't understand after that how I create the point at the right place. By creating a cercle with the point as center and the smallest distance as radius ? And then calculating the intersection between the circle and the line ? Isn't it too complicated ?

Thank you both for your answers.

Did you try the template I uploaded?

Hello,

I cannot try David's workbench because I'm working with FME 2015. However, I looked at it very carefully and did the same in my version of FME. I was on leave until today so I tested that this morning. The result is the perpendicular line, but there is no point created on the intersection between this new line and the initial one, so I have to add a LineOnLineOverlayer.

Thank you for your help.

 

Have a nice day.

Userlevel 4

Here's the same template for FME 2015.1

neighborfinder-2015.fmwt

Result:

Green = input line, blue dot = input point, red = resulting connection.

Reply