Atmospheric Refraction is responsible for the bending of light. This is apparent in different observations like inferior mirages, looming or the squeezing of sun and moon at the horizon.
This page presents an analysis of measurements that show that refraction above a certain ground layer has a value that does not vary much at different times and days. This is important to know when surveyors make optical measurements over great distances. Observations above the ground layer are free from big variations in looming and no mirages can occur. We can derive the shape and size of the earth from such observations with good accuracy.
The analysis on this page is based on the work of cinnamoncontrol from his video Flat Earth: Bear Mountain
The bending of light, i.e. the curvature of a light ray is expressed in the refraction coefficient k, which is defined as the ratio of the radius of the earth to the radius of curvature of the light ray:
(1) 

Per Definition  
where^{'} 

Light slows down as it passes through a transparent medium. The index of refraction determines the speed of light in the medium: v = c / n, where v is the speed of light in the medium, c = 300,000km/s is the speed of light in vacuum and n is the index of refraction that depends on the medium and its density.
If the density is not isotropic in a medium like the air, light gets bent in arcs. The amount of refraction, i.e. the bending of light, depends on the Refractivity Gradient. The Refractivity Gradient in the atmosphere is the change of the index of refraction with altitude.
The index of refraction n is proportional to the density of the air, which can be derived via the ideal gas law from pressure, temperature, humidity and CO2 concentration for a light ray of a certain wavelength. This connection between index of refraction, wavelength and atmospheric parameters is expressed in the empirically derived Ciddor equation, see Calculator for Refractivity based on Ciddor Equation.
For an accuracy of less than 5% we can ignore humidity and CO2 concentration, as can be explored with the Calculator for Refractivity based on Ciddor Equation. Applying Fermat's principle, using the Ciddor equation and applying Calculus we can derive an equation for the refraction coefficient as a function of pressure, absolute temperature and the temperaure gradient, see Deriving Equations for Atmospheric Refraction:
(2) 
 
where^{'} 

The most influence on k and hence on the bending of light has the temperature gradient. By measuring this atmospheric parameters along a line of sight we can calculate the bending of light and correct optical measurements accordingly. But this is only feasible when refraction does not vary much and is not too strong.
The air has a layer above the ground where the heat exchange between the ground and the air is taking place. Above this layer the air is well mixed and the temperature gradient and hence refraction is always near a standard value, which reduces slowly with altitude. But in the ground layer the temperature gradient can divert considerably from standard refraction and bend light up and down in relatively small radii compared to the radius of the earth. This causes all sorts of optical effects like mirages and strong looming.
Lets see how refraction behaves above this ground layer.
To analyze how refraction behaves depending on altitude we need atmospheric data over long periods and many altitudes.
The National Centers for Environmental Information provides such data on the link Integrated Global Radiosonde Archive (IGRA). IGRA consists of radiosonde and pilot balloon observations at over 2,700 globally distributed stations.
The Data is collected in ASCII files that contain measurements from many days. A plot of the data from one single balloon launch looks like this:
We can now use the Ciddor equation to calculate the index of refraction (right field below) from pressure, temperature and humidity for each altitude:
We can already see that the index of refraction above the ground layer is decreasing linearly with altitude, while near the ground it deviates exponentially.
We know that the bending of light does not depend on the magnitude of the index of refraction, but on the index of refraction gradient. The curvature of a light ray at a certain altitude is proportial to the slope of the index of refraction line in the graph. So if we calculate the slope for each altitude and plot this slope, we can directly see how strong refraction is.
Now we want to do that not only for a single day, but for say 2 years, so we can get an image of the average refraction over many days.
Each blue dot represents the refractivity gradient and refraction coefficient for a certain day and altitude measurement. We can see that above the ground layer all dots lie on a narrow range, while in the ground layer very near the ground the values divert considerably. This is consistent with observations, which show little refraction effects above the ground layer but often strong refraction effects near the surface.
Because the index of refraction is always very near the value of 1, it is easier to use refractivity, which is defined as follows. So we get the plot above for the refractivity gradient, i.e. the change in refractivity per meter, which is proportional to the curvature of a light ray
(3) 
 
(4) 
 
where^{'} 

The refraction coefficient k is proportional to the negative refractivity gradient dN/dh:
(5) 

where R = 6371 km ≈ 6.4 × 10^{6} m is the radius of the earth.
All points for the refractivity gradient above the ground layer lie near a line, which represents standard refraction. The value of the standard refraction for the plot above is about k = 0.16, which decreases slightly with altitude.
If we know the Refraction Coefficient, height measurements using a theodolite can be corrected with the following approximation equations, as long as the distance d is much less than the radius of curvature of the light ray:
(6) 
 
see 
Refraction Angle and Lift (Rainy Lake Experiment: Equations)  
where^{'} 

A positive Refraction Angle means the light ray is bent down and the object appears too high. In a zenith angle measurement we have to add the Refraction Angle to the zenith angle to get the correct angle as measured without refraction.
From the Refraction Angle we can calculate the magnitude l of how much an object at distance d appears to be raised due to Refraction:
(7) 
 
where^{'} 

As Refraction Angles in radian are numbers much less than 1, this equations are very good approximations. The distance d can be the line of sight distance or the distance along the light ray or the distance along the surface of the earth. They are all essentially the same as long as d is much smaller than R.