Solved

Create midpoint of every line feature

  • 20 February 2015
  • 14 replies
  • 194 views

Hello everyone,

 

 

In my workspace I am using the CenterOfGravityReplaces and/or the CenterPointReplacer transformer but some of my points do not actually land on the line. Some do. How can I get it so that all of the midpoints land on the lines?

 

 

 

 

 
icon

Best answer by gio 21 February 2015, 00:19

View original

14 replies

Badge +3
The center is center of its bounding box. That why its not on the line if line is not straight piece.

 

Make a network of it, that is, all lines are defined between nodes.

 

The use a snipper in percentage mode on these linepieces. Start = 50, End = 50 will result in middle of linepiece.
Badge +7

I'm trying to do the same thing. We currently do this with ArcInfo. See:

http://pro.arcgis.com/en/pro-app/tool-reference/data-management/feature-to-point.htm

"If the Inside option on the dialog box is checked (the point_location parameter is set to INSIDE), the location of the representative point of an input feature will be contained by the input feature and determined as follows:

For an input line: the output point will be on the line. If the line is a parametric (true) curve, the output point will be at the midpoint of the line."

I'm trying to replicate this in FME by using the Snipper to trim 50% from the start and end of the line, resulting in a point feature. See:

https://knowledge.safe.com/questions/33775/snipper-does-not-work-properly.html?childToView=49717#answer-49717

It works for some lines but we have others where the line branches (dark grey in screenshot below) or is a multipart feature where the parts are geographically separate (light grey in screenshot).

This results in more than one point coming out of Snipper. The yellow points are what the ArcGIS tool creates, the pink are what Snipper produces. There's obviously a certain advantage in a blob appearing on each of the light grey lines, but we specifically only want one point per feature.

Badge +14

I'm trying to do the same thing. We currently do this with ArcInfo. See:

http://pro.arcgis.com/en/pro-app/tool-reference/data-management/feature-to-point.htm

"If the Inside option on the dialog box is checked (the point_location parameter is set to INSIDE), the location of the representative point of an input feature will be contained by the input feature and determined as follows:

For an input line: the output point will be on the line. If the line is a parametric (true) curve, the output point will be at the midpoint of the line."

I'm trying to replicate this in FME by using the Snipper to trim 50% from the start and end of the line, resulting in a point feature. See:

https://knowledge.safe.com/questions/33775/snipper-does-not-work-properly.html?childToView=49717#answer-49717

It works for some lines but we have others where the line branches (dark grey in screenshot below) or is a multipart feature where the parts are geographically separate (light grey in screenshot).

This results in more than one point coming out of Snipper. The yellow points are what the ArcGIS tool creates, the pink are what Snipper produces. There's obviously a certain advantage in a blob appearing on each of the light grey lines, but we specifically only want one point per feature.

I was going to say that it works on polyline, but as with everything esri, multilines are treated differently. :)
Userlevel 2
Badge +17

Hi @tim_wood, I'm not sure whether it's the correct behavior that the Snipper with your setting generates multiple points for every part of a so-called multi-part line. I thought the Snipper should reject a feature having an Aggregate or Multi geometry according to this description in the help doc.

"Aggregate features, including homogeneous aggregates, are also rejected." -- Help on the Snipper

Or, if the behavior is intentional, the help doc has to be modified. Hope someone from Safe check this. @NatalieAtSafe

Anyway, "midpoint" cannot be defined for a multi-part line, and your quoted Esri description on the "Feature To Point" functionality doesn't mention the definition of the INSIDE point of a multi-part line. You therefore will have to clarify the definition of your desired point for a multi-part line at first. Since the logic of the Esri function is not published, "a point which is the same as the point created by the Esri Feature To Point function" defines nothing.

Just an example. If you need to create "a point on a multi-part line, which is closest to the center of gravity of the source multi-part line", it could be created by a small workflow consisting of a CanterPointReplacer (Mode: Center of Gravity Point), a NeighborFinder, and a VertexCreator.

Badge +7

Hi @tim_wood, I'm not sure whether it's the correct behavior that the Snipper with your setting generates multiple points for every part of a so-called multi-part line. I thought the Snipper should reject a feature having an Aggregate or Multi geometry according to this description in the help doc.

"Aggregate features, including homogeneous aggregates, are also rejected." -- Help on the Snipper

Or, if the behavior is intentional, the help doc has to be modified. Hope someone from Safe check this. @NatalieAtSafe

Anyway, "midpoint" cannot be defined for a multi-part line, and your quoted Esri description on the "Feature To Point" functionality doesn't mention the definition of the INSIDE point of a multi-part line. You therefore will have to clarify the definition of your desired point for a multi-part line at first. Since the logic of the Esri function is not published, "a point which is the same as the point created by the Esri Feature To Point function" defines nothing.

Just an example. If you need to create "a point on a multi-part line, which is closest to the center of gravity of the source multi-part line", it could be created by a small workflow consisting of a CanterPointReplacer (Mode: Center of Gravity Point), a NeighborFinder, and a VertexCreator.

Thanks @takashi I'll have a go at that. I don't mind if the FME output is not exactly the same as what ESRI produces, I'm aiming for something as close as possible. So I'd like one point on the dark grey line and one on the light grey line, as close as possible to the midpoint or centre of gravity as possible. I've thought about snapping the point to the nearest line, but I'm worried it might be moved to a different line which happens to be closer.

 

 

