The TGF software (2019)

The terrain gravity field (TGF) is a new MATLAB-based software suitable for calculations of gravity forward modelling in the spatial domain. It is capable of calculating 1) various gravity field functionals, generated by some arbitrary-shaped 3D geometries together with mass-density distributions, in 2) different spectral band-widths, including high-frequency gravity modelling (also known as residual terrain modelling or RTM) and full-banded modelling where a full topographic mass-model is used as input, 3) through a combination of four different types of elementary mass-elements, i.e., polyhedron, prism, tesseroid and point masses. The TGF works in two modes, in interactive mode with GUI interface and in batch mode without the GUI interface which allows rather easy modification and adaption of the code for scientific studies.

Structure of the software

As shown in Fig. 1, the interface of the TGF software is divided into four modules depending on various functions, i.e., the input of computation points, definition of the mass distributions, specification to the functionals and computation zones, and output files.

The computation point information is located and read by pressing the pushbutton ‘Computation Point’ in the panel of ’Computation Points’. The computation file is defined in binary format with vector for  - number of points, latitude, longitude and height respectively.

The ’Forward Mass’ module specifies the input file to define the topographic masses, via the geometric upper and lower boundaries and density values. The detailed DEMs (pushbuttons – ‘DetailedDEM’ and ‘DetailedREF’) define geometric boundaries of masses in the vicinity of computation point, which are approximated by polyhedron and prism. DEMs loaded via the pushbuttons -- ’TESSDEM’ and ’TESSREF’ -- define the far zone masses which are modelled by tesseroid.  ‘CoarseDEM’ and ‘CoarseREF’ specify the coarse DEMs which are required for point-mass modeling. When working with a model of spatially-varying mass-densities, three 2D horizontal density grids are required for respective integration zones. Elevation and density data are in binary format of vector ‘[minphi manphi resphi minlam maxlam reslam elevation]’, minimum, maximum and resolution of DEM grid in latitude and longitude directions.

The module ‘Gravitational Field’ defines parameters (Tab. 1) which specify the type of gravity functionals, integration zones and earth approximation type.

The ‘Output’ module allows to define the output file and to convert file in grid format to binary file. In the bottom right corner, the status of the calculation will be shown in blue texts. 

RTM test over Zugspitze area

Our TGF software was applied for regional RTM gravity field calculations over a test area located in the Zugspitze of German Alps bounded by longitude between 10.95 and 11.25, and latitude between 47.35 and 47.5. Using MERIT DEM and MERIT SHCs 2160 respectively representing the Earth’s surface and the smooth reference surface, the gravity potential and its first and second derivatives were calculated at computation points located on the MERIT DEM surface and arranged in terms of a 1’’ resolution grid.  RTM heights and implied gravity field are displayed in Figs. 2-4. All computations use a constant density of 2.67 g/cm3 and spherical approximation.

Software download

Developed by Meng Yang under supervision of Christian Hirt.


M. Yang, C. Hirt, R. Pail (2019) TGF: A New MATLAB-based Software for Terrain  Gravity Field Calculation.  Comput. Geosci., under review.

Please consider citing it in your publications if you use it for your research.


D. Tsoulis (2012) Analytical computation of the full gravity tensor of a homogeneous artitrarily shaped polyhedral source using line integral. Geophysics 77(2), F1-F11.

D. Nagy, G. Papp, J. Benedek (2000) The gravitational potential and its derivatives for prism. Journal of Geodesy 74, 552-560.

D. Nagy, G. Papp, J. Benedek (2002) Corrections to "The gravitational potential and its derivatives for prism". Journal of Geodesy 76, 475-475.

T. Grombein, K. Seitz, B. Heck (2013) Optimized formulas for the gravitational field of a tesseroid. Journal of Geodesy 87(7), 645-660.

X.L. Deng, T. Grombein, W.B. Shen, B. Heck, K. Seitz (2016) Corrections to “A comparison of the tesseroid, prism and point-mass approaches for mass reductions in gravity field modelling” (Heck and Seitz, 2007) and “Optimized formulas for the gravitational field of a tesseroid” (Grombein et al., 2013). Journal of Geodesy 90, 585-587.

M. Yang, C. Hirt, R. Tenzer, R. Pail (2018) Experiences with the use of mass-density maps in residual gravity forward modelling. Stud. Geophys. Geod., 62.

M. Yang, C. Hirt, M. Rexer, R. Pail, D.  Yamazaki (2019) The tree canopy effect in gravity forward modelling. Geophys. J. Int., 219 (1),

M. Yang, C. Hirt, R. Pail (2019) TGF: A New MATLAB-based Software for Terrain Gravity Field Calculation. Comput. Geosci., under review.

Getting help

Write an e-mail to Meng Yang via or It would be better if you would like to submit a bug report/feature request/question to the Github project


The TGF is research-only software. Neither TU Munich nor any of its staff accept any liability in connection with the use of the software, data and models provided here. Neither TU Munich nor any of its staff make any warranty of correctness, fitness, completeness, usefulness and accuracy of the software, data and models for any intended or unintended purpose.