pos is an attribute of lat; if we try something like
we should get [1.0,2.0] as an answer. So an atom with index (1,2) lives at the "real-space coordinates" (1,2). (this seems trivial, but it gets different when you do the same for a lattice other than a square one).
If we play a bit with your onsite function:
we see the output 0 and -1, and is precisely what we want. Next step is defining a wire, say 40 atoms long and 10 wide, and assign the on site energies on all the atoms using the function "onsite". The way to do it in kwant is by:
sys[(lat(x, y) for x in range(40) for y in range(10))] = onsite
which assigns the function "onsite" to all on site energies at sites 0<=x<40 and 0<=y<10. At this point, nothing happened much. If we ask python to
it will tell us something like "<function onsite at 0x7ff91e80f050>". In order to actually get all the on site energies and hoppings assigned, is to finalize the system with sys.finalized. kwant will then figure out what all the on site energies and all the hoppings are supposed to be by passing all the lat(x,y)s to the onsite function.