Apparatus and methods are provided for determining in near realtime the position of a probe placed within a living body. Electric currents are driven between one or more electrodes on the probe and electrodes placed on the body surface. The impedance between the probe and each of the body surface electrodes is measured, and three-dimensional position coordinates of the probe are determined based on the impedance measurements. Dynamic compensation is provided for changing impedance of the body surface and its interface with the electrodes, resulting from such causes as electrode peel-off and changes in moisture and temperature. The compensation improves the accuracy of, inter alia, medical procedures, such as mapping the heart or performing ablation to treat cardiac arrhythmias.