In 2017.0.1.1, the Snipper has an Agggregate Handling option, which can be set to Deaggregate or Reject. I think this may be missing from the help page for the transformer @NatalieAtSafe.

 

Userlevel 2
Badge +17
Thanks @takashi I'll have a go at that. I don't mind if the FME output is not exactly the same as what ESRI produces, I'm aiming for something as close as possible. So I'd like one point on the dark grey line and one on the light grey line, as close as possible to the midpoint or centre of gravity as possible. I've thought about snapping the point to the nearest line, but I'm worried it might be moved to a different line which happens to be closer.

 

 

In 2017.0.1.1, the Snipper has an Agggregate Handling option, which can be set to Deaggregate or Reject. I think this may be missing from the help page for the transformer @NatalieAtSafe.

 

ah, I didn't notice the Aggregate Handling parameter. Definitely the help has to be updated.

 

 

Badge +7

Hi @tim_wood, I'm not sure whether it's the correct behavior that the Snipper with your setting generates multiple points for every part of a so-called multi-part line. I thought the Snipper should reject a feature having an Aggregate or Multi geometry according to this description in the help doc.

"Aggregate features, including homogeneous aggregates, are also rejected." -- Help on the Snipper

Or, if the behavior is intentional, the help doc has to be modified. Hope someone from Safe check this. @NatalieAtSafe

Anyway, "midpoint" cannot be defined for a multi-part line, and your quoted Esri description on the "Feature To Point" functionality doesn't mention the definition of the INSIDE point of a multi-part line. You therefore will have to clarify the definition of your desired point for a multi-part line at first. Since the logic of the Esri function is not published, "a point which is the same as the point created by the Esri Feature To Point function" defines nothing.

Just an example. If you need to create "a point on a multi-part line, which is closest to the center of gravity of the source multi-part line", it could be created by a small workflow consisting of a CanterPointReplacer (Mode: Center of Gravity Point), a NeighborFinder, and a VertexCreator.

@takashi are you suggesting CenterPointRepacer/NeighborFinder/VertexCreator after the Snipper or instead of the Snipper?
Userlevel 2
Badge +17
@takashi are you suggesting CenterPointRepacer/NeighborFinder/VertexCreator after the Snipper or instead of the Snipper?
This screenshot illustrates the example I mentioned above.

 

 

However, this might be better.

 

 

Badge +7
@takashi are you suggesting CenterPointRepacer/NeighborFinder/VertexCreator after the Snipper or instead of the Snipper?
@takashi I believe you are a genius! Your second option is indeed better (yellow = ArcGIS, purple = FME). @daleatsafe can we give this guy some points for solving this?

 

Hi

You can use the labelpointreplacer , coordinateextractor, vertexcreator (replace with point mode witj the xvalue and y value from the coordinateextractor)

Userlevel 4
Badge +13

Hi @tim_wood, I'm not sure whether it's the correct behavior that the Snipper with your setting generates multiple points for every part of a so-called multi-part line. I thought the Snipper should reject a feature having an Aggregate or Multi geometry according to this description in the help doc.

"Aggregate features, including homogeneous aggregates, are also rejected." -- Help on the Snipper

Or, if the behavior is intentional, the help doc has to be modified. Hope someone from Safe check this. @NatalieAtSafe

Anyway, "midpoint" cannot be defined for a multi-part line, and your quoted Esri description on the "Feature To Point" functionality doesn't mention the definition of the INSIDE point of a multi-part line. You therefore will have to clarify the definition of your desired point for a multi-part line at first. Since the logic of the Esri function is not published, "a point which is the same as the point created by the Esri Feature To Point function" defines nothing.

Just an example. If you need to create "a point on a multi-part line, which is closest to the center of gravity of the source multi-part line", it could be created by a small workflow consisting of a CanterPointReplacer (Mode: Center of Gravity Point), a NeighborFinder, and a VertexCreator.

Hi @takashi and @tim_wood. The Aggregate Handling is going to be added into the Snipper doc. It will state something along the lines of "If "Aggregate Handling" is "Deaggregate," all input aggregates will be deaggregated, and each split part will be processed independently. With this setting, the transformer might output more features than were given as inputs. If "Aggregate Handling" is "Reject," all input aggregates will be rejected."
Badge +7

Hi

You can use the labelpointreplacer , coordinateextractor, vertexcreator (replace with point mode witj the xvalue and y value from the coordinateextractor)

 

I liked the sound of this idea but unless I run the features through GeometryFilter (Line port) or GeometryValidator (all come out of Passed port), LabelPointReplacer rejects what seems like the first feature as having and invalid geometry type. Inspecting the feature, it's an fme_aggregate made up of 2 lines so I wonder if LabelPointReplace doesn't like multipart features. I wonder what GeometryValidator and GeometryFilter do to the data because 20,000 input features come out the Passed/Line ports and become 68,000 features after LabelPointReplacer, and I get the green points shown below.

 

 

Badge

Hi @hlee1282

CenterPointReplacer uses feature bounding box or center of mass, i.e. it does not guarantee that the 'center point' will be on the line.

You might want to give LineDivider (custom transformer developed by @takashi ) a try.

Thanks for all the suggestions, I had the same problem, and used the simple solution of reader - snipper - writer. In snipper, using exact parameter noted above, sipping mode: distance percentage, starting location and ending location both 50.

Worked like a charm, thanks!

Reply