

def process_tile(tile):
    'Process a single MBTiles tile.'
    global base_kwds, src
    (ulx, uly) = mercantile.xy(*mercantile.ul(tile.x, tile.y, tile.z))
    (lrx, lry) = mercantile.xy(*mercantile.ul((tile.x + 1), (tile.y + 1), tile.z))
    kwds = base_kwds.copy()
    kwds['transform'] = from_bounds(ulx, lry, lrx, uly, 256, 256)
    with rasterio.open('/vsimem/tileimg', 'w', **kwds) as tmp:
        for bidx in tmp.indexes:
            reproject(rasterio.band(src, bidx), rasterio.band(tmp, bidx))
    contents = bytearray(virtual_file_to_buffer('/vsimem/tileimg'))
    return (tile, (contents[(- 1):] + contents[:(- 1)]))

dataset/ETHPy150Open mapbox/rio-mbtiles/mbtiles/__init__.py process_tile/original