def split_area(bbox, pixel_width, max_size):
    """
    Splits a square polygon in smaller squares.

    Arguments:
    -----------
    bbox: list
        list of coordinates (lon, lat) of the 4 bounding box summits - must be in
        the order: [[x_min, y_max],[x_max, y_max],[x_max, y_min],[x_min, y_min]]
    pixel_width: int
        width of the bbox, in pixels
    max_size: int
        maximum authorized pixel width

    Returns:
    -----------
    small_boxes: list
        list of smaller boxes (with coordinates in the same format as the original)
    """    
    
    # get coordinates of the original bbox     
    x_min = bbox[0][0]
    y_max = bbox[0][1]
    x_max = bbox[2][0]
    y_min = bbox[2][1]

    # compute size of each small box
    small_boxes = []
    nb_breaks = int(pixel_width // max_size)
    x_step = (x_max - x_min) / (nb_breaks+1)
    y_step = (y_max - y_min) / (nb_breaks+1)

    # compute coordinates of each small box
    for i in range(nb_breaks+1):
        x_min_i = x_min + i*x_step
        x_max_i = x_max - (nb_breaks-i)*x_step
        for j in range(nb_breaks+1):
            y_min_i = y_min + j*y_step
            y_max_i = y_max - (nb_breaks-j)*y_step
            box_i = [[x_min_i, y_max_i],[x_max_i, y_max_i],[x_max_i, y_min_i],[x_min_i, y_min_i]]
            small_boxes.append(box_i)
    
    return small_boxes