Space filling curve with locality for odd column/row count First of all: I don't have a mathematical background, I'm looking for something I can eventually implement in software.
What I'm looking for is a space filling cure with locality, like the hilbert curve, but one instead that can also handle odd number of rows/pixels. E.g. hilbert curve requires powers of two (2x2, 256x256, etc) and I would like one that also works with 81x81 or 59x59, you get the drift.

I do not have a strong mathematical background neither, but I think that the following trick would work: you have to consider a $59 \times 59$ grid as a multilevel refined grid. Here is an example how to achieve a $5 \times 5$ grid:

Then you put a multilevel hilbert curve (or a multilevel z-curve: see image) on this grid and you have your SFC on an odd column/row count. I know that your grid is regular, but you use the irregular grid (square with different sizes) to do your numbering, and you map this irregular grid to your original grid keeping the same numbering.
