The precision and stability of spot centroid location were crucial in many fields. According to the edge blurring principle on the optical system, a new algorithm of spot centroid extraction was proposed. The proposed algorithm, based on the arctangent function, can be used to fit the gray distribution of the light spot by variable substitution, and then the centroid of spot can be obtained. In the process of solution, the Gauss-Newton method was adopted to iterate, and then the least square method was used for optimal estimation. Firstly, the advantage and disadvantages of the proposed algorithm between the traditional algorithms were obvious through comparison analysis, and then the feasibility was validated experimentally. The experimental results show that the location precision of the spot centroid is 0.125 3 pixels, and the angle measurement accuracy of the photoelectric sensor is 0.172 3, superior to the sensor's technical requirement 0.25. The robustness of the proposed algorithm to noise, contrast, aspect ratio and size is superior to the traditional algorithms. The experimental results were stable and reliable, and meet the requirement of the angle sensor.