def ensure_location_spacing(data, distance_threshold=1):
    """
    Method to remove images of hurdles that are too close to each other. This should remove overlap of data.

    :param data: np.array from iterate_image_files, containing all image files from a given label
    :param distance_threshold: Images closer together than this will be removed.
    :return: np.array of size (n-k, 4) where n is the number of images with the given label and k is the number of
    images removed because they were too close. 
    """
    data.sort(axis=0, order=("env_key", "pos"))
    prev_env = "none"
    prev_pos = 0
    entries_to_keep = []
    for i in range(data.shape[0]):
        key, pos, _, _, _ = data[i]
        if prev_env != key:
            prev_env = key
        elif prev_pos + distance_threshold < pos:
            pass
        else:
            continue
        prev_pos = pos
        entries_to_keep.append(i)

    data = data[entries_to_keep]
    return data