GP Tool to get true midpoint of multi-part lines

538
5
07-29-2022 08:34 AM
Status: Open
Labels (1)
Bud
by
Notable Contributor

For multi-part lines, it would be helpful if there were a GP that could:

Create a single midpoint for the entire feature. Place the point halfway along the entire length of the line (all parts considered).

  • The Feature Vertices to Points GP tool doesn't seem to do this. It creates a point for each part.
  • The Feature to Point GP tool (with the "Inside" option) doesn't seem to do it either. The point isn't placed halfway along the line.
    • It seems to do something else, like possibly place the point in the middle of the feature envelope. Then snap the point to the line, to satisfy the "Inside" criteria. That's not the same as the line midpoint.

Could a GP Tool be added that creates a true midpoint for multi-part lines?

Thanks.

5 Comments
ScottFedak2085

There is this editing tool that you may find useful: https://pro.arcgis.com/en/pro-app/latest/help/editing/create-point-features-along-a-line.htm

I haven't utilized this with multiline features, so I can't speak to exactly how those are handled, but you could try this GP Script tool and specify a percentage of 50%: https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/generate-points-along-lines....

Bud
by

@ScottFedak2085 

I think you might be right, the Generate Points Along Lines tool (your second link) seems to do what I want, using By Percentage: 50.

  • Create a single midpoint for the entire multi-part feature.
  • Place the point halfway along the entire length of the line (all parts considered).

Bud_1-1680292398096.png

@DanLee Feel free to close this idea.

 

ScottFedak2085

@Bud glad that helped.

I know I've ran into issues with that GP Tool only being able to apply the same distance or percentage across every feature in a feature class. I've had times where I wanted to utilize a features attributes to vary how points are placed along a given feature. To accomplish this, I've modified the code in Link #1 below utilizing Geometry Objects. It might be worth looking at Geometry Objects and their associated methods (Link #2) when you have a chance, they can be a pretty powerful tool in conducting custom spatial analysis. 

Link #1 - https://gis.stackexchange.com/questions/214162/generate-points-along-line

Link #2 - https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/geometry.htm 

Bud
by

@ScottFedak2085 Interesting. Thanks.

I had thought about that concept too: "utilize a feature's attributes to vary how points are placed along a given feature." I can see how that would be useful; I submitted it as an idea: Use value from field in Generate Points Along Lines.

Bud
by

It looks like the Central point x-coordinate and y-coordinate options can be used in Calculate Geometry Attributes to get the true midpoint of multi-part lines (in conjunction with an XY Event Layer).

Bud_0-1708923710006.png

However, I did some measuring with the measurement tool, and the point might not be exactly in the middle of the line. It might be off by a few metres. So maybe it’s not the true midpoint.