Analyzing the behavioral patterns of agricultural machinery based on the spatiotemporal information embedded in massive trajectory data, segmenting trajectory points into a series of field segments and road segments, and assigning corresponding semantic labels are crucial preliminary tasks for subsequent research on agricultural machinery trajectories. Currently, density-based clustering algorithms struggle to effectively differentiate clusters with weak connections, often identifying two weakly connected clusters as a whole. To overcome these limitations, a clustering algorithm based on local direction centrality measurement and spatial distance feature (CLDCM-SDF) is designed, which uses a clustering mechanism based on a local direction centrality measurement (CLDCM) to separate weakly connected clusters. To further improve the model’s recognition performance, a cluster boundary resetting strategy based on a spatial distance feature (SDF) is proposed, which resets points at the cluster boundary according to the spatial distances between points and the distribution of the number of other points within their neighborhoods, thereby enhancing recognition performance at the cluster boundary. To validate the effectiveness of the proposed method, experiments are conducted on a total of 470 agricultural machinery trajectory samples from three real harvester trajectory datasets provided by the Key Laboratory of Agricultural Machinery Monitoring and Big Data Applications, Ministry of Agriculture and Rural Affairs, People’s Republic of China. The results show that the proposed method has improved the average F1-score on the corn, wheat, and paddy harvester trajectory datasets by 12.82, 24.09, and 14.38 percentage points, respectively, compared to the state-of-the-art (SOTA) methods used in existing clustering algorithms when applied to field-road classification. © 2024 Journal of Computer Engineering and Applications Beijing Co., Ltd.; Science Press. All rights reserved.