Labeling grid cells interface based on oreintation

Viewed 19

I have a grid with cells divided into two regions (pink and blue) by a boundary (grey):

enter image description here

The pandas data frame that I have consists of "row" and "columns" of the boundary cells:

row col
9    1      
9    2      
8    3      
9    4         
8    5
9    5
...
5   14
5   15

Which algorithm can label boundary cell interfaces (thick red and green lines) based on their orientation? I looked into flood fill algorithm but it labels the entire cells in each region regardless of the faces orientation. Ideally the output may look like:

row col NorthFace  SouthFace  WestFace  EastFace
9    1    Front     Back        NA      NA
9    2    Front     Back        NA      NA      
8    3    Front     Back        Left    Right
9    4    Front     Back        NA      NA
8    5    Front     NA          Left    Right
9    5    NA        Back        NA      Right
...
5   14    Front     Back        Left    NA
5   15    Front     Back        NA      NA
0 Answers
Related