Skip to content

Instantly share code, notes, and snippets.

@richpsharp
Created February 26, 2021 23:42
Show Gist options
  • Select an option

  • Save richpsharp/4287ca2ceba5a31f7334df7cab5a4569 to your computer and use it in GitHub Desktop.

Select an option

Save richpsharp/4287ca2ceba5a31f7334df7cab5a4569 to your computer and use it in GitHub Desktop.
Running a batch of pollination runs.
"""Run pollination model on a variety of scenarios
All data should be in a "data" subdirectory in the same directory as this
script.
Run it with docker as the following:
docker container run -it --rm --name pollination_kelley -v `pwd`:/usr/local/workspace therealspring/inspring:latest pollination_simulations.py
"""
import logging
import natcap.invest.pollination
from osgeo import gdal
gdal.SetCacheMax(2**27)
logging.basicConfig(
level=logging.DEBUG,
format=(
'%(asctime)s (%(relativeCreated)d) %(processName)s %(levelname)s '
'%(name)s [%(funcName)s:%(lineno)d] %(message)s'))
LOGGER = logging.getLogger(__name__)
logging.getLogger('taskgraph').setLevel(logging.INFO)
if __name__ == '__main__':
for args in [
{
"farm_vector_path": "./data/coffee_iCAFE_2012_md5_8f3644b1353587ef9e30fb61c0386f72.shp",
"guild_table_path": "./data/CostaRica_Pollination_GuildTable_14guilds.csv",
"landcover_biophysical_table_path": "./data/Pollination_Biophysical_baseline_loag.csv",
"landcover_raster_path": "./data/cobertura_IMN_agpppc_fill_water_ND_TFA1000_streams_CR.tif",
"results_suffix": "_pollin_baseline_loag_9Feb21"
},
{
"farm_vector_path": "./data/coffee_iCAFE_2012_md5_8f3644b1353587ef9e30fb61c0386f72.shp",
"guild_table_path": "./data/CostaRica_Pollination_GuildTable_14guilds.csv",
"landcover_biophysical_table_path": "./data/Pollination_Biophysical_baseline_medag.csv",
"landcover_raster_path": "./data/cobertura_IMN_agpppc_fill_water_ND_TFA1000_streams_CR.tif",
"results_suffix": "_pollin_baseline_medag_9Feb21"
},
{
"farm_vector_path": "./data/coffee_iCAFE_2012_md5_8f3644b1353587ef9e30fb61c0386f72.shp",
"guild_table_path": "./data/CostaRica_Pollination_GuildTable_14guilds.csv",
"landcover_biophysical_table_path": "./data/Pollination_Biophysical_scenario_loag.csv",
"landcover_raster_path": "./data/CR_LULC_scenario_10m.tif",
"results_suffix": "_pollin_scenario_loag_9Feb21"
},
{
"farm_vector_path": "./data/coffee_iCAFE_2012_md5_8f3644b1353587ef9e30fb61c0386f72.shp",
"guild_table_path": "./data/CostaRica_Pollination_GuildTable_14guilds.csv",
"landcover_biophysical_table_path": "./data/Pollination_Biophysical_scenario_medag.csv",
"landcover_raster_path": "./data/CR_LULC_scenario_10m.tif",
"results_suffix": "_pollin_scenario_medag_9Feb21"
}]:
natcap.invest.pollination.execute({**args, **{'workspace_dir': args['results_suffix']}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment