In this paper, aiming at the problem of sun shadow localization, by analyzing and calculating the parameters affecting the shadow length of the object, the rod length optimization model based on multi-parameter hierarchical search is established with the aim of inversion of the rod length, and the MATLAB simulation is used to realize the sun shadow positioning technology. Firstly, a straight-line shadow length variation model based on the change of solar height angle is established, and the relationship between the straight shadow length and the declination angle and the time angle is obtained. Secondly, the control variable is used to analyze the length of the straight rod. Using the method of control variable to analyze the variation rule of longitude, latitude, measurement date and... measurement time and the curve of the straight shadow length from 9:00 to 15:00 (Beijing time), it is found that the shadow length decreases first and then increases at 11:45. The minimum value obtained is about 2.1. Finally, the model is tested by the actual measurement method, the error of the model result relative to the actual measured value is about 1.732%, and the model has higher precision. For the shadow localization problem, the relationship between the straight shadow length and the shadow vertex coordinate value is obtained through the geometric relationship. For the case where the straight rod location is unknown, this paper applies the long length of the shadow length and the solar elevation angle inversion at the same place. Based on the principle of the parameter, the pole length optimization model based on parameter hierarchical search is established, and the range of the poles in the same group is approximated to zero. The MATLAB is used to perform rough search and fine search on the longitude and latitude. The feasible longitude and latitude values are (108.4566˚E, 19.2771˚N) and (103.1670˚E, 3.2552˚S). The first group of latitude and longitude corresponds to the offshore area of Hainan Province, and its longitude and longitude error of Hainan Province is 1.256%. Therefore, the first location is designated as Hainan Province within the error tolerance. The second group of latitude and longitude corresponds to Indonesia.