Skip to main content

I have this Geometry and these Numbers:

I want in my Attributes:

ID | Right | Left | Up | Down

13 | 14 | | | 19

14 | 15 | 13 | | 20

 

How can i get the neighbors?

It seems all the the tiles are equal, so you could take the centroid of each one to create a point geometry. Then you could offset that point to move its X as much as the width of the tile and get the up (positive offset) or the down (negative). Once you have performed the Offset you just have to make a Spatial Relator to see in which tile it has fallen.

For right and left you would take the same centroid and use the Offset transformer to change its Y coordinate using the height of the tile.


Get the coordinates of the centerpoint of each tile (CenterPointExtractor), they'll be stored in a pair of attributes. Since you know how big each tile is you can use VertexCreators to generate new points, based on the centerpoint coordinates, that fall inside the tiles to the right, left, top and bottom. Do a PointOnAreaOverlayers with those points and the tiles, copying the tile number to the points (create new attributes for that) and then merge that all back to the original tiles:

get_tile_numbers.fmw


Here's another possible solution using the NeighborFinder: directional_neighborfinder.fmwt

Comments and explanations inside.


Reply