I have an ArcMap document with 100 locations plotted using their latitude and longitude values. I want to show connections between the 100 points in the graph. Essentially 100*100 = 10,000 lines. Is there a way to construct a graph showing these connections using ArcMap?
One solution (and a great chance to implement
itertools) would be:
import arcpy, os, itertools infc = r"C:\MyFolder\MyGDB\MyInputFeatureClass" # Replace with the path to your input feature class outfc = r"C:\MyFolder\MyGDB\MyOutputFeatureClass" # Replace with the path to your output feature class spatialref = arcpy.Describe(infc).spatialReference if not arcpy.Exists(outfc): arcpy.CreateFeatureclass_management(os.path.dirname(outfc), os.path.basename(outfc), "POLYLINE", "", "", "", spatialref) points = [arcpy.Point(row, row) for row in arcpy.da.SearchCursor(infc, "SHAPE@XY")] with arcpy.da.InsertCursor(outfc, "SHAPE@") as cursor: for combination in itertools.combinations(points, 2): line = arcpy.Polyline(arcpy.Array(combination)) cursor.insertRow((line,))
Make sure the path you copy-and-paste from ArcCatalog/Windows explorer is in a raw string
r"". And the input has a coordinate system defined, or define one using Define Projection.