A strategic reason (e.g. getting a resource) may be a good reason to settle on a bonus even if you lose it. Probably you can settle next to it though. You lose food bonuses. Commerce bonuses are kept (I'll ignore despotism). For shield bonuses in the most significant situation, a town on a 1-shield square (e.g. a BG), the shield is lost since there's a 1-shield minimum anyways. Otherwise the shield bonus is kept.
Hm, I hadn't noticed this list had omitted anarchy before
Food :
• basic value : 2
• if civ = agricultural : +1
Shields :
• basic value : this of terrain
• if city size = city : +1
• if city size = metropolis : +3 if civ = industrious, +2 otherwise
• if no shield so far : +1
• if golden age = on : +1
• if mobilisation = on & city production = military unit : +1
Commerce :
• basic value : this of terrain, river bonus applying
• if city size = village : +1
• if city size = city : +4 if civ = commercial, +2 otherwise
• if city size = metropolis : +6 if civ = commercial, +3 otherwise
• if city = capital : at least 4
• if civ = seafaring & city = coastal : +1
• if government = republic/democracy : +1
• if golden age = on : +1
To all three :
if government = despotism or anarchy, for shields and commerce, and for food if city not by fresh water : -1 if value > 2