The value of g at the surface of the earth is given by the equation g=G\frac{GM}{R^2} and its average value on the surface of the earth is about 9.8 ms^{-2} . But we have to remember that the value of g changes with R and some other factors which we will  discuss below. Even from above equation we can tell that as the body moves above or below the surface of the earth, the value of g changes.

Variation of g above the surface of the Earth

Let us put a body at the height h above the surface of the earth. Now the distance of the object from the center of the earth is (R+h). Therefore the acceleration due to gravity at this point is given by the equation

g_h=\dfrac{GM}{(R+h)^2}

Acceleration due to gravity at the surface of the earth is

g=\dfrac{GM}{R^2}

Dividing these equation we get

\dfrac{g_h}{g} = \dfrac{R^2}{(R+h)^2}

From this we can say that (R+h)^2 will be greater than R^2 and this will lead to a conclusion that g_h < g . Hence acceleration due to gravity decreases as the height increases.

For more approximation lets say that height of body (h) is far far less than radius of earth (R) and using binomial expansion we get

\dfrac{1}{(R+h)^2} = (R+h)^{-2} = \dfrac{1}{R^2} ( 1 - \dfrac{2h}{R} + ... )

Hence we have the final result as

\dfrac{g_h}{g} = ( 1 - \dfrac{2h}{R} )

Variation of g below the surface of the Earth

Let us assume that an object is d depth below the surface of the earth. Then in this condition, the distance of the object from the center of the earth is (R-d). In this situation, the whole mass of the earth will not attract the object. The only mass attracting the object will be the volume of sphere having radius (R-d). If we consider earth as homogenous then the effective mass attracting the object is

M_{eff} = \dfrac{4}{3} \pi (R-d)^3 \rho

Now, acceleration due to gravity below the surface of the earth is

g_d = G \dfrac{M_{eff}}{(R-d)^2} = G \dfrac{\frac{4}{3}\pi (R-d)^3 \rho}{(R-d)^2}

g_d = \dfrac{4}{3} \pi G (R-d) \rho   ….. (1)

Mass of earth is

M_E = \dfrac{4}{3} \pi R^3 \rho

Now, putting the mass of earth in equation g=\frac{GM}{R^2} we get

g = \dfrac{4}{3} \pi G R \rho   ……. (2)

Dividing equation (1) by (2) we get

g_d = g(1 - \dfrac{d}{R})

This expression shows that the value of g decreases as we the depth ‘d’ increases. This shows that as we go deep into the center of the earth, the value of g decreases continuously and at the center of the earth it becomes zero.

So, we find that acceleration due to gravity decreases as we move above or below the surface of the earth. The value of g is maximum at the surface of the earth.

 Variation of g due to rotation of Earth

Due to earth’s rotation, the value of g increased while we move from equator to the poles along the surface of the earth. So, the value of g is maximum at pole and minimum at equation. The relation for this variation is given by

g' = g \sqrt{1 - \dfrac{2 \omega^2 R cos^2 \phi}{g}}

Here \phi is the latitude of the place, R is the radius of the earth and \omega is the angular velocity of earth.

Variation of g due to shape of the Earth

Earth is ellipsoidal and not perfectly spherical. So, it is flatter at pole and has bulge at the equator. The polar radius of earth is 6.357 \times 10^6 m and equatorial radius is 6.378 \times 10^6 m Since acceleration due to gravity is inversely proportional to the radius of the earth, g at pole is greater than that at the equator.