Concerning the problem that severe signal multipath effect, low accuracy of sensor node positioning, etc. in narrow space, a new method using Weighted Centroid Localization (WCL) algorithm based on Received Signal Strength Indicator (RSSI) was proposed. The algorithm was used in scenarios with characteristics of long and narrow strip space, and it could dynamically acquire the decline index of path by RSSI and distance of neighbor beacon node signal, improve the environmental adaptation of RSSI distance detection algorithm. In addition, the algorithm based on environment improved weight coefficient of weighted centroid algorithm by introducing correction factor, which improved the accuracy of localization. Theoretical analysis and simulation results show that the algorithm has been optimized to adapt to narrow space. As compared with the Weighted Centroid Localization (WCL) algorithm, in roadway environment with the width of 3 m, 5 m, 8 m, 10 m respectively and 10 beacon nodes, positioning precision increases 22.1%, 19.2%, 16.1% and 16.5% respectively, the stability increases 23.4%, 21.5%, 18.1% and 15.4% respectively.