System harmonic impedance is the key parameter of harmonic emission level estimation and responsibility division. The traditional estimation method is usually suitable for the condition that the system impedance is constant and the background harmonic voltage fluctuation is small. However, changes in operation mode, switching impedance and other factors will lead to changes in system impedance, and resonance, harmonic fluctuation and other phenomena will cause a large range of fluctuations in the background harmonic voltage. Therefore, a method for estimating system harmonic impedance based on DBSCAN clustering and data filtering is proposed in this paper. When the system impedance changes, DBSCAN clustering can separate data clusters corresponding to different impedance values. When the background harmonic voltage has a large range of fluctuations, the data filtering is beneficial to retain the data segment with small fluctuation of background harmonic voltage. Finally, robust regression method is used to calculate the harmonic impedance of the system for clustering and filtered data. The simulation results show that the proposed method can suppress the influence of the system impedance variation and the background harmonic voltage fluctuation.