In order to improve the accuracy of magnetic azimuth measurement,it is often necessary to establish a more accurate local geomagnetic model to obtain precise magnetic declination information.Compared with global geomagnetic model, local geomagnetic model contains magnetic anomaly information caused by underground magnetic ore veins at the surface.Considering the different burial depths and sizes of underground magnetic veins,their effects on magnetic declination at different borehole depths differ significantly.Therefore,it is necessary to consider the correction of the azimuth angle of medium and deep wells under the influence of underground magnetic veins.Based on ANSYS Maxwell numerical simulation software,the geomagnetic field model under the influence of magnetic veins of different burial depths and sizes was established.Through numerical simulation method and actual drilled borehole trajectory of a medium?deep well (Z well),a method of azimuth correction was given to quantitatively analyse the influence of underground magnetic veins on the azimuth and borehole trajectory.The results of the study show that the effect of underground magnetic veins on the azimuth of drilling within the 2 000 m thickness stratum is about 0.6° under the condition that the magnetic veins are buried at a depth of 2 100 m.After considering the influence of underground magnetic veins,the borehole trajectory is inevitably offset,and the offset increases with the depth of the well,which may cause off?targeting and other accidents for medium and deep wells.Therefore,it is of great significance to consider that the azimuth correction under the influence of geomagnetic veins can strongly improve the azimuth measurement accuracy and realise accurate guidance.