The z depth of any given x/y will always be the same as the total depth of the array, even if there is no data in the cells. An empty cell will contain 0 though, so you can make a function loop to check how many cells in that particular row/column are not equal to zero and return the result.