Abstract The detection and recognition of track geometry are crucial for ensuring railway transportation safety and maintenance efficiency. Traditional linetype recognition algorithms struggle to effectively handle the complexities of variable track geometry and noise interference. To address these challenges, a novel linetype recognition algorithm (NLRA) is proposed, which thoroughly analyzes the characteristics of track curvature across straight lines, transition curves, and circular segments. By employing partial differential equations for data preprocessing, NLRA effectively filters out noise. Utilizing curve design parameters and integrating line anti-noise recognition with multi-segment line fitting techniques, the algorithm accurately identifies each line segment and incorporates a single-point recognition method for data gaps. Experimental results demonstrate that NLRA outperforms traditional algorithms in terms of real-time performance, recognition accuracy, anti-interference capability, and noise handling. Notably, NLRA enhances accuracy by at least 35.1% and recall by at least 17.4% on selected typical routes. This work underscores the algorithm's potential to provide efficient and accurate tools for track maintenance, facilitate advancements in track detection software, and significantly contribute to railway transportation safety.