Space-filling curves

One can conveniently scan a finite 2D grid just by going along each successive row in turn. One can scan a quadrant of an infinite grid using the σ function on page 1127, or one can scan a whole grid by for example going in a square spiral that at step t reaches position

(-1)^#({1, -1}(Abs[#^{2} - t] - #) + #^{2} - t- Mod[#, 2])/2 &[Round[Sqrt[t]]]