Communication and networking plays a crucial role in data transmission in UASN. The sensor nodes in UASN are intermittently deployed randomly in the three‐dimension scenario. As a consequence, the three‐dimension based localization algorithm is the need for an hour. To fulfill the objective, we have proposed a localization algorithm I‐LASP (Improvement of localization algorithm for compensating stratification effect based on extended improved particle swarm optimization technique) in three‐dimensional UASN, based on compensation of stratification effect for the improvement of the performance parameters such as localization accuracy, ranging accuracy, convergence rate and execution time. To compute the accurate position of target nodes, EIPSO (Extended improved PSO) technique is applied, and the degree of coplanarity is checked before the calculation of distance among nodes in order to get the accurate location of target nodes. The Centroid method is used to initialize the position of sensor nodes, and the ray theory method is used to compensate the stratification effect on the layered ocean water. The proposed algorithm is compared to the existing LASP, Std PSO, and GNA‐ESSP (Gauss‐newton algorithm‐extended sound speed profile) localization algorithm. The proposed algorithm provides 34.50%, 38.87%, and 42.66% of high accuracy in terms of localization with low density of target sensor nodes and 37.96%, 29.58%, and 50.77% high accuracy in terms of localization with a high density of target sensor nodes respectively. The proposed algorithm is compared with LASP, GNA‐ESSP, and TDOA to obtain 66.84%, 71.14%, and 86.13% of high accuracy in terms of ranging with low density of target sensor nodes and 42.34%, 89.00%, and 95.08% high accuracy in terms of ranging with a high density of target sensor nodes respectively. Experimental results represents that the proposed algorithm obtains better performance in terms of localization accuracy, ranging accuracy, root mean square error, normalized localization error, execution time and convergence rate.