def select_grid_sampling_areas(iso3, grid, lut):
    '\n\n    '
    for i in range(1, 11):
        if (i == 1):
            grid.loc[((grid['id_range_m'] < lut[1]), 'decile')] = str(i)
            value_name = '0-{}'.format(str(lut[1]))
            grid.loc[((grid['id_range_m'] < lut[1]), 'value')] = value_name
        elif (i <= 9):
            grid.loc[(((grid['id_range_m'] >= lut[(i - 1)]) & (grid['id_range_m'] <= lut[i])), 'decile')] = str(i)
            value_name = '{}-{}'.format(str(lut[(i - 1)]), str(lut[i]))
            grid.loc[(((grid['id_range_m'] >= lut[(i - 1)]) & (grid['id_range_m'] <= lut[i])), 'value')] = value_name
        elif (i == 10):
            grid.loc[((grid['id_range_m'] > lut[(i - 1)]), 'decile')] = str(i)
            value_name = '>{}'.format(str(lut[(i - 1)]))
            grid.loc[((grid['id_range_m'] > lut[(i - 1)]), 'value')] = value_name
        else:
            continue
    np.random.seed(2)
    grid = grid.loc[(grid['area_km2'] > 2400)].reset_index()
    sampling_areas = grid.groupby(['decile']).apply((lambda x: x.sample(1))).reset_index(drop=True)
    directory = os.path.join(DATA_INTERMEDIATE, iso3, 'sampling_area')
    if (not os.path.exists(directory)):
        os.makedirs(directory)
    sampling_areas.to_file(os.path.join(directory, 'sampling_areas.shp'))
    sampling_areas.crs = 'epsg:4326'
    return sampling_areas
def select_grid_sampling_areas(iso3, grid, lut):
    '\n\n    '
    for i in range(1, 11):
        if (i == 1):
            grid.loc[((grid['id_range_m'] < lut[1]), 'decile')] = str(i)
            value_name = '0-{}'.format(str(lut[1]))
            grid.loc[((grid['id_range_m'] < lut[1]), 'value')] = value_name
        elif (i <= 9):
            grid.loc[(((grid['id_range_m'] >= lut[(i - 1)]) & (grid['id_range_m'] <= lut[i])), 'decile')] = str(i)
            value_name = '{}-{}'.format(str(lut[(i - 1)]), str(lut[i]))
            grid.loc[(((grid['id_range_m'] >= lut[(i - 1)]) & (grid['id_range_m'] <= lut[i])), 'value')] = value_name
        elif (i == 10):
            grid.loc[((grid['id_range_m'] > lut[(i - 1)]), 'decile')] = str(i)
            value_name = '>{}'.format(str(lut[(i - 1)]))
            grid.loc[((grid['id_range_m'] > lut[(i - 1)]), 'value')] = value_name
        else:
            continue
    np.random.seed(2)
    grid = grid.loc[(grid['area_km2'] > 2400)].reset_index()
    sampling_areas = grid.groupby(['decile']).apply((lambda x: x.sample(1))).reset_index(drop=True)
    directory = os.path.join(DATA_INTERMEDIATE, iso3, 'sampling_area')
    if (not os.path.exists(directory)):
        os.makedirs(directory)
    sampling_areas.to_file(os.path.join(directory, 'sampling_areas.shp'))
    sampling_areas.crs = 'epsg:4326'
    return sampling_areas