Copy pasting from the original gdal2tiles.py
script:
rx = int((ulx - geotran[0]) / geotran[1] + 0.001)
ry = int((uly - geotran[3]) / geotran[5] + 0.001)
rxsize = max(1, int((lrx - ulx) / geotran[1] + 0.5))
rysize = max(1, int((lry - uly) / geotran[5] + 0.5))
I think this calculates offsets to read from, and the length in x,y to read.
- My doubt is why is 0.001 and 0.5 added to resolution.
- Shouldn't they calculate incorrect offsets and sizes for low pixel resolution images, and especially in geodetic coordinates.
Further edits:
- I think I misunderstood basic
BODMAS
rules, this is a stupid question, and they don't bring significant changes to the calculated values. - Still, I'd love to know some edge cases for which they're there.