I have an example data frame below:
data = [
[1, 2, 100, 4342],
[3, 4, 100, 999],
[5, 6, 500, 4339],
[4, 5, 300, 999],
[12, 13, 100, 4390],
[6, 7, 600, 4335],
[2, 3, 200, 4341],
[10,11, 100, 4400],
[11,12, 200, 999],
[7, 8, 200, 4332]
]
df = pd.DataFrame(data, columns = ['Node','Dwn_Node', 'Dwn_Length','Elevation'])
df = df.replace(999, np.nan)
Where the Node
column describes the name of the current node and Dwn_Node
describes the name of the node 'down stream'. Elevation
describes the elevation of the current node and Dwn_Length
describes the length to the 'down stream' node. I am really not sure of the best way to complete this, but the goal would be to interpolate the missing values using slope. I am thinking there might be a function or better capability in networkx but am very unfamiliar with that library.
The above data set is an example data set but is accurate in that the node order is out of place.
One way I thought of would be to separate the previous and subsequent nodes of the unknown nodes i.e.
data1 = [
[12, 13, 100, 4390],
[10,11, 100, 4400],
[11,12, 200, 999]
]
Calculate slope from data1
by taking the sum of Dwn_Length
of nodes 10 and 11 under the difference in elevation values of node 10 and 12 then apply that slope to interpolate the elevation of node 11 given the Dwn_Length
of node 10. This seems very tedious for a data set that has many sets of missing node values within a network though.