def render(fmt, width, height, bbox, srs, styles, layers, **kwargs):

    if srs.lower().startswith('epsg'):
        if srs.endswith("900913") or srs.endswith("3857"):
            srs = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null"
        else:
            srs = "+init=" + srs.lower()

    name = prepare_wms(layers, srs, styles, **kwargs)
    filename = "{name}.{bbox}.{width}x{height}.{fmt}".format(
        name=name,
        bbox='_'.join(str(b) for b in bbox),
        width=width,
        height=height,
        fmt=fmt
    )

    while os.path.exists(name + ".lock"):
        time.sleep(0.05)
    m = mapnik.Map(width, height)
    mapnik.load_map(m, name + '.xml')
    m.zoom_to_box(mapnik.Box2d(*bbox))
    mapnik.render_to_file(m, filename, fmt)

    with open(filename) as tiledata:
        tile = buffer(tiledata.read())
    os.unlink(filename)

    return filename, tile



### following procedures and functions are in support of the tiled mapping services, TMS
estimating the correct rescaling transform is slow, so just use the
dataset/ETHPy150Open hydroshare/hydroshare2/ga_resources/drivers/__init__.py/render--crossover with--dataset/ETHPy150Open benanne/kaggle-ndsb/data.py/build_rescale_transform_fast