def dat_extent(dat, axes):
    """
    Get the extent of the dat variable.

    Parameters
    ----------
    dat : PyGMI Data
        PyGMI raster dataset.
    axes : matplotlib.axes._subplots.AxesSubplot
        Matploltib axes.

    Returns
    -------
    left : float
        Left coordinate.
    right : float
        Right coordinate.
    bottom : float
        Bottom coordinate.
    top : float
        Top coordinate.

    """
    left, right, bottom, top = dat.extent
    if right - left > 10000 or top - bottom > 10000:
        axes.xaxis.set_label_text('Eastings (km)')
        axes.yaxis.set_label_text('Northings (km)')
        left /= 1000.0
        right /= 1000.0
        top /= 1000.0
        bottom /= 1000.0
    else:
        axes.xaxis.set_label_text('Eastings (m)')
        axes.yaxis.set_label_text('Northings (m)')
    return left, right, bottom, top
