Global Navigation Satellite Systems (GNSS) provides a novel means for deformation monitoring, which is an important guarantee for structures. Accurately separating its linear and nonlinear signals, and noise in GNSS time series is the foundation for analyzing deformation mechanisms and the prerequisite for assessing the status. However, extracting deformation signals is a challenging obstacle to applying GNSS for deformation monitoring. Aimed at that, a new method is proposed in this study. Fine-tuning the window size and threshold of the Hampel filter through grid search allows for initial anomaly detection and correction. Optimizing the K parameter of the K-Nearest Neighbors (KNN) algorithm via rigorous K-Fold Cross-Validation ensures further smoothing of the filtered data, which overcomes the limitations of the Hampel filter in handling continuous anomalies. Experimental results demonstrate that the proposed method improves performance by approximately 62% compared to traditional methods and by around 40% relative to IQR and other methods. This study presents an effective approach for detecting and eliminating outliers in GNSS deformation monitoring, offering noteworthy theoretical and practical implications.