The detection and calculation of buried depth of urban underground cable pipelines are of great significance to urban safety and planning and construction. However, due to various reasons, the location information of urban underground cables is missing, and there are security risks. Based on the geomagnetic field magnetization model, this paper proposes a method for calculating the position and buried depth of cable ducts, and performs calculation verification and compensation for the common single-pipe laying and row-pipe laying situations of cable ducts. Simple and fast detection and positioning of pipes and pipes. Firstly, the one-dimensional information of the pipeline position is determined according to the coincidence of the geomagnetic direction and the magnetic anomaly direction, and then the position and the buried depth of the pipeline are determined by using the magnetic component signal of the mirror image geomagnetic direction. Calculation error in the case of draining. The validity of this method for cable duct detection is verified by experiments.