[gdal-dev] Mercator_2SP support in GeoTiff

Trent Piepho tpiepho at gmail.com
Sun Nov 3 17:11:45 PST 2013


I'm trying to improve GDAL's support for BSB nautical charts, most of
which use the Mercator_2SP projection.

When converting to GeoTIFF with GDAL, the Mercator_2SP project is
converted into Mercator_1SP without correctly adjusting the
parameters.

For example, my source KAP file has a projection (uninteresting
parameters elided) and center of:
    PROJECTION["Mercator_2SP"],
    PARAMETER["standard_parallel_1",47.667],
    PARAMETER["central_meridian",0],
Center      (-9222211.302, 4063849.585) (122d47'31.25"W, 47d41'15.45"N)

Convert to a GeoTiff, and one gets:
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
Center      (-9222211.302, 4063849.585) ( 82d50'40.32"W, 34d26'23.38"N)

Not the same thing at all!

As I understand it, both the 1SP and 2SP forms are the same projection
and the only difference is how the scale is specified.  In 1SP the
scale at the latitude of origin is specified, while in 2SP a latitude
of true scale, where the scale is 1.0, is specified instead.  Either
of those parameters can be calculated from the other.

It seems that GeoTIFF uses just one coordinate transform key for both
the 1SP and 2SP forms and allows for any or all of the parameters
named ProjNatOriginLatGeoKey,  ProjScaleAtNatOriginGeoKey, and
ProjStdParallel1GeoKey. It also seems that the GeoTIFF spec does not
define how to interpret those parameters.

What GDAL does is ignore ProjStdParallel1GeoKey when reading a geotiff
and not set it when creating one.  A Mercator_2SP projection will get
a default ProjScaleAtNatOriginGeoKey value of 1.0, which of course
changes the projection.

It seems the logical thing to do is use 1SP when only ScaleAtNatOrigin
is specified and to use 2SP when only StdParallel1 is specified.  If
both are specified then it's not clear what to do.  Either the
projection is over specified or the ScaleAtNatOrigin should be
interpreted as the scale at StdParallel1, as opposed to the scale at
NatOriginLat.  The latter would seem to contradict the "at natural
origin" part of ScaleAtNatOrigin and I can't find any reference to
someone wanting to do this.  It seems better to me to consider such a
geotiff to be flawed.

I've made a patch that produces this behavior.  It allows Mercator_2SP
projections to be saved and loaded as GTiffs.

I found a reference to a similar bug in GeoTools and it appears their
fix is the same as mine:
http://jira.codehaus.org/browse/GEOT-2163
http://osgeo-org.1560.x6.nabble.com/svn-r31885-branches-2-5-x-modules-library-coverage-src-main-java-org-geotools-coverage-grid-io-imagef-td4248652.html

After my patch GDAL should be able to inter-operate with GeoTools.  I
can't say about other software, but clearly what GDAL does now is not
correct in any way.


More information about the gdal-dev mailing list