The Spanish goverment uses a value charts to calculate the official value of a poperty, if the real sale price of the property is over this value you will have to pay the taxes according the real sale price, but if the real sale price of the house is lower than the official value you will have to pay the taxes according the official value.
Many cities updated their official value charts when the market was growing in 2006, this is the cause that in the present many times the real sale price is lower than the official value, and after the purchase the goverment ask to the buyer for extra taxes in order to reach the official value.
A good property agent, lawyer or similar can tell you this official values because this is public information given by the goverment, knowing this official value you can calculate how much will cost you the taxes when buying a house, this is a good thing to do before buying.
You can appeal the official value if the goverment ask you for extra tax, somentimes works sometimes not, in many cases this extra taxes are piece of cake.