Custom raster data source + EPSG:3857 causes ~21 km north shift and rendering issues

Hi,

I’m using a custom raster data source / reader in GeoServer. The same data source works fine in several projections, but I’m facing a strange issue specifically with EPSG:3857.

My raster data was originally generated in a Web Mercator variant defined by the following WKT (Google Maps Global Mercator / auxiliary sphere):

PROJCS[“Google Maps Global Mercator”,
GEOGCS[“WGS 1984 Major Auxiliary Sphere”,
DATUM[“Auxiliary Sphere WGS84”,
SPHEROID[“WGS 1984 Major Auxiliary Sphere”, 6378137, 0]],
PRIMEM[“Greenwich”, 0, AUTHORITY[“EPSG”, “8901”]],
UNIT[“Degree”, 0.0174532925199433, AUTHORITY[“EPSG”, “9102”]]],
PROJECTION[“Mercator_2SP”],
PARAMETER[“Standard_Parallel_1”, 0],
PARAMETER[“Central_Meridian”, 0],
PARAMETER[“False_Easting”, 0],
PARAMETER[“False_Northing”, 0],
UNIT[“Metre”, 1, AUTHORITY[“EPSG”, “9001”]],
AUTHORITY[“EPSG”, “3857”]]

GeoServer’s built-in definition for EPSG:3857 is the standard “WGS 84 / Pseudo-Mercator”

PROJCS[“WGS 84 / Pseudo-Mercator”,
GEOGCS[“WGS 84”,
DATUM[“World Geodetic System 1984”,
SPHEROID[“WGS 84”, 6378137.0, 298.257223563, AUTHORITY[“EPSG”,“7030”]],
AUTHORITY[“EPSG”,“6326”]],
PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”,“8901”]],
UNIT[“degree”, 0.017453292519943295],
AXIS[“Geodetic latitude”, NORTH],
AXIS[“Geodetic longitude”, EAST],
AUTHORITY[“EPSG”,“4326”]],
PROJECTION[“Popular Visualisation Pseudo Mercator”, AUTHORITY[“EPSG”,“1024”]],
PARAMETER[“semi_minor”, 6378137.0],
PARAMETER[“latitude_of_origin”, 0.0],
PARAMETER[“central_meridian”, 0.0],
PARAMETER[“scale_factor”, 1.0],
PARAMETER[“false_easting”, 0.0],
PARAMETER[“false_northing”, 0.0],
UNIT[“m”, 1.0],
AXIS[“Easting”, EAST],
AXIS[“Northing”, NORTH],
AUTHORITY[“EPSG”,“3857”]]

What I’m seeing:

  1. Inside the custom raster data source I use my own WKT (Google Maps Global Mercator / auxiliary sphere) as the CRS of the data.
  2. On the client side I request GeoServer with SRS=EPSG:3857.
  3. In this setup, around Turkey latitudes I get an approximate 21 km northward shift, and at some zoom levels I also see rendering artefacts / misalignment.
  4. If I override EPSG:3857 in GeoServer with my WKT, the shift disappears and rendering looks correct

My questions:

  1. Does GeoServer / GeoTools treat these two WKTs (auxiliary sphere Web Mercator vs WGS84 / Pseudo-Mercator) as different CRS, so that an actual transformation chain is applied between them?

  2. What is the recommended / best-practice way to handle this situation?

    • Overriding the EPSG:3857 definition in GeoServer with my WKT,

    • or defining a separate custom CRS for my WKT (e.g. CUSTOM:900913) and explicitly reprojecting from that to EPSG:3857?

  3. Is the observed ~21 km north shift an expected result of transforming between a spherical Web Mercator (auxiliary sphere) and the ellipsoidal WGS84 Pseudo-Mercator in GeoTools?

I’d really appreciate a technical explanation of how GeoServer/GeoTools matches these two projections internally and any guidance on the correct approach to avoid this kind of shift and rendering issues.

Thanks in advance.