def get_xr_crs(ds):
    """
    Read dataset and get crs from attributes. If attributes don't 
    exist, thrown an error.

    Parameters
    ----------
    ds: xarray dataset, dataarray
        A single xarray dataset with variables and x and y dims.

    Returns
    ----------
    crs : int
        A int containing the crs of xarray dataset.
    """

    # raw arcgis albers proj info
    albers_proj = ('+proj=aea +lat_1=-18 +lat_2=-36 +lat_0=0 +' +
                   'lon_0=132 +x_0=0 +y_0=0 +ellps=GRS80 ' +
                   '+towgs84=0,0,0,0,0,0,0 +units=m +no_defs=True')

    # when crs attribute is a string
    if isinstance(ds.crs, str):

        # approach 1
        if ds.crs.startswith('EPSG:'):
            return int(ds.crs.split(':')[1])

        # approach 2
        if hasattr(ds, 'geobox'):
            return int(ds.geobox.crs.epsg)

        # approach 3
        if ds.crs == albers_proj:
            return 3577
            
        # approach 4
        if '+init=epsg:' in ds.crs:
            return int(ds.crs.split(':')[-1])
        
    # when a iterable...
    if isinstance(ds.crs, (tuple, list)):
        
        # approach 1
        return int(''.join(e for e in ds.crs if e.isdigit()))

    # error if we get here...
    raise ValueError('Could not extract crs from dataset.')