6

I have a shapefile with several points (A, B, C, D, E,...) and I want to draw a line between all possible combinations of points (A-B, A-C, A-D, B-C, B-D,...).

As I know that it is quite simple in ArcGIS I don't want to use a Python-script or something similar. The "Points To Line" tool just draws me one line that is connecting all the points (A-B-C-D-...).

How can I do it using ArcGIS Desktop (all extensions available) ?

4
  • That will be a cool feature. I have not come across this before! Is this for any interesting analysis?
    – CwecU
    Nov 9, 2016 at 17:54
  • 7
    I think you can do this in two steps. First run "Generate Near Table", selecting Location. Next, run "XY to Line", providing start_x,start_y, near_x,near_y. Generate Near Table requires an Advanced license.
    – klewis
    Nov 9, 2016 at 18:18
  • Can you show a screen shot your attribute table?
    – whyzar
    Nov 9, 2016 at 19:01
  • Thank you klewis, I think this is a very simple and useful solution for the problem!
    – Christoph
    Nov 10, 2016 at 14:35

2 Answers 2

8

WORKFLOW:

arcpy.SpatialJoin_analysis("points","points", "D:/Scratch/many.shp","JOIN_ONE_TO_MANY","INTERSECT", search_radius="1000000 Meters")
arcpy.SelectLayerByAttribute_management("many", "NEW_SELECTION", """"TARGET_FID" = "JOIN_FID"""")
arcpy.DeleteFeatures_management(in_features="many")
arcpy.AddField_management("many", "FromTo", "TEXT")

calculate field using:

str(sorted([ !TARGET_FID!, !JOIN_FID!]))

Convert points to line:

arcpy.PointsToLine_management("many", "D:/Scratch/lines.shp", Line_Field="FromTo")

RESULT:

Results

2
  • 1
    Nice solution. Worth emphasising that this all works as long as the search radius is big enough to encompass all points.
    – Hornbydd
    Nov 9, 2016 at 23:10
  • The search radius could easily be calculated by first calculating the extent of the dataset.
    – Fezter
    Nov 10, 2016 at 2:17
0

I think the answer from klewis is very helpful:

I think you can do this in two steps. First run "Generate Near Table", selecting Location. Next, run "XY to Line", providing start_x,start_y, near_x,near_y. Generate Near Table requires an Advanced license. – klewis

Your Answer

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

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