'Calculate the bbox from a given list of Layer objects'

def get_bbox_from_layers(self, layers):

    bbox = None
    for layer in layers:
        layer_bbox = layer.bbox
        if (bbox is None):
            bbox = list(layer_bbox[0:4])
        else:
            bbox[0] = min(bbox[0], layer_bbox[0])
            bbox[1] = max(bbox[1], layer_bbox[1])
            bbox[2] = min(bbox[2], layer_bbox[2])
            bbox[3] = max(bbox[3], layer_bbox[3])
    return bbox
