For a map like that the simplest way would be to have the z set to 5.
The first slot for land or water. That could be set as either a negative or positive number. 1, and greater equals land, less than 1 equals water.
The other 4 slots would be for if it has a tile next to it. Basically the cell at x1,y1, z2 would be the x,y coord subtracting 1 from the current x. Then x1,y1,z3 would be the current y minus 1. Z4 would be current x + 1... etc. And you would just set the value to a 1 or 0 for if something is there or not.
You could even simplify that to have just two z slots by using a counting system.
(x1,y1,z2)'s value might be 1 meaning that there is only one tile next to it, and its position is current x minus 1, or to the left.
(x1,y1,z2)'s value might be 2 meaning that there is only one tile next to it, but its on top.
Basically you just add 1 going around the tile... ehh its simplified, and yet more complicated. Especially when you start having to take into account the fact that the array object is not zero based.