def load_region(region_id, local=False, return_regions=False):
    if local:
        _vr = Dataset(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data/terrain_parameters/VarslingsOmr_2017.nc'), 'r')
        _regions = _vr.variables['LokalOmr_2018'][:]
    else:
        _vr = Dataset(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data/terrain_parameters/VarslingsOmr_2019.nc'), 'r')
        _regions = _vr.variables['skredomr19_km'][:]
        print('Missing value: {mv}'.format(mv=_vr.variables['skredomr19_km'].missing_value))
    _region_bounds = np.where((_regions == region_id))
    (y_min, y_max, x_min, x_max) = (min(_region_bounds[0].flatten()), max(_region_bounds[0].flatten()), min(_region_bounds[1].flatten()), max(_region_bounds[1].flatten()))
    reg_mask = np.where((_regions[y_min:y_max, x_min:x_max] == region_id), 1.0, np.nan)
    _vr.close()
    if return_regions:
        return (_regions, reg_mask, y_min, y_max, x_min, x_max)
    else:
        return (reg_mask, y_min, y_max, x_min, x_max)
def load_region(region_id, local=False, return_regions=False):
    if local:
        _vr = Dataset(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data/terrain_parameters/VarslingsOmr_2017.nc'), 'r')
        _regions = _vr.variables['LokalOmr_2018'][:]
    else:
        _vr = Dataset(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data/terrain_parameters/VarslingsOmr_2019.nc'), 'r')
        _regions = _vr.variables['skredomr19_km'][:]
        print('Missing value: {mv}'.format(mv=_vr.variables['skredomr19_km'].missing_value))
    _region_bounds = np.where((_regions == region_id))
    (y_min, y_max, x_min, x_max) = (min(_region_bounds[0].flatten()), max(_region_bounds[0].flatten()), min(_region_bounds[1].flatten()), max(_region_bounds[1].flatten()))
    reg_mask = np.where((_regions[y_min:y_max, x_min:x_max] == region_id), 1.0, np.nan)
    _vr.close()
    if return_regions:
        return (_regions, reg_mask, y_min, y_max, x_min, x_max)
    else:
        return (reg_mask, y_min, y_max, x_min, x_max)