I'm currently reading documentation about map projections to understand the source code of the Proj4 project.
The scale factor is named in a variety of sources I read. This sources explained its definition and its value for some projections.
In the source code of Proj4, for the mercator projection (sphere and ellipse case), the scale factor influences the coordinates on the projection :
//P->k0 is the scale factor
xy.x = P->k0 * lp.lam;
xy.y = - P->k0 * log(pj_tsfn(lp.phi, sin(lp.phi), P->e));
Why and how I should use the scale factor during the computation of the projection ? Is there any valuable resources on the web ?
This question in asked in the sense of projection computation. I can find the formula for the inverse and forward projection as well as the scale factor in a various of resources, but no one explains how I should use both in a algorithm. You have the definition of the projection and the definition of the scale factor, but it's not clearly written that I should multiply or divide the result by the scale factor.
Is it a general rule : if I find the formula for any projection with the related scale factor, should I, in all cases, always divide or multiply the results by the scale factor ?
Unfortunately, the term "scale factor" is ambiguous. In cartography, maps and projections, the concept and application of scale is of fundamental importance. By definition, it is a factor – meaning it is something to multiply or divide – so whether "scale" or "factor" is the adjective the particular word pairing has no obvious meaning, except in a particular context:
The map or globe scale is a ratio of distance on map or globe to corresponding distance on the ground or reality. Either it has no units or its units reflect the map and ground units – miles per inch, km per cm, etc. It is variously called scale, map scale, principal scale, representational fraction, or nominal scale. I like that last one, nominal scale, because most maps have a single statement of its scale. Sadly, it is sometimes also called scale factor.
All map projections distort linear scale, all over the map. This distortion is almost always termed scale factor (and sometimes "projection scale factor" or "point scale factor"). At any point on the map, it is the ratio of the "true" (undistorted) scale and the "nominal" (distorted) scale. In other words, it is the ratio of the true ground distance to the implied distance on the map.
When computing a map projection, that is
(X, Y) ← projection (λ, φ)
you need to have some constant which depends on the size of your region of interest, the size of your map, and the map units involved. That constant is our friend the nominal scale. Since you don't provide the full code, and it's a little cryptic, I cannot say for certain, but I suspect that is what is meant by "scale factor" in your particular problem.
According to Mathematics_of_the_Mercator_projection on wiki, the spherical case, which uses radius, R, as a substitute for scale:
X = R λ
Y = R ln [tan (π/4 + φ/2)]
(That looks similar to your code.)
How is radius a substitute for scale? Simple. It is the constant which determines the size of the map: a larger globe yields a larger map. If R is the Earth's radius, then your map scale will be one-to-one. If R is the radius of your globe in, say, mm, inches, or pixels, then X,Y will be in those same units and the map's nominal scale, NS, will be the ratio of your globe's radius to the Earth's radius:
NS = globe radius / Earth radius
To get ground distances from a measurement on a projected map, including any distortions:
ground distance = map distance / NS
To remove distortion, see below.
To properly correct distortion at any point on a projected map, you ought to be able to calculate the distortion, SF (scale factor):
SF ← distortion (λ, φ)
In this case, SF has to be calculated, or provided in a look-up table, wherever it is needed. Does your code calculate "scale factor" as a function of "lam" and "phi"? I doubt it.
According to Mathematics_of_the_Mercator_projection on wiki, which uses K for scale factor:
Spherical case: K = sec φ
Ellipsoidal case: K = sec φ sqrt(1 - e2 sin2 φ)
where e2 is about 0.006 for all reference ellipsoids.
To correct for any projection distortion, i.e., to convert a projected map distance to get true (undistorted) globe distance, always divide by the scale factor, SF:
ground distance = map distance / SF
That might look familiar.
Yes, they're used in exactly the same way. However, whenever the Earth is really projected onto a map that is actually measured in terms of map units (mm, cm, inches, pixels, etc.), then you need to apply both
- a global nominal scale to get the correct globe/earth magnitude and units, and
- a local scale factor to correct for projection distortion at any particular Earth position.
If you are not making measurement on an actual map, and you are just using coordinates that are in the same units as your Earth radius, R, then your nominal scale is trivial (NS = 1) and you only need to use the scale factor.