Skip to content

Review the Mercator projection #4109

@PaulWessel

Description

@PaulWessel

See the forum for background on this issue. That issues only affects data projections and not mapping. This feature request simply tries to clarify why there are differences and if we need to make any changes. It is not yet clear if this is a bug or a "feature".

Following complaints about the northing values in a Mercator projection when standard parallel other than Equator was used, we made this change to our codes in 6.1:

vmerc (setting up the projection) added a projected y-value for the standard latitude, previously always zero.

GMT->current.proj.j_yc = (fabs (slat) > 0.0) ? GMT->current.proj.j_x * d_log (GMT, tand (45.0 + 0.5 * slat)) : 0.0;

merc_sph (forward projection) subtracts this value from the result, yielding zero northing at the standard latitude:

*y = (fabs (lat) < 90.0) ? GMT->current.proj.j_x * d_log (GMT, tand (45.0 + 0.5 * lat)) - GMT->current.proj.j_yc : copysign (DBL_MAX, lat);

imerc_sph (inverse projection) then adds the northing back in before recovering the latitude:

*lat = atand (sinh ((y + GMT->current.proj.j_yc) * GMT->current.proj.j_ix));

What this does is to say that the projected y-value ("northing") shall be zero at the standard parallel instead of at the Equator.

This is a big part of the forum poster's differences. But it is not all. Reading Snyder on Mercator, he sets up everything for Equator. At the end of the chapter he says other standard parallels can be used, and then one makes the adjustment by multiplying by cos (stlat) and dividing for the inverse. He also says for ellipsoidal equations the scale is cos (stdlat)/sqrt (1 - e^2sin^2(stdlat)). Note for Equator these scales are 1.

In GMT 3(?) we had separate equations for spherical and ellipsoidal mercator, but @WalterHFSmith figured out that if we convert latitude to conformal latitude and use that in the spherical equations, we get the same result. So since at least GMT 4 we no longer have ellipsoidal versions and do it via the auxiliary latitudes required for the projection at hand. However, there are still some differences with Snyder:

  1. We do, and have for a long time, scaled the projection by cos(stdlat), as suggested per Snyder.
  2. We also divide by sqrt (1 - e^2sin^2(stdlat)), which should only happen for the ellipsoidal case.

Because maps are unaffected, and very few people use Mercator for data projection (most use UTM), it is possible that this is slightly wrong and nobody really noticed until the forum post. I see a few things that may be problematic or limiting:

  • Given we use auxiliary latitudes (here, conformal) in the spherical equations, I am not sure about the 1/sqrt (1 - e^2sin^2(stdlat)), but a vague memory says that this is an overall scaling factor needed when using the conformal latitude. This I am sure @WalterHFSmith can set us straight on.
  • Snyder did not discuss a northing adjustment (like ours) so that the projected y-value is zero at the standard latitude; he only added the scale.
  • Our introduction of j_yc above means we cannot obtain Snyder's value for a (lon, lat) point when a standard parallel other than Equator is selected.
  • If the poster tries to insert Equator as his standard parallel then he still cannot recreate the 6.0.0 and earlier results because now the cos(stdlat) is 1.

Perhaps @joa-quim can help sort this out. I know proj supports a standard parallel, but do they set y-out to zero there? If we want to make that an optional thing (the northing shift) then perhaps that should instead be dealt with via -C in mapproject and grdproject?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions