Convert lattice to 1-dimensional array