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 : extent_x = ccrs.GOOGLE_MERCATOR.x_limits - ccrs.GOOGLE_MERCATOR.x_limits ....: extent_y = ccrs.GOOGLE_MERCATOR.y_limits - ccrs.GOOGLE_MERCATOR.y_limits ....: In : extent_x Out: 40075016.685578488 In : extent_y Out: 40075016.685578495 In : extent_x - extent_y Out: -7.4505805969238281e-09
While this reference (see the
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?