I have pipe network data (polylines) with missing age and size attributes. For pipe age, I have 10779 pipes with 1034 of them having NODATA values. For pipe size, I have 10779 pipes with 738 of them having NODATA values.
What tool can I use to set the missing values based on the nearest (or connecting) pipe attribute information?
EDIT 1: In my mind, I feel like I could set up something like this pseudo code:
for each pipe if the pipe[age]==NODATA find the pipe_nearest pipe[age] = pipe_nearest[age] if the pipe[size]==NODATA find the pipe_nearest pipe[size] = pipe_nearest[size]
And then it would be all done. I just can't figure out how to determine the polyline nearest the current polyline.
Edit 2: Attempting to use FelixIP's solution. First off, I got access to another copy of the data set with the pipes clearly connected to each other - I have from and to node fields (FNODE_1, and TNODE_1), and the pipes are clearly snapped to each other. I have copied my initial layer twice, creating has_X and Missing_X layers for both age (YEAR_) and diameter (DIAM) information.
Starting with diameter first, I adjusted the script for the names of my own layers, so it reads:
def fillGap (d,fr): mxd = arcpy.mapping.MapDocument("CURRENT") lyr=arcpy.mapping.ListLayers(mxd,"Has_Diam") q='"TNODE_1"=%s%s%s' %(r"'",fr,"'") tbl=arcpy.da.TableToNumPyArray(lyr,"DIAM",q) if len(tbl)==0:return d return tbl fillGap (!DIAM!,!FNODE_1!)
but for some reason I am getting this error on execution:
I am trying to sort it out, but since I don't completely the Python code that is used in calculating the expression, it is proving to be a little difficult.