A new nearly continuous model of layered soil-pile interaction (LSPI) is developed in this paper. The surrounding soil is modelled as an axisymmetric continuum and stratified in the vertical direction with consideration of the continuity of adjacent soil layers. The pile is modelled as an elastic cylindrical rod. The Cosine transform method is introduced to obtain theoretical solutions for the dynamic impedance and velocity of the pile head under vertical dynamic load. The reasonability and superiority of the LSPI model are validated by comparisons with previous solutions and field testing results. Dynamic analysis is conducted by a series of practical arithmetic examples, which demonstrate that soil heterogeneity leads to an increase in the number of cut-off frequencies and the dynamic behaviors of piles are more significantly influenced by the upper soil layer. Results obtained provide valuable insight into the dynamic design of piles and the signal analysis of pile integrity tests.