def main():
    """Write your expression here."""

    wgs84_srs = osr.SpatialReference()
    wgs84_srs.ImportFromEPSG(4326)

    sinusoidal_raster1_path = 'solution_111_tar_80_res_2km_carbon_0.tif'
    raster_2_path = 'realized_e_source_abs_ann_mean.tif'
    raster_3_path = '1.5d_ha_per_pixel.tif'
    raster2_info = pygeoprocessing.get_raster_info(raster_2_path)
    target_pixel_size = (1.495833333333333348, 1.5092592592592593)
    resample_method = 'average'
    projected_raster1_path = f'wgs84_projected_{sinusoidal_raster1_path}'

    warp_raster_task = TASK_GRAPH.add_task(
        func=pygeoprocessing.warp_raster,
        args=(sinusoidal_raster1_path, target_pixel_size,
              projected_raster1_path, resample_method),
        kwargs={
            'target_projection_wkt': wgs84_srs.ExportToWkt(),
            'target_bb': raster2_info['bounding_box']
        },
        target_path_list=[projected_raster1_path],
        task_name=f'project {sinusoidal_raster1_path}')
    warp_raster_task.join()

    single_expression = {
        'expression': '(raster2>-9999)*raster1*raster3',
        'symbol_to_path_map': {
            'raster1': projected_raster1_path,
            'raster2': raster_2_path,
            'raster3': raster_3_path,
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_projection_wkt': wgs84_srs.ExportToWkt(),
        'target_pixel_size': target_pixel_size,
        'resample_method': resample_method,
        'target_raster_path': "top80_solution_area_1.5d.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return
示例#2
0
def main():
    """Write your expression here."""

    raster_calculation_list = [
        {
            'expression': '(x < 0) * x',
            'symbol_to_path_map': {
                'x': r"C:\Users\rpsharp\Documents\output.tif",
            },
            'target_nodata': -1,
            'target_raster_path': "less_than.tif",
            'build_overview': True,
        },
    ]

    for calculation in raster_calculation_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()
def main():
    """Entry point."""
    for dir_path in [WORKSPACE_DIR, CHURN_DIR, ECOSHARD_DIR]:
        try:
            os.makedirs(dir_path)
        except OSError:
            pass
    task_graph = taskgraph.TaskGraph(CHURN_DIR, -1, 5.0)
    kernel_raster_path = os.path.join(CHURN_DIR, 'radial_kernel.tif')
    kernel_task = task_graph.add_task(
        func=create_flat_radial_convolution_mask,
        args=(0.00277778, 2000., kernel_raster_path),
        target_path_list=[kernel_raster_path],
        task_name='make convolution kernel')
    hab_fetch_path_map = {}
    # download hab mask and ppl fed equivalent raster
    for raster_id, raster_url in BASE_RASTER_URL_MAP.items():
        raster_path = os.path.join(ECOSHARD_DIR, os.path.basename(raster_url))
        _ = task_graph.add_task(
            func=raster_calculations_core.download_url,
            args=(raster_url, raster_path),
            target_path_list=[raster_path],
            task_name='fetch hab mask')
        hab_fetch_path_map[raster_id] = raster_path
    task_graph.join()

    hab_mask_raster_info = pygeoprocessing.get_raster_info(
        hab_fetch_path_map['hab_mask'])

    ppl_fed_raster_info = pygeoprocessing.get_raster_info(
        hab_fetch_path_map['ppl_fed'])

    ppl_fed_nodata_to_zero_path = os.path.join(
        CHURN_DIR, 'ppl_fed__nodata_to_zero.tif')

    task_graph.add_task(
        func=pygeoprocessing.raster_calculator,
        args=(
            [(hab_fetch_path_map['ppl_fed'], 1),
             (ppl_fed_raster_info['nodata'][0], 'raw')],
            _nodata_to_zero_op, ppl_fed_nodata_to_zero_path,
            gdal.GDT_Float32, None),
        target_path_list=[ppl_fed_nodata_to_zero_path],
        task_name='hab mask nodata to zero')
    task_graph.join()

    # calculate extent of ppl fed by 2km.
    ppl_fed_reach_raster_path = os.path.join(CHURN_DIR, 'ppl_fed_reach.tif')
    ppl_fed_reach_task = task_graph.add_task(
        func=pygeoprocessing.convolve_2d,
        args=[
            (ppl_fed_nodata_to_zero_path, 1), (kernel_raster_path, 1),
            ppl_fed_reach_raster_path],
        kwargs={
            'working_dir': CHURN_DIR,
            'mask_nodata': False,
            'raster_driver_creation_tuple': (
                'GTiff', (
                    'TILED=YES', 'BIGTIFF=YES', 'COMPRESS=ZSTD',
                    'PREDICTOR=1', 'BLOCKXSIZE=256', 'BLOCKYSIZE=256',
                    'NUM_THREADS=2')),
                'n_threads': 4},
        dependent_task_list=[kernel_task],
        target_path_list=[ppl_fed_reach_raster_path],
        task_name=(
            'calculate natural hab proportion'
            f' {os.path.basename(ppl_fed_reach_raster_path)}'))

    # mask ppl fed reach by the hab mask.
    raster_calculations_core.evaluate_calculation(
        {
            'expression': 'ppl_fed_reach*(hab_mask>0.0)',
            'symbol_to_path_map': {
                'ppl_fed_reach': ppl_fed_reach_raster_path,
                'hab_mask': hab_fetch_path_map['hab_mask'],
            },
            'target_pixel_size': hab_mask_raster_info['pixel_size'],
            'target_nodata': TARGET_NODATA,
            'target_raster_path': REALIZED_POLLINATION_RASTER_PATH,
        }, task_graph, CHURN_DIR)
    task_graph.join()

    compress_and_overview.compress_to(
        task_graph, REALIZED_POLLINATION_RASTER_PATH, 'bilinear',
        REALIZED_POLLINATION_COMPRESSED_RASTER_PATH)

    task_graph.close()
示例#4
0
        MASKED_LOCAL_RASTER_PATH = os.path.join(
            CHURN_DIR, 'masked_%s' % os.path.basename(LOCAL_RASTER_PATH))
        LOGGER.debug('masking %s', MASKED_LOCAL_RASTER_PATH)
        REMASKING_EXPRESSION = {
            'expression': 'mask*service',
            'symbol_to_path_map': {
                'mask': MASK_RASTER_PATH,
                'service': LOCAL_RASTER_PATH,
            },
            'target_nodata': -1,
            'target_raster_path': MASKED_LOCAL_RASTER_PATH,
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
        }

        raster_calculations_core.evaluate_calculation(REMASKING_EXPRESSION,
                                                      TASK_GRAPH,
                                                      WORKSPACE_DIR)
        RASTERS_TO_NORMALIZE_PATH_LIST.append(MASKED_LOCAL_RASTER_PATH)

    NORMALIZE_THESE_DIRECTLY = [
        # 'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_moisture_md5_d5396383d8a30f296988f86bb0fc0528.tif',
        # 'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_flood_md5_6b603609e55d3a17d20ea76699aaaf79.tif',
        'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_flood_md5_f1237e76a41039e22629abb85963ba16.tif'
    ]

    for URL in RASTERS_TO_MASK_AND_NORMALIZE_URL_LIST:
        LOCAL_RASTER_PATH = os.path.join(ECOSHARD_DIR, os.path.basename(URL))
        DOWNLOAD_TASK = TASK_GRAPH.add_task(
            func=ecoshard.download_url,
            args=(URL, LOCAL_RASTER_PATH),
            target_path_list=[LOCAL_RASTER_PATH],
def main():
    """Write your expression here."""
    base_directory = os.getcwd()

    masked_workspace_dir = 'masked_workspace_dir'
    ecoshard_workspace_dir = 'ecoshard_dir'
    for dirname in [masked_workspace_dir, ecoshard_workspace_dir]:
        try:
            os.makedirs(dirname)
        except OSError:
            pass

    mask_url = 'https://storage.googleapis.com/critical-natural-capital-ecoshards/masked_nathab_esa_nodata_md5_7c9acfe052cb7bdad319f011e9389fb1.tif'
    mask_path = os.path.join(ecoshard_workspace_dir,
                             os.path.basename(mask_url))
    download_task = TASK_GRAPH.add_task(
        func=raster_calculations_core.download_url,
        args=(mask_url, mask_path),
        target_path_list=[mask_path],
        task_name='download %s' % mask_path)
    download_task.join()

    for path in glob.glob(os.path.join(base_directory, '*.tif')):
        path_root_name = os.path.splitext(os.path.basename(path))[0]
        target_raster_path = os.path.join(masked_workspace_dir,
                                          '%s_masked.tif' % (path_root_name))
        LOGGER.debug("processing %s to %s", path, target_raster_path)
        # if we wanted to split off an ecoshard....
        #path_root_name = re.match('(.*)_md5_.*\.tif', os.path.basename(path))[1]
        #so this is a regular expression that's matching the pattern [something]_md5_[something].tif
        #the first part that says (.*) says match any characters and remember them
        #the _md5_ means literally match md5, and it just remembers everything before the _md5_...tif
        #the os.path.basename(path) part ensures that the path you're putting in is just the filename... in case there's a directory in there
        #then the last [1] means "pick the first match that I remembered" which will be the leading part of your filename
        #so you can see how it works like this:
        #>>> path='dir/foo_md5_aaaabbbcccdddeeeff121235.tif'
        #>>> re.match('(.*)_md5_.*\.tif', os.path.basename(path))[1]

        remasking_expression = {
            'expression': 'mask*service',
            'symbol_to_path_map': {
                'mask': mask_path,
                'service': path,
            },
            'target_nodata': -1,
            'target_raster_path': target_raster_path,
            ###file name split off from its path and its ecoshard too because it will be re-ecosharded
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
        }

        raster_calculations_core.evaluate_calculation(remasking_expression,
                                                      TASK_GRAPH,
                                                      WORKSPACE_DIR)

    LOGGER.debug("joining TASK_GRAPH")
    TASK_GRAPH.join()
    TASK_GRAPH.close()
    return

    aggregate_service_list = [
        {
            'expression':
            'nitrogen + sediment + pollination + wood + nonwood + grazing',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_nitrogen_md5_00765388b2c864dbf242674187956d3d.tif',
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_sediment_md5_dc83a48d1879284106d093d9cf87b085.tif',
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/potential_pollination_edge_md5_3b0171d8dac47d2aa2c6f41fb94b6243.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_wood_masked_md5_0f8766045ac50683db7af59f988bcad8.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/masked_nathab_esa_md5_40577bae3ef60519b1043bb8582a07af.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_grazing_md5_36cf99f8af9743264b8cbaa72229488c.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_nspwog.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression':
            'nitrogen + sediment + pollination + wood + nonwood + grazing',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nitrogen_downstream_md5_437e1759b0f994b47add4baf76509bbe.tif',
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_sediment_downstream_md5_daa86f70232c5e1a8a0efaf0b2653db2.tif',
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_pollination_md5_06f52f2854ae1c584742d587b1c31359.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_timber_masked_md5_fc5ad0ff1f4702d75f204267fc90b33f.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nwfp_masked_md5_754ba4d8cd0c54399fd816748a9e0091.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_grazing_md5_d03b584dac965539a77bf96cba3f8096.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_nspwog.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + sediment + pollination + wood + grazing',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_nitrogen_md5_00765388b2c864dbf242674187956d3d.tif',
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_sediment_md5_dc83a48d1879284106d093d9cf87b085.tif',
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/potential_pollination_edge_md5_3b0171d8dac47d2aa2c6f41fb94b6243.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_wood_masked_md5_0f8766045ac50683db7af59f988bcad8.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_grazing_md5_36cf99f8af9743264b8cbaa72229488c.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_nspwg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + sediment + pollination + wood + grazing',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nitrogen_downstream_md5_437e1759b0f994b47add4baf76509bbe.tif',
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_sediment_downstream_md5_daa86f70232c5e1a8a0efaf0b2653db2.tif',
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_pollination_md5_06f52f2854ae1c584742d587b1c31359.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_timber_masked_md5_fc5ad0ff1f4702d75f204267fc90b33f.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_grazing_md5_d03b584dac965539a77bf96cba3f8096.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_nspwg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + pollination + wood + grazing',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_nitrogen_md5_00765388b2c864dbf242674187956d3d.tif',
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/potential_pollination_edge_md5_3b0171d8dac47d2aa2c6f41fb94b6243.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_wood_masked_md5_0f8766045ac50683db7af59f988bcad8.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_grazing_md5_36cf99f8af9743264b8cbaa72229488c.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_npwg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + pollination + wood + grazing',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nitrogen_downstream_md5_437e1759b0f994b47add4baf76509bbe.tif',
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_pollination_md5_06f52f2854ae1c584742d587b1c31359.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_timber_masked_md5_fc5ad0ff1f4702d75f204267fc90b33f.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_grazing_md5_d03b584dac965539a77bf96cba3f8096.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_npwg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'pollination + wood + grazing',
            'symbol_to_path_map': {
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/potential_pollination_edge_md5_3b0171d8dac47d2aa2c6f41fb94b6243.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_wood_masked_md5_0f8766045ac50683db7af59f988bcad8.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_grazing_md5_36cf99f8af9743264b8cbaa72229488c.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_pwg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'pollination + wood + grazing',
            'symbol_to_path_map': {
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_pollination_md5_06f52f2854ae1c584742d587b1c31359.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_timber_masked_md5_fc5ad0ff1f4702d75f204267fc90b33f.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_grazing_md5_d03b584dac965539a77bf96cba3f8096.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_pwg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'wood + grazing',
            'symbol_to_path_map': {
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_wood_masked_md5_0f8766045ac50683db7af59f988bcad8.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_grazing_md5_36cf99f8af9743264b8cbaa72229488c.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_wg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'wood + grazing',
            'symbol_to_path_map': {
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_timber_masked_md5_fc5ad0ff1f4702d75f204267fc90b33f.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_grazing_md5_d03b584dac965539a77bf96cba3f8096.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_wg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'pollination + grazing',
            'symbol_to_path_map': {
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/potential_pollination_edge_md5_3b0171d8dac47d2aa2c6f41fb94b6243.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_grazing_md5_36cf99f8af9743264b8cbaa72229488c.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_pg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'pollination + grazing',
            'symbol_to_path_map': {
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_pollination_md5_06f52f2854ae1c584742d587b1c31359.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_grazing_md5_d03b584dac965539a77bf96cba3f8096.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_pg.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'pollination + wood',
            'symbol_to_path_map': {
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/potential_pollination_edge_md5_3b0171d8dac47d2aa2c6f41fb94b6243.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_wood_masked_md5_0f8766045ac50683db7af59f988bcad8.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_pw.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'pollination + wood',
            'symbol_to_path_map': {
                'pollination':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_pollination_md5_06f52f2854ae1c584742d587b1c31359.tif',
                'wood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_timber_masked_md5_fc5ad0ff1f4702d75f204267fc90b33f.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_pw.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + sediment + nonwood + grazing',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_nitrogen_md5_00765388b2c864dbf242674187956d3d.tif',
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_sediment_md5_dc83a48d1879284106d093d9cf87b085.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/masked_nathab_esa_md5_40577bae3ef60519b1043bb8582a07af.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_grazing_md5_36cf99f8af9743264b8cbaa72229488c.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_nsog.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + sediment + nonwood + grazing',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nitrogen_downstream_md5_437e1759b0f994b47add4baf76509bbe.tif',
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_sediment_downstream_md5_daa86f70232c5e1a8a0efaf0b2653db2.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nwfp_masked_md5_754ba4d8cd0c54399fd816748a9e0091.tif',
                'grazing':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_grazing_md5_d03b584dac965539a77bf96cba3f8096.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_nsog.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + sediment + nonwood',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_nitrogen_md5_00765388b2c864dbf242674187956d3d.tif',
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_sediment_md5_dc83a48d1879284106d093d9cf87b085.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/masked_nathab_esa_md5_40577bae3ef60519b1043bb8582a07af.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_nso.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + sediment + nonwood',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nitrogen_downstream_md5_437e1759b0f994b47add4baf76509bbe.tif',
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_sediment_downstream_md5_daa86f70232c5e1a8a0efaf0b2653db2.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nwfp_masked_md5_754ba4d8cd0c54399fd816748a9e0091.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_nso.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'sediment + nonwood',
            'symbol_to_path_map': {
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_sediment_md5_dc83a48d1879284106d093d9cf87b085.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/masked_nathab_esa_md5_40577bae3ef60519b1043bb8582a07af.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_so.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'sediment + nonwood',
            'symbol_to_path_map': {
                'sediment':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_sediment_downstream_md5_daa86f70232c5e1a8a0efaf0b2653db2.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nwfp_masked_md5_754ba4d8cd0c54399fd816748a9e0091.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_so.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + nonwood',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_potential_nitrogen_md5_00765388b2c864dbf242674187956d3d.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/masked_nathab_esa_md5_40577bae3ef60519b1043bb8582a07af.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_potential_ES_score_no.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'nitrogen + nonwood',
            'symbol_to_path_map': {
                'nitrogen':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nitrogen_downstream_md5_437e1759b0f994b47add4baf76509bbe.tif',
                'nonwood':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/normalized_realized_nwfp_masked_md5_754ba4d8cd0c54399fd816748a9e0091.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "aggregate_realized_ES_score_no.tif",
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
    ]

    for calculation in aggregate_service_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    #why doesn't this work??
    #TASK_GRAPH.join()
    #ecoshard aggregate*.tif --hash_file --rename --buildoverviews --interpolation_method average

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    normalized_service_list = [
        {
            'expression': 'service/ percentile(service, 99)',
            'symbol_to_path_map': {
                'service':
                r"C:\Users\Becky\Documents\raster_calculations\CNC_workspace\potential_wood_products.tif",
            },
            'target_nodata': -1,
            'target_raster_path': "raw_normalized_potential_wood_products.tif",
        },
        {
            'expression': 'service/ percentile(service, 99)',
            'symbol_to_path_map': {
                'service':
                r"C:\Users\Becky\Documents\raster_calculations\CNC_workspace\potential_pollination_edge.tif",
            },
            'target_nodata': -1,
            'target_raster_path':
            "raw_normalized_potential_pollination_edge.tif",
        },
        {
            'expression': 'service/ percentile(service, 99)',
            'symbol_to_path_map': {
                'service':
                r"C:\Users\Becky\Documents\raster_calculations\CNC_workspace\potential_sedimentdeposition.tif",
            },
            'target_nodata': -1,
            'target_raster_path': "raw_normalized_potential_sediment.tif",
        },
        {
            'expression': 'service/ percentile(service, 99)',
            'symbol_to_path_map': {
                'service':
                r"C:\Users\Becky\Documents\raster_calculations\CNC_workspace\potential_grazing.tif",
            },
            'target_nodata': -1,
            'target_raster_path': "raw_normalized_potential_grazing.tif",
        },
        {
            'expression': 'service/ percentile(service, 99)',
            'symbol_to_path_map': {
                'service':
                r"C:\Users\Becky\Documents\raster_calculations\CNC_workspace\potential_nitrogenretention.tif",
            },
            'target_nodata': -1,
            'target_raster_path': "raw_normalized_potential_nitrogen.tif",
        },
    ]

    for calculation in normalized_service_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return  #terminates at this point

    clamping_service_list = [
        {
            'expression': '(val >= 0) * (val < 1) * val + (val >= 1)',
            'symbol_to_path_map': {
                'val': "raw_normalized_realized_nitrogen_downstream.tif",
            },
            'target_nodata': -1,
            'target_raster_path':
            "normalized_realized_nitrogen_downstream.tif",
        },
        {
            'expression': '(val >= 0) * (val < 1) * val + (val >= 1)',
            'symbol_to_path_map': {
                'val': "raw_normalized_realized_sediment_downstream.tif",
            },
            'target_nodata': -1,
            'target_raster_path':
            "normalized_realized_sediment_downstream.tif",
        },
        {
            'expression': '(val >= 0) * (val < 1) * val + (val >= 1)',
            'symbol_to_path_map': {
                'val': "raw_normalized_realized_pollination.tif",
            },
            'target_nodata': -1,
            'target_raster_path': "normalized_realized_pollination.tif",
        },
    ]

    for calculation in clamping_service_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()

    synthesis_index_expression = {
        'expression':
        'nitrogen + sediment + pollination + nwfp + timber + grazing',
        'symbol_to_path_map': {
            'nitrogen':
            "normalized_realized_nitrogen_downstream.tif",
            'sediment':
            "normalized_realized_sediment_downstream.tif",
            'pollination':
            "normalized_realized_pollination.tif",
            'nwfp':
            'https://storage.googleapis.com/critical-natural-capital-ecoshards/realized_nwfp_md5_f1cce72af652fd16e25bfa34a6bddc63.tif',
            'timber':
            'https://storage.googleapis.com/critical-natural-capital-ecoshards/realized_timber_md5_5154151ebe061cfa31af2c52595fa5f9.tif',
            'grazing':
            'https://storage.googleapis.com/critical-natural-capital-ecoshards/realized_grazing_md5_19085729ae358e0e8566676c5c7aae72.tif',
        },
        'target_nodata': -1,
        'target_raster_path': "aggregate_realized_score_nspntg.tif",
        'target_pixel_size': (0.002777777777778, -0.002777777777778),
        'resample_method': 'average'
    }

    raster_calculations_core.evaluate_calculation(synthesis_index_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return  #terminates at this point

    normalized_service_list = [
        {
            'expression':
            'service/ percentile(service, 99)',
            'symbol_to_path_map': {
                'service':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/realized_nitrogenretention_downstream_md5_82d4e57042482eb1b92d03c0d387f501.tif',
            },
            'target_nodata':
            -1,
            'target_raster_path':
            "raw_normalized_realized_nitrogen_downstream.tif",
        },
        {
            'expression':
            'service/ percentile(service, 99)',
            'symbol_to_path_map': {
                'service':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/realized_sedimentdeposition_downstream_md5_1613b12643898c1475c5ec3180836770.tif',
            },
            'target_nodata':
            -1,
            'target_raster_path':
            "raw_normalized_realized_sediment_downstream.tif",
        },
        {
            'expression': 'service/ percentile(service, 99)',
            'symbol_to_path_map': {
                'service':
                'https://storage.googleapis.com/critical-natural-capital-ecoshards/realized_pollination_md5_8a780d5962aea32aaa07941bde7d8832.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "raw_normalized_realized_pollination.tif",
        },
    ]

    for calculation in normalized_service_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()

    clamping_service_list = [
        {
            'expression': '(val >= 0) * (val < 1) * val + (val >= 1)',
            'symbol_to_path_map': {
                'val': "raw_normalized_realized_nitrogen_downstream.tif",
            },
            'target_nodata': -1,
            'target_raster_path':
            "normalized_realized_nitrogen_downstream.tif",
        },
        {
            'expression': '(val >= 0) * (val < 1) * val + (val >= 1)',
            'symbol_to_path_map': {
                'val': "raw_normalized_realized_sediment_downstream.tif",
            },
            'target_nodata': -1,
            'target_raster_path':
            "normalized_realized_sediment_downstream.tif",
        },
        {
            'expression': '(val >= 0) * (val < 1) * val + (val >= 1)',
            'symbol_to_path_map': {
                'val': "raw_normalized_realized_pollination.tif",
            },
            'target_nodata': -1,
            'target_raster_path': "normalized_realized_pollination.tif",
        },
    ]

    for calculation in clamping_service_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()

    synthesis_index_expression = {
        'expression':
        'nitrogen + sediment + pollination + nwfp + timber + grazing',
        'symbol_to_path_map': {
            'nitrogen':
            "normalized_realized_nitrogen_downstream.tif",
            'sediment':
            "normalized_realized_sediment_downstream.tif",
            'pollination':
            "normalized_realized_pollination.tif",
            'nwfp':
            'https://storage.googleapis.com/critical-natural-capital-ecoshards/realized_nwfp_md5_f1cce72af652fd16e25bfa34a6bddc63.tif',
            'timber':
            'https://storage.googleapis.com/critical-natural-capital-ecoshards/realized_timber_md5_5154151ebe061cfa31af2c52595fa5f9.tif',
            'grazing':
            'https://storage.googleapis.com/critical-natural-capital-ecoshards/realized_grazing_md5_19085729ae358e0e8566676c5c7aae72.tif',
        },
        'target_nodata': -1,
        'target_raster_path': "aggregate_realized_score_nspntg.tif",
        'target_pixel_size': (0.002777777777778, -0.002777777777778),
        'resample_method': 'average'
    }

    raster_calculations_core.evaluate_calculation(synthesis_index_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return  #terminates at this point

    masker_list = [
        {
            # the %s is a placeholder for the string we're passing it using this function that lists every number in the range and takes away the [] of the list and turns it into a string
            'expression':
            'mask(raster, %s, invert=False)' %
            (str([] + [x for x in range(50, 181)])[1:-1]),
            'symbol_to_path_map': {
                'raster':
                'https://storage.googleapis.com/ipbes-ndr-ecoshard-data/ESACCI-LC-L4-LCCS-Map-300m-P1Y-2015-v2.0.7_md5_1254d25f937e6d9bdee5779d377c5aa4.tif',
            },
            'target_nodata':
            -1,
            'target_raster_path':
            'masked_nathab_esa.tif',
        },
        {
            'expression':
            'mask(raster, %s, invert=False)' %
            (str([20, 30] + [x for x in range(80, 127)])[1:-1]),
            'symbol_to_path_map': {
                'raster':
                'https://storage.googleapis.com/ecoshard-root/working-shards/coopernicus_landcover_discrete_compressed_md5_264bda5338a02e4a6cc10412b8edad9f.tif',
            },
            'target_nodata':
            -1,
            'target_raster_path':
            'masked_nathab_copernicus.tif',
        },
        {
            # this is for masking out forest from natural habitat, for livestock production
            # this counts the >50% herbaceous / < 50% tree cover category as "not forest"; also includes lichens, mosses  and shrubland which maybe isn't totally edible by cattle either
            'expression':
            'mask(raster, %s, invert=False)' %
            (str([x for x in range(110, 154)] + [180])[1:-1]),
            'symbol_to_path_map': {
                'raster':
                'https://storage.googleapis.com/ipbes-ndr-ecoshard-data/ESACCI-LC-L4-LCCS-Map-300m-P1Y-2015-v2.0.7_md5_1254d25f937e6d9bdee5779d377c5aa4.tif',
            },
            'target_nodata':
            -1,
            'target_raster_path':
            'masked_nathab_notforest_esa.tif',
        },
    ]
    for masker in masker_list:
        raster_calculations_core.evaluate_calculation(masker, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    grazing_service_list = [
        {
            'expression': 'mask*service',
            'symbol_to_path_map': {
                'mask':
                'C:/Users/Becky/Documents/raster_calculations/CNC_workspace/masked_nathab_notforest_esa.tif',
                'service':
                'C:/Users/Becky/Documents/raster_calculations/CNC_workspace/potential_grazing_value.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "potential_grazing.tif",
            'build_overview': True,
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'mask*service',
            'symbol_to_path_map': {
                'mask':
                'C:/Users/Becky/Documents/raster_calculations/CNC_workspace/masked_nathab_notforest_esa.tif',
                'service':
                'C:/Users/Becky/Documents/raster_calculations/CNC_workspace/realised_grazing_value.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "realized_grazing.tif",
            'build_overview': True,
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
    ]

    for calculation in grazing_service_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    potential_service_list = [
        {
            'expression': 'mask*service',
            'symbol_to_path_map': {
                'mask':
                'https://storage.googleapis.com/ecoshard-root/working-shards/masked_nathab_esa_md5_40577bae3ef60519b1043bb8582a07af.tif',
                'service':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/ESACCI_LC_L4_LCCS_borrelli_sediment_deposition_md5_3e0ccb34352269d7eb688dd488de002f.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "potential_sedimentdeposition.tif",
            'build_overview': True,
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
        },
        {
            'expression': 'mask*service',
            'symbol_to_path_map': {
                'mask':
                'https://storage.googleapis.com/ecoshard-root/working-shards/masked_nathab_esa_md5_40577bae3ef60519b1043bb8582a07af.tif',
                'service':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/worldclim_esa_2015_n_retention_md5_d10a396b8f0fee70dd3bbd3524a6a97c.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "potential_nitrogenretention.tif",
            'build_overview': True,
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
    ]

    for calculation in potential_service_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    realized_service_list = [
        {
            'expression': 'beneficiaries*service',
            'symbol_to_path_map': {
                'beneficiaries':
                'C:/Users/Becky/Documents/raster_calculations/CNC_workspace/downstream_beneficiaries_md5_68495f4bbdd889d7aaf9683ce958a4fe.tif',
                'service':
                'C:/Users/Becky/Documents/raster_calculations/CNC_workspace/potential_nitrogenretention.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "realized_nitrogenretention_downstream.tif",
            'build_overview': True,
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
        {
            'expression': 'beneficiaries*service',
            'symbol_to_path_map': {
                'beneficiaries':
                'C:/Users/Becky/Documents/raster_calculations/CNC_workspace/downstream_beneficiaries_md5_68495f4bbdd889d7aaf9683ce958a4fe.tif',
                'service':
                'C:/Users/Becky/Documents/raster_calculations/CNC_workspace/potential_sedimentdeposition.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "realized_sedimentdeposition_downstream.tif",
            'build_overview': True,
            'target_pixel_size': (0.002777777777778, -0.002777777777778),
            'resample_method': 'average'
        },
    ]

    for calculation in realized_service_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    # just build overviews
    raster_calculation_list = [
        {
            'expression': 'x',
            'symbol_to_path_map': {
                'x': '../nathab_potential_pollination.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "potential_pollination.tif",
            'build_overview': True,
        },
    ]

    for calculation in raster_calculation_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    #calculate people fed equivalents from individual nutrient data
    raster_calculation_list = [
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                '../pollination_esa_tifs/prod_poll_dep_realized_va_10s_ESACCI_LC_L4_LCSS.tif',
                'en':
                '../pollination_esa_tifs/prod_poll_dep_realized_en_10s_ESACCI_LC_L4_LCSS.tif',
                'fo':
                '../pollination_esa_tifs/prod_poll_dep_realized_fo_10s_ESACCI_LC_L4_LCSS.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "pollination_ppl_fed_on_ag_10s_esa.tif",
            'build_overview': True,
        },
    ]

    for calculation in raster_calculation_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)
def main():
    """Write your expression here."""

    # here's a snippet that will reproject it to the esa bounding box and size:
    esa_info = pygeoprocessing.get_raster_info(
        "ESACCI-LC-L4-LCCS-Map-300m-P1Y-2015-v2.0.7_md5_1254d25f937e6d9bdee5779d377c5aa4.tif"
    )
    base_raster_path = r"ESACCI_PNV_iis_OA_ESAclasses_max_md5_e6575db589abb52c683d44434d428d80.tif"
    target_raster_path = '%s_wgs84%s' % os.path.splitext(base_raster_path)
    pygeoprocessing.warp_raster(
        base_raster_path,
        esa_info['pixel_size'],
        target_raster_path,
        'near',
        target_projection_wkt=esa_info['projection_wkt'],
        target_bb=esa_info['bounding_box'])

    return

    wgs84_srs = osr.SpatialReference()
    wgs84_srs.ImportFromEPSG(4326)

    raster_calculation_list = [
        {
            'expression':
            '(raster2>0)*raster1',
            'symbol_to_path_map': {
                'raster1':
                "ESACCI_PNV_iis_OA_ESAclasses_max_md5_e6575db589abb52c683d44434d428d80.tif",
                'raster2':
                "ESACCI-LC-L4-LCCS-Map-300m-P1Y-2015-v2.0.7_md5_1254d25f937e6d9bdee5779d377c5aa4.tif",
            },
            'target_nodata':
            0,
            'target_projection_wkt':
            wgs84_srs.ExportToWkt(),
            'target_pixel_size': (0.002777777777778, 0.002777777777778),
            'bounding_box_mode': [-180, -90, 180, 90],
            'resample_method':
            'near',
            'target_raster_path':
            "ESACCI_PNV_iis_OA_ESAclasses_max_ESAresproj_md5_e6575db589abb52c683d44434d428d80.tif",
        },
    ]

    for calculation in raster_calculation_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression':
        '(raster1/raster2)*raster3*(raster2>0) + (raster2==0)*raster3',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Downloads\ssp3_2050_md5_b0608d53870b9a7e315bf9593c43be86.tif",
            'raster2':
            r"C:\Users\Becky\Downloads\ssp1_2010_md5_5edda6266351ccc7dbd587c89fa2ab65.tif",
            'raster3':
            r"C:\Users\Becky\Documents\raster_calculations\lspop2017.tif",
        },
        'target_nodata': 2147483647,
        'default_nan': 2147483647,
        'target_pixel_size': (0.002777777777778, 0.002777777777778),
        'resample_method': 'near',
        'target_raster_path': "lspop_ssp3.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression': 'raster1*raster2*raster3*(raster4>0)+(raster4<1)*-9999',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\pollination\monfreda_2008_yield_poll_dep_ppl_fed_5min.tif",
            'raster2':
            r"C:\Users\Becky\Documents\raster_calculations\CNC_workspace\SEA\poll_suff_ag_coverage_prop_10s_ESACCI-LC-L4-LCCS-Map-300m-P1Y-2015_SEAclip_wgs.tif",
            'raster3':
            r"C:\Users\Becky\Documents\geobon\pollination\esa_pixel_area_ha.tif",
            'raster4':
            r"C:\Users\Becky\Documents\raster_calculations\CNC_workspace\SEA\ESA2015_without5_8forest_ag_mask.tif"
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_pixel_size': (0.002777777777778, 0.002777777777778),
        'resample_method': 'near',
        'target_raster_path':
        "pollination_ppl_fed_on_ag_10s_esa2015_SEAclip.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression':
        'raster1*raster2*raster3*(raster4>0)+(raster4<1)*-9999',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\pollination\monfreda_2008_yield_poll_dep_ppl_fed_5min.tif",
            'raster2':
            r"C:\Users\Becky\Documents\raster_calculations\CNC_workspace\SEA\poll_suff_ag_coverage_prop_10s_ESA2015_without5_8forest.tif",
            'raster3':
            r"C:\Users\Becky\Documents\geobon\pollination\esa_pixel_area_ha.tif",
            'raster4':
            r"C:\Users\Becky\Documents\raster_calculations\CNC_workspace\SEA\ESA2015_without5_8forest_ag_mask.tif"
        },
        'target_nodata':
        -9999,
        'default_nan':
        -9999,
        'target_pixel_size': (0.002777777777778, 0.002777777777778),
        'resample_method':
        'near',
        'target_raster_path':
        "pollination_ppl_fed_on_ag_10s_esa2015_without5_8forest.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    wgs84_srs = osr.SpatialReference()
    wgs84_srs.ImportFromEPSG(4326)

    raster_calculation_list = [
        {
            'expression':
            '(raster2)*200 + (raster2<1)*raster1',  #this resets everywhere it's a forest project to "bare"
            'symbol_to_path_map': {
                'raster1':
                r"C:\Users\Becky\Documents\cnc_project\SEA\ESACCI-LC-L4-LCCS-Map-300m-P1Y-2015_SEAclip.tif",
                'raster2':
                r"C:\Users\Becky\Documents\cnc_project\SEA\ForestMask_5_8.tif"
            },
            'target_nodata': 0,
            'target_projection_wkt': wgs84_srs.ExportToWkt(),
            'target_pixel_size': (0.002777777777778, 0.002777777777778),
            'resample_method': 'near',
            'target_raster_path': "Forest_5_8_toBare.tif",
        },
    ]

    for calculation in raster_calculation_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    #then will need to use nodata_replace.py-> can't just do this on the mask to begin with because it's not in the right projection
    # python nodata_replace.py "C:\Users\Becky\Documents\cnc_project\SEA\Forest_5_8_toBare.tif" "C:\Users\Becky\Documents\cnc_project\SEA\ESACCI-LC-L4-LCCS-Map-300m-P1Y-2015_SEAclip.tif" ESA2015_without5_8forest.tif
    #nodata_replace doesn't work because the two rasters are slightly different dimensions. so try this:
    #docker run -it -v "%CD%":/usr/local/workspace therealspring/inspring:latest ./stitch_rasters.py --target_projection_epsg 4326 --target_cell_size 0.002777777777778 --target_raster_path ESA2015_without5_8forest.tif --resample_method near --area_weight_m2_to_wgs84 --overlap_algorithm replace --raster_pattern ./CNC_workspace/SEA/ "*wgs.tif"
    #then run pollination model
    #docker run -d --name pollsuff_container --rm -v `pwd`:/usr/local/workspace therealspring/inspring:latest make_poll_suff.py ./*.tif && docker logs pollsuff_container -f

    return

    single_expression = {
        'expression': 'raster1*raster2',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\CV\pnv_lspop2017\cv_value_pnv_md5_3e1680fd99db84773e1473289958e0ac.tif",
            'raster2':
            r"C:\Users\Becky\Documents\geobon\CV\pnv_lspop2017\cv_pop_pnv_md5_57ca9a7a91fe23a81c549d17adf6dbd1.tif",
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_pixel_size': (0.0027777778, -0.0027777778),
        'resample_method': 'near',
        'target_raster_path': "coastal_risk_reduction_pnvls17.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    calc_list = [
        {
            'expression': 'raster1 - raster2',
            'symbol_to_path_map': {
                'raster1':
                r"C:\Users\Becky\Documents\geobon\ndr\stitch_pnv_esa_modified_load.tif",
                'raster2':
                r"C:\Users\Becky\Documents\geobon\ndr\stitch_pnv_esa_n_export.tif",
            },
            'target_nodata': float(numpy.finfo(numpy.float32).min),
            'default_nan': float(numpy.finfo(numpy.float32).min),
            'target_pixel_size':
            (0.0027777777777777778, -0.0027777777777777778),
            'resample_method': 'near',
            'target_raster_path': "pnv_n_retention.tif",
        },
        {
            'expression': 'raster1 - raster2',
            'symbol_to_path_map': {
                'raster1':
                r"C:\Users\Becky\Documents\geobon\ndr\stitch_worldclim_esa_2000_modified_load.tif",
                'raster2':
                r"C:\Users\Becky\Documents\geobon\ndr\stitch_worldclim_esa_2000_n_export.tif",
            },
            'target_nodata': float(numpy.finfo(numpy.float32).min),
            'default_nan': float(numpy.finfo(numpy.float32).min),
            'target_pixel_size':
            (0.0027777777777777778, -0.0027777777777777778),
            'resample_method': 'near',
            'target_raster_path': "esa2000_n_retention.tif",
        },
        {
            'expression': 'raster1 - raster2',
            'symbol_to_path_map': {
                'raster1':
                r"C:\Users\Becky\Documents\geobon\ndr\stitch_worldclim_esa_2015_modified_load.tif",
                'raster2':
                r"C:\Users\Becky\Documents\geobon\ndr\stitch_worldclim_esa_2015_n_export.tif",
            },
            'target_nodata': float(numpy.finfo(numpy.float32).min),
            'default_nan': float(numpy.finfo(numpy.float32).min),
            'target_pixel_size':
            (0.0027777777777777778, -0.0027777777777777778),
            'resample_method': 'near',
            'target_raster_path': "esa2015_n_retention.tif",
        },
    ]
    for calc in calc_list:
        raster_calculations_core.evaluate_calculation(calc, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression': 'raster1*raster2',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\CV\2000_with_lspop2017\cv_value_esa2000ls17.tif",
            'raster2':
            r"C:\Users\Becky\Documents\geobon\CV\2000_with_lspop2017\cv_pop_esa2000ls17.tif",
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_pixel_size': (0.00277777780000000021, -0.00277777780000000021),
        'resample_method': 'near',
        'target_raster_path': "coastal_risk_reduction_esa2000ls17.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    wgs84_srs = osr.SpatialReference()
    wgs84_srs.ImportFromEPSG(4326)

    single_expression = {
        'expression': 'raster1*raster2',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\CV\2000\cv_value_esa2000.tif",
            'raster2':
            r"C:\Users\Becky\Documents\geobon\CV\2000\cv_pop_esa2000.tif",
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_pixel_size': (0.00277777780000000021, -0.00277777780000000021),
        'resample_method': 'near',
        'target_projection_wkt': wgs84_srs.ExportToWkt(),
        'target_raster_path': "coastal_risk_reduction_esa2000.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression': 'raster1*raster2',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\CV\2000_with_lspop2017\cv_value_esa2000ls17.tif",
            'raster2':
            r"C:\Users\Becky\Documents\geobon\CV\2000_with_lspop2017\cv_pop_esa2000ls17.tif",
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_pixel_size': (0.00277777780000000021, -0.00277777780000000021),
        'resample_method': 'near',
        'target_raster_path': "coastal_risk_reduction_esa2000ls17.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression': 'raster1*raster2',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\CV\2018\cv_value_esa2018.tif",
            'raster2':
            r"C:\Users\Becky\Documents\geobon\CV\2018\cv_pop_esa2018.tif",
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_raster_path': "coastal_risk_reduction_esa2018.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression': 'raster1*raster2*raster3*(raster4>0)+(raster4<1)*-9999',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\pollination\monfreda_2008_yield_poll_dep_ppl_fed_5min.tif",
            'raster2':
            r"C:\Users\Becky\Documents\geobon\pollination\poll_suff_ag_coverage_prop_10s_ESACCI-LC-L4-LCCS-Map-300m-P1Y-2018-v2.1.1.tif",
            'raster3':
            r"C:\Users\Becky\Documents\geobon\pollination\esa_pixel_area_ha.tif",
            'raster4':
            r"C:\Users\Becky\Documents\geobon\pollination\ESACCI-LC-L4-LCCS-Map-300m-P1Y-2018-v2.1.1_ag_mask.tif"
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_pixel_size': (0.00277777780000000021, -0.00277777780000000021),
        'resample_method': 'near',
        'target_raster_path': "pollination_ppl_fed_on_ag_10s_esa2018.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression': 'raster1*raster2*raster3*(raster4>0)+(raster4<1)*-9999',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\pollination\monfreda_2008_yield_poll_dep_ppl_fed_5min.tif",
            'raster2':
            r"C:\Users\Becky\Documents\geobon\pollination\poll_suff_ag_coverage_prop_10s_ESACCI-LC-L4-LCCS-Map-300m-P1Y-2000-v2.0.7.tif",
            'raster3':
            r"C:\Users\Becky\Documents\geobon\pollination\esa_pixel_area_ha.tif",
            'raster4':
            r"C:\Users\Becky\Documents\geobon\pollination\ESACCI-LC-L4-LCCS-Map-300m-P1Y-2000-v2.0.7_ag_mask.tif"
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_pixel_size': (0.00277777780000000021, -0.00277777780000000021),
        'resample_method': 'near',
        'target_raster_path': "pollination_ppl_fed_on_ag_10s_esa2000.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression': 'raster1*raster2',
        'symbol_to_path_map': {
            'raster1':
            r"C:\Users\Becky\Documents\geobon\pollination\monfreda_2008_yield_poll_dep_ppl_fed_5min.tif",
            'raster2':
            r"C:\Users\Becky\Documents\geobon\pollination\esa_pixel_area_ha.tif",
        },
        'target_nodata': float(numpy.finfo(numpy.float32).min),
        'default_nan': float(numpy.finfo(numpy.float32).min),
        'target_pixel_size': (0.00277777780000000021, -0.00277777780000000021),
        'resample_method': 'near',
        'target_raster_path': "monfreda_prod_poll_dep_ppl_fed_10sec.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return

    single_expression = {
        'expression':
        '10000(va/486980 + en/3319921 + fo/132654) / 3',  # not sure why but this is 10,000 x smaller than previous version
        'symbol_to_path_map': {
            'en':
            r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\monfreda_2008_yield_poll_dep_en_10km_md5_a9511553677951a7d65ebe0c4628c94b.tif",
            'fo':
            r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\monfreda_2008_yield_poll_dep_fo_10km_md5_20f06155618f3ce088e7796810a0c747.tif",
            'va':
            r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\monfreda_2008_yield_poll_dep_va_10km_md5_3e38e4a811f79c75499e759ccebec6fc.tif",
        },
        'target_nodata': -9999,
        'default_nan': -9999,
        'target_raster_path': "monfreda_2008_yield_poll_dep_ppl_fed_5min.tif",
    }

    raster_calculations_core.evaluate_calculation(single_expression,
                                                  TASK_GRAPH, WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()

    return
def main():
    """Write your expression here."""

    #coarse average of pollination dependence

    #    calculation_list = [
    #        {
    #            'expression': 'polldep/total',
    #            'symbol_to_path_map': {
    #                'polldep': r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\monfreda_2008_yield_poll_dep_en_10km.tif",
    #                'total':r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\monfreda_2008_yield_total_en_10km.tif"
    #            },
    #            'target_nodata': -9999,
    #            'default_nan': -9999,
    #            'target_raster_path': "prop_poll_dep_10km_en.tif",
    #            'target_pixel_size': (0.08333300100000000377, -0.08333300100000000377),
    #        },
    #        {
    #            'expression': 'polldep/total',
    #            'symbol_to_path_map': {
    #                'polldep': r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\monfreda_2008_yield_poll_dep_fo_10km.tif",
    #                'total':r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\monfreda_2008_yield_total_fo_10km.tif"
    #            },
    #            'target_nodata': -9999,
    #            'default_nan': -9999,
    #            'target_raster_path': "prop_poll_dep_10km_fo.tif",
    #            'target_pixel_size': (0.08333300100000000377, -0.08333300100000000377),
    #        },
    #        {
    #            'expression': 'polldep/total',
    #            'symbol_to_path_map': {
    #                'polldep': r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\monfreda_2008_yield_poll_dep_va_10km.tif",
    #                'total':r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\monfreda_2008_yield_total_va_10km.tif"
    #            },
    #            'target_nodata': -9999,
    #            'default_nan': -9999,
    #            'target_raster_path': "prop_poll_dep_10km_va.tif",
    #            'target_pixel_size': (0.08333300100000000377, -0.08333300100000000377),
    #        },
    #
    #    ]
    #
    #    for calculation in calculation_list:
    #        raster_calculations_core.evaluate_calculation(
    #            calculation, TASK_GRAPH, WORKSPACE_DIR)
    #
    #    TASK_GRAPH.join()
    #    TASK_GRAPH.close()
    #
    #    return

    #    single_expression = {
    #        'expression': '(va*(486980) + en*(3319921) + fo*(132654)) / (486980 + 3319921 + 132654)',
    #        'symbol_to_path_map': {
    #            'va': r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\prop_poll_dep_10km_va.tif",
    #            'en': r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\prop_poll_dep_10km_en.tif",
    #            'fo': r"C:\Users\Becky\Documents\raster_calculations\ag_work\pollination\prop_poll_dep_10km_fo.tif",
    #        },
    #        'target_nodata': -9999,
    #        'default_nan': -9999,
    #        'target_raster_path': "prop_poll_dep_10km_weightedavg.tif",
    #        'target_pixel_size': (0.08333333333333332871, -0.08333333333333332871),
    #    }
    #
    #    raster_calculations_core.evaluate_calculation(
    #        single_expression, TASK_GRAPH, WORKSPACE_DIR)
    #
    #    TASK_GRAPH.join()
    #    TASK_GRAPH.close()
    #
    #    return

    raster_calculation_list = [
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_va_10s_cur_md5_8e327c260369864d5a38e03279574fb2.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_en_10s_cur_md5_a33bd27cb092807455812b6474b88ea3.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_fo_10s_cur_md5_f0660f3e3123ed1b64a502046e4246bd.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_potential_10s_cur.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_va_10s_ssp1_md5_dd661fc2b46dcaae0291dc8b095162af.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_en_10s_ssp1_md5_e38c0f651fd99cc5823c4d4609f3605a.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_fo_10s_ssp1_md5_259247bc5e53dfa4e299f84fcdd970f0.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_potential_10s_ssp1.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_va_10s_ssp3_md5_9d199ecc7cae7875246fb6c417d36c25.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_en_10s_ssp3_md5_c5a582a699913836740b4d8eebff44cc.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_fo_10s_ssp3_md5_8ebf271cbdcd53561b0457de9dc14ff7.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_potential_10s_ssp3.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_va_10s_ssp5_md5_96374887d44c5f2bd02f1a59bc04081b.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_en_10s_ssp5_md5_e97f7cd3bb6d92944f234596718cb9c9.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_potential_fo_10s_ssp5_md5_15dc8849799d0413ab01a842860515cc.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_potential_10s_ssp5.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_va_10s_cur_md5_c8035666f5a6e5c32fb290df989183e2.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_en_10s_cur_md5_d3e8bc025523d74cd4258f9f954b3cf4.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_fo_10s_cur_md5_857aa9c09357ad6614e33f23710ea380.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_deficit_10s_cur.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_va_10s_ssp1_md5_d9b620961bfe56b7bfb52ee67babe364.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_en_10s_ssp1_md5_2ae004b2e3559cdfc53ed754bfd6b33e.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_fo_10s_ssp1_md5_08c28442f699f35ab903b23480945785.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_deficit_10s_ssp1.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_va_10s_ssp3_md5_0a6744d0b69ec295292a84c8383290d5.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_en_10s_ssp3_md5_10ce2f30db2ac4a97266cfd075e67fa9.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_fo_10s_ssp3_md5_19a2a1423c028e883a477e6b73524da5.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_deficit_10s_ssp3.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_va_10s_ssp5_md5_33e0cd5f3a846d1532a44c56c2d4ade5.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_en_10s_ssp5_md5_b5fb16243689850078961e0228f774f2.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/prod_poll_dep_unrealized_fo_10s_ssp5_md5_155e5e1aab3c226a693973efc41400fc.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_deficit_10s_ssp5.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_va_30s_cur_md5_5dc3b32361e73deefe0c1d3405d1887b.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_en_30s_cur_md5_a0216f9f217a5960179720585720d4fa.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_fo_30s_cur_md5_01077b8ee4bae46e1d07c23728d740fc.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_nut_req_30s_cur.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_en_30s_ssp1_md5_2dec3f715e60666797c3ec170ee86cce.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_en_30s_ssp1_md5_2dec3f715e60666797c3ec170ee86cce.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_fo_30s_ssp1_md5_655aa774ebd352d5bf82336c4c4a72ab.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_nut_req_30s_ssp1.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_va_30s_ssp3_md5_024b2aa9c2e71e72c246c34b71b75bf8.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_en_30s_ssp3_md5_2cd38b2e5b32238f24b635dfdd70cf22.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_fo_30s_ssp3_md5_3f8b935a55836c44f7912f5520699179.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_nut_req_30s_ssp3.tif",
            'build_overview': True,
        },
        {
            'expression': '(va/486980 + en/3319921 + fo/132654) / 3',
            'symbol_to_path_map': {
                'va':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_va_30s_ssp5_md5_4267bfdd9392dff1d8cfd30f504567d9.tif',
                'en':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_en_30s_ssp5_md5_279c0ec49113c0036d3dc8c9ef387469.tif',
                'fo':
                'https://storage.googleapis.com/ipbes-natcap-ecoshard-data-for-publication/nut_req_fo_30s_ssp5_md5_8b1dfa322e4e9202711e8057a34c508e.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_nut_req_30s_ssp5.tif",
            'build_overview': True,
        },
    ]

    for calculation in raster_calculation_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()

    derived_raster_calculation_list = [
        {
            'expression': '(potential-deficit)/potential',
            'symbol_to_path_map': {
                'potential': 'outputs/pollination_potential_10s_cur.tif',
                'deficit': 'outputs/pollination_deficit_10s_cur.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_NC_10s_cur.tif",
            'build_overview': True,
        },
        {
            'expression': '(potential-deficit)/potential',
            'symbol_to_path_map': {
                'potential': 'outputs/pollination_potential_10s_ssp1.tif',
                'deficit': 'outputs/pollination_deficit_10s_ssp1.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_NC_10s_ssp1.tif",
            'build_overview': True,
        },
        {
            'expression': '(potential-deficit)/potential',
            'symbol_to_path_map': {
                'potential': 'outputs/pollination_potential_10s_ssp3.tif',
                'deficit': 'outputs/pollination_deficit_10s_ssp3.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_NC_10s_ssp3.tif",
            'build_overview': True,
        },
        {
            'expression': '(potential-deficit)/potential',
            'symbol_to_path_map': {
                'potential': 'outputs/pollination_potential_10s_ssp5.tif',
                'deficit': 'outputs/pollination_deficit_10s_ssp5.tif',
            },
            'target_nodata': -1,
            'target_raster_path': "outputs/pollination_NC_10s_ssp5.tif",
            'build_overview': True,
        },
    ]

    for calculation in derived_raster_calculation_list:
        raster_calculations_core.evaluate_calculation(calculation, TASK_GRAPH,
                                                      WORKSPACE_DIR)

    TASK_GRAPH.join()
    TASK_GRAPH.close()