def tile_bbox(bbox, grid_width):
    min_x = math.floor(bbox[0]/grid_width) * grid_width
    min_y = math.floor(bbox[1]/grid_width) * grid_width
    max_x = math.ceil(bbox[2]/grid_width) * grid_width
    max_y = math.ceil(bbox[3]/grid_width) * grid_width

    x_steps = math.ceil((max_x - min_x) / grid_width)
    y_steps = math.ceil((max_y - min_y) / grid_width)

    for x in xrange(int(x_steps)):
        for y in xrange(int(y_steps)):
            yield (
                min_x + x * grid_width,
                min_y + y * grid_width,
                min_x + (x + 1) * grid_width,
                min_y + (y + 1)* grid_width,
            )
Tile bbox into multiple sub-boxes, each of `grid_width` size.
dataset/ETHPy150Open omniscale/imposm/imposm/geom.py/tile_bbox