1

I have a dataset of points and I would like to make lines connecting each point with all the other points of the dataset.

It is similar to Creating all possible line segments between all points using QGIS but I want to do it in ArcMap.

Is this possible?

2
  • 4
    Of course it's possible. What have you tried, and what problem did you encounter?
    – Vince
    Oct 20 '20 at 11:28
  • 1
    About 200 points. So basically the question is if there is already such tool available in ArcMap. Otherwise I can spend more time to do it manually with ArcPy (I guess by using multiple times the POINTS TO LINE tool)
    – GeoF
    Oct 20 '20 at 11:35
6

I dont know of such a tool.

You can use arcpy with itertools.combinations:

import arcpy
from itertools import combinations
   
pointfc = r'C:\GIS\ArcMap_default_folder\Default.gdb\samplepoints'
coordinates = [xy[0] for xy in arcpy.da.SearchCursor(pointfc,'SHAPE@XY')] #List all point coordinates

arcpy.CreateFeatureclass_management(out_path='in_memory', out_name='lines', geometry_type='POLYLINE', spatial_reference=pointfc)
icur = arcpy.da.InsertCursor(r'in_memory\lines','SHAPE@')

sr = arcpy.Describe(pointfc).spatialReference
for p1, p2 in combinations(coordinates, 2):
    newline = arcpy.Polyline(arcpy.Array([arcpy.Point(*p1), arcpy.Point(*p2)]), sr)
    icur.insertRow([newline])
del(icur)

enter image description here

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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