def get_subcity(city, nodelist):
    """
    Returns (copied) subgraph of city object, only holding building nodes
    within nodelist building.
    Important: Returned subgraph is copy of (sub)graph!

    Raises assertion error, if nodes in nodelist are not
    building nodes. Does not include network or street nodes.

    Parameters
    ----------
    city : city object
        City object of pycity
    nodelist : list
        List of building node ids, which should be extracted

    Returns
    -------
    subcity : city object
        City object (only including chosen building nodes)
    """
    for node in nodelist:
        assert node in city.nodelist_building
    subcity = city.subgraph(nodelist).copy()
    subcity.environment = city.environment
    subcity.nodelist_building = nodelist
    return subcity
