Canada has an independent electoral commision that sets electoral boundaries, mostly on geographic borders, like county lines. My electoral district, for example, is Leed, the Grenville, the Thousand Islands, and Rideau Lakes and encompases those four geographic districts. It can also be done by a computer using maximum n-sided polygons with equal populations.
As a Canadian I always forget to take the racist factor into account.