By using square field terrain correction method and MATLAB language, large scale gravity median and far region terrain correction have been edited. This program can make it possble for computer to realize the gravity median and far region terrain correction which had to be completed by manual in the past. It can not only reduce the intensity of terrain correction, but also improve the working accuracy and efficiency.