In the practical application of WSN (wireless sensor network), location information of the sensor nodes has become one of the essential information pieces in the whole network. At present, some localization algorithms use intelligent optimization algorithm to optimize the node group directly. Although the overall localization error is reduced, the location deviation of individual unknown nodes will be larger, and the large number of iterations will cause a large energy consumption of nodes. Aiming at the above problems, this paper comes up with a two-stage WSN localization algorithm based on the degree of K-value collinearity (DC-K) and improved grey wolf optimization. The first stage is aiming at the defects of the existing collinearity algorithm, putting forward the concept of DC-K, according to the K-value to carry out the initial location in the first stage. The second stage is using the improved grey wolf optimization algorithm to optimize the location results which were obtained in the first stage, so as to get more accurate location results. The experimental results display that this localization algorithm with a better localization accuracy has high robustness and has fewer iterations in the optimization process, which greatly reduces the energy consumption of nodes.