The grounding grid is a key part of substation protection, which provides safety to personnel and equipment under normal as well as fault conditions. Currently, the topology of a grounding grid is determined by assuming that its orientation is parallel to the plane of earth. However, in practical scenarios, the assumed orientation may not coincide with the actual orientation of the grounding grid. Hence, currently employed methods for topology detection fails to produce the desired results. Therefore, accurate detection of grounding grid orientation is mandatory for measuring its topology accurately. In this paper, we propose a derivative method for orientation detection of grounding grid in high voltage substations. The proposed method is applicable to both equally and unequally spaced grounding grids. Furthermore, our method can also determine the orientation of grounding grid in the challenging case when a diagonal branch is present in the mesh. The proposed method is based on the fact that the distribution of magnetic flux density is perpendicular to the surface of the earth when a current is injected into the grid through a vertical conductor. Taking the third order derivative of the magnetic flux density, the main peak coinciding with the position of underground conductor is accurately obtained. Thus, the main peak describes the orientation of buried conductor of grounding grid. Simulations are performed using Comsol Multiphysics 5.0 to demonstrate the accuracy of the proposed method. Our results demonstrate that the proposed method calculate the orientation of grounding grid with high accuracy. We also investigate the effect of varying critical parameters of our method.