0

Have noticed a great number of libraries that calculate the bounds for a tile like so:

def TileBounds(self, tx, ty, zoom):
    "Returns bounds of the given tile in EPSG:900913 coordinates"
    
    minx, miny = self.PixelsToMeters( tx*self.tileSize, ty*self.tileSize, zoom )
    maxx, maxy = self.PixelsToMeters( (tx+1)*self.tileSize, (ty+1)*self.tileSize, zoom )
    return ( minx, miny, maxx, maxy )

source: https://docs.maptiler.com/google-maps-coordinates-tile-bounds-projection/#3/50.00/15.00

Why is the tx+1/ty+1 is used in the calculation?

I'm perplexed as it means that the bottom and right border overlap with the neighboring tile. In short the bounds that is returned is slightly too big.

4
  • 1
    I do not believe that the formula gives overlaps. Earlier in the code I can see tx = int( math.ceil( px / float(self.tileSize) ) - 1 ). I think that +1 is there for compensating -1. Commented Oct 11, 2024 at 6:25
  • It does in fact give an overlap, take for example the following: mercator = GlobalMercator() bounds = mercator.TileLatLonBounds( 5, 5, 13) print print "\tEPSG:900913 Extent: ", bounds bounds = mercator.TileLatLonBounds( 5, 6, 13) print print "\tEPSG:900913 Extent: ", bounds You'll notice the max of the first tile is the min for the second, they do in fact overlap. Commented Oct 11, 2024 at 7:55
  • 2
    "the max of the first tile is the min for the second, they do in fact overlap" - where is the overlap? They do share a common boundary, but not common area. Commented Oct 11, 2024 at 13:04
  • @JohnD No, they don't overlap, they touch. It's like tiles in a bathroom (if you ignore the grout for the sake of the analogy) or floorboards, one starts where the other finishes, but none are on top of the neighbors. Commented Oct 12, 2024 at 13:25

1 Answer 1

0

That's how polygons work in GIS. The edge of one tile is on top of the next one. Otherwise the program needs to worry about pixel sizes and a bunch of other stuff that would just be complicated and time consuming to keep track of.

2
  • Thank you, is that just a generally understood principle or is there an RFC somewhere I could read about? It's confusing for me because I noticed that I had a function that would get the tile coverage of a certain polygon. But if I took a tile, got it's bounds, and passed it into that function I didn't receive the original input but additional tiles. It seems many of the libraries have a sort of buffer concept you can use to mitigate this issue but not that apparent for GIS newbiews. Commented Oct 11, 2024 at 6:50
  • Mostly it's set out in the OGC simple feature spec, basically the exterior ring of a polygon is not inside the polygon, this most often causes problems when intersecting polygons as you usually end up with all the touching polygons. Commented Oct 11, 2024 at 9:03

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.