Rail impedance directly affects the transmission performance of track circuit . Considering the condition of earth stratification, for the difficult to calculate the rail impedance due to the semi-infinite integration interval and the oscillation of the integrand by using the Carson formula, The truncation method is proposed to divide the impedance formula is divided into definite integral and tail integral. The integral is approximated by the spline function, and the tail integral is calculated by using the exponential integral and Euler formula. Based on it, the rail impedance calculation formula of track circuit is obtained. The electromagnetic field model of track circuit with earth stratification is simulated by finite element method, and the correctness of the method is verified. Based on the formula, the influence of current frequency, soil depth and conductivity on rail impedance is studied. The relative error between the calculated results of rail impedance and the simulation results of finite element is within 5%. It can be seen that the formula has high accuracy and correctly reflects the law of rail impedance variation with current frequency, soil depth and resistivity. It provides a reliable reference for the theoretical calculation of rail impedance of track circuit.