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 :
-
See these links for Select by Location: desktop.arcgis.com/en/arcmap/10.3/map/working-with-layers/… and this link for exporting selected records in an attribute table: desktop.arcgis.com/en/arcmap/latest/manage-data/geodatabases/…– GBGCommented Feb 9, 2022 at 23:13
-
I have seen that it is not solving my purpose...– Rpandia31Commented Feb 9, 2022 at 23:40
1 Answer
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:(