0

I am calculating the tile coordinates in a WebMercator projection at different zoom levels and have the following problem:

Cartopy suggests that the projection extent in meters is slightly different in the X and Y direction:

In [67]:     extent_x = ccrs.GOOGLE_MERCATOR.x_limits[1] - ccrs.GOOGLE_MERCATOR.x_limits[0]
   ....:     extent_y = ccrs.GOOGLE_MERCATOR.y_limits[1] - ccrs.GOOGLE_MERCATOR.y_limits[0]
   ....: 

In [68]: extent_x
Out[68]: 40075016.685578488

In [69]: extent_y
Out[69]: 40075016.685578495

In [70]: extent_x - extent_y
Out[70]: -7.4505805969238281e-09

While this reference (see the __init__ and MetersToPixels functions in the script at the end) suggests that extent is equal in both directions:

self.initialResolution = 2 * math.pi * 6378137 / self.tileSize
...
res = self.Resolution( zoom )
px = (mx + self.originShift) / res
py = (my + self.originShift) / res

Which is right? Is the discrepancy in X and Y extent that results from using the cartopy definition merely a floating-point approximation issue or real?

If it is an floating point artifact, is there a way to obtain correct X and Y extents from cartopy?

  • 2
    Web Mercator is a Mercator projection -- distance is not reliable in any dimenson, much less equivalent in X and Y at any location – Vince Apr 4 '16 at 10:35
1

See this image:

image.

As you can see the distance between the latitudes increases in the direction of the poles. So how should the resolution in this direction be equal? A cm at the pole-position in Y-direction is surely much more then a cm at the Equator. To be more precise Web-Mercator (as most Mercator-projections) cannot project the poles at all because they are infinitely far away.

However this does also not apply to the X-resolution as the total length of the full circle at latitude 80 (see north of Greenland for instance) is much smaller than the Equator, isn´t it? Only exception from this rule is the Equator itself where we surely have this equality on resolution in direction of X and that therefore has no further graphical distortion (except from the scale of the map itself).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.