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 magnetization model of geomagnetic field, 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, which can realize the simple and fast detection and positioning of single pipes and row 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. The simulation result of the row pipes shows that the calculation error is calibrated by using the distortion degree of project curve. The validity of the proposed method for cable duct detection is verified by experiments.