def calc_center_pos(city, nodelist):
    """
    Calculates center position for nodes in nodelist

    Parameters
    ----------
    city : object
        city object of pycity_calc
    nodelist : list (of ints)
        List of node ids

    Returns
    -------
    pos : tuple
        Position tuple (x, y)
    """

    for node in nodelist:
        assert node in city, ('Node ' + str(node) + 'is not in city!')

    x_sum = 0
    y_sum = 0
    nb_nodes = len(nodelist)

    for id in nodelist:
        node_x = city.nodes[id]['position'].x
        node_y = city.nodes[id]['position'].y

        x_sum += node_x
        y_sum += node_y

    x = x_sum / nb_nodes
    y = y_sum / nb_nodes

    pos = (x, y)

    return pos