In order to improve wireless sensor network localization accuracy, this paper proposed threshold optimization and weighted centroid localization algorithm. Firstly using of the signal transmission model to estimate the distance between unknown nodes and beacon nodes, according to the location information of beacon nodes to select optimal beacon node combination. Then divide the overlapping region formed by beacon nodes in combination, and calculate the centroid and the weight of each region, using the weighted algorithm to locating calculation. Finally, averaging each combination calculate value to obtain positioning result. Simulation results show that compared with the existing algorithms the optimized algorithm has been reduced the localization error and improved accuracy.