I have a Polyline feature class.
For each feature in the Fc...I want the list of all the connecting lines(A table).
For Example For Feature 17686 Connecting Id are : 17688 & 17684.
For Reference :

Asked
Active
Viewed 44 times
1
Rpandia31
- 141
- 6
-
See these links for Select by Location: https://desktop.arcgis.com/en/arcmap/10.3/map/working-with-layers/using-select-by-location.htm and this link for exporting selected records in an attribute table: https://desktop.arcgis.com/en/arcmap/latest/manage-data/geodatabases/export-selected-records-from-a-table.htm – GBG Feb 09 '22 at 23:13
-
I have seen that it is not solving my purpose... – Rpandia31 Feb 09 '22 at 23:40
1 Answers
5
Derive lines end points, delete spatially identical, name points and transfer their attributes to lines table:
Export lines table to 2 identical stand-alone table in GDB, e.g. ABC and CBA and Make Query Table No1:
Repeat to create Query Table No2 and 3, using:
ABC.ton = BCA.fromn
and
ABC.ton = BCA.ton
You'll need to export all query tables and concatenate them. Table below shows all lines connected to line 612, compare it with 1st picture:
This hectic workflow can be replaced by tiny field calculator expression:
import collections
from collections import defaultdict
dF,dT=defaultdict(list),defaultdict(list)
tbl=arcpy.da.TableToNumPyArray("LINKS",("LINKNO" , "fromn" , "ton"))
for i,f,t in tbl:
dF[f]+=[str(i)]; dF[t]+=[str(i)]
dT[t]+=[str(i)]; dT[f]+=[str(i)]
def getConnected(i,f,t):
bigList = set(dF[f]+dT[t])
bigList.remove(str(i))
return ','.join(list(bigList))
#-----
getConnected( !LINKNO!, !fromn! , !ton! )
Use python, I think there is a need for one more query table if there are more than one line going out from FromNode:(
FelixIP
- 22,922
- 3
- 29
- 61




