cursor=arcpy.da.searchCursor("mettaled", "SHAPE@")
for row in cursor:
    for part in geom:
        for pnt in part:
        x,y=pnt.X, pnt.Y
        print x,y

I am trying to merge the intersected line together(one feature class), but the problem is that some of those line having gaps and not intersected 100%. note: I used to do it with 'unsplit line' then 'spatial join' but that didn't work with gaped lines.

Can anyone do that with arcpy like list coordinates of the lines and connect-append the end point with the start of the next line

example of only two line

  • What happened when you ran the code that you’ve presented?
    – PolyGeo
    Commented Apr 3, 2022 at 10:51
  • Looking over your code, it appears you have a multi-part polyline that you want to convert into a single-part polyline (which involves removing the gap). Is that correct?
    – bixb0012
    Commented Apr 3, 2022 at 15:40
  • @PolyGeo it bring the x,y of all the line vertex
    – saraghafri
    Commented Apr 4, 2022 at 4:42
  • exactly that's what am looking for @bixb0012
    – saraghafri
    Commented Apr 4, 2022 at 4:43

1 Answer 1


What will work in this situation since the parts are inline with each other is to take the points from each part and create a new, single ArcPy array and pass that to the Polyline constructor to create a new single-part polyline.

>>> import arcpy
>>> install_info = arcpy.GetInstallInfo()
>>> f"{install_info['ProductName']}, {install_info['Version']}"
'ArcGISPro, 2.9.1'
>>> # illustrative code for combining multi-part polyline to single-part polyline
>>> multi_polyline = arcpy.FromWKT('MULTILINESTRING((0 0, 2 0, 2 1, 4 1),(8 2, 10 2, 12 4))')
>>> multi_polyline.isMultipart
>>> multi_polyline.partCount
>>> single_polyline = arcpy.Polyline(
...     arcpy.Array([vertex for part in multi_polyline for vertex in part])
... )
>>> single_polyline.isMultipart
>>> single_polyline.partCount
>>> # modified OP code to combine multi-part polyline to single-part polyline
with arcpy.da.SearchCursor("mettaled", "SHAPE@") as cur:
    for shape, in cur:  # notice the comma after shape for tuple unpacking
        new_shape = arcpy.Polyline(
            arcpy.Array([vertex for part in shape for vertex in part]),
  • thanks for helping, but am beginner at python so if you don't mind can you clarify it more? like if I need to change any of the Parameter or any thing else
    – saraghafri
    Commented Apr 5, 2022 at 6:29
  • @saraghafri, I updated my code block to include modifications to your code that should work.
    – bixb0012
    Commented Apr 5, 2022 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.