Repository for generating and running heat-resilient infrastructure scenarios (street trees, cool roofs, shade structures, and baseline workflows).
This repo uses:
chri.ymlfor the Conda environment (R + geospatial system libraries)install_packages.Rfor R package installation
conda env create -f chri.yml
conda activate chriIf the environment already exists:
conda env update -f chri.yml
conda activate chriWith the chri conda environment active, run:
Rscript install_packages.RThis may take some time!
Python is not currently required for the active pipeline.
On EC2 instances with appropriate IAM roles, AWS and GEE may not require manual login.
export AWS_PROFILE=cities-data-dev
aws sso login
aws s3 lsgcloud auth application-default login
gcloud config set project citiesindicators
gcloud auth application-default set-quota-project citiesindicatorsAlso ensure your account has Earth Engine access.
Main CLI entrypoint:
run-scenarios.R
Example:
Rscript run-scenarios.R \
--plan 'BRA-Campinas@accelerator_area|aoi_path="http//wri-cities-tcm...."|copy_baseline=urban_extent:
baseline:baseline[g],
trees:pedestrian-achievable-90pctl[gdcp],
cool-roofs:all-buildings[gdcp],
cool-roofs_trees:all-buildings_pedestrian-achievable-90pctl[gdcp];
ZAF-Cape_Town@business_district|aoi_path=DEFAULT|copy_baseline=false:
cool-roofs:all-buildings[gdcp]'To automatically terminate the EC2 instance after all groups finish add
EC2_TERMINATE_ON_COMPLETE=true:
EC2_TERMINATE_ON_COMPLETE=true Rscript run-scenarios.R --plan ....
The plan syntax is:
{city_id}@{aoi_id}|aoi_path={s3_object_url}|copy_baseline={baseline_aoi_id}:
{infrastructure_id}:{scenario_id}[flags]Flags inside [ ]:
g: generate scenario data (only flag that can be used for baseline)d: download datac: run CTCMp: process and upload outputs
Currently available infrastructures and scenarios are:
| infra_id | scenario_id | Definition |
|---|---|---|
| baseline | baseline* | Baseline layers |
| trees | pedestrian-achievable-90pctl** | Street trees achievable |
| cool-roofs | all-buildings | Cool roofs on all buildings |
| large-buildings | Cool roofs on large buildings | |
| cool-roofs_trees | all-buildings_pedestrian-achievable-90pctl | Combination cool roofs and street trees achievable |
* Current behavior if baseline is flagged to generate is to process existing baseline data to the necessary CCL layers and calculate metrics. This does not run the baseline CTCM.
** Running the pedestrian-achievable-90pctl tree scenario requires that the Opportunity Layers have been generated for a city. Generation of the scenario requires a geojson file that is created during this process.
Notes:
aoi_pathcan be provided as an S3 object URL. If not specified, the default is:city_projects/{CITY}/{AOI}/scenarios/baseline/baseline/aoi__baseline__baseline.geojsonin thewri-cities-tcmbucket where{CITY}is the city name and{AOI}is the AOI name specified in the script invocation.- Scenario runs require baseline data in the target AOI folder. Copy data from
an existing baseline run by setting
copy_baselineper city block inside--planusing|copy_baseline=.... Usefalseto disable,true(maps tourban_extent), or an AOI name such asbusiness_district. If omitted,copy_baselineis disabled.
The tree scenario generation may take a long time to run and may occasionally fail. The code works by iterating over a grid and you can resume the scenario generation from the point where it failed. Simply include TREE_RESUME_AOI_GRID_ID=xx before the script invocation where xx is the ID of the gridcell where the failure occured.
EC2_TERMINATE_ON_COMPLETE=true TREE_RESUME_AOI_GRID_ID=640 Rscript run-scenarios.R --plan 'BRA-Teresina@accelerator_area_big|aoi_path=DEFAULT|copy_baseline=false:
trees:pedestrian-achievable-90pctl[gdcp],
cool-roofs:all-buildings[gdcp]'
Use screen or nohup so jobs survive SSH disconnects.
screen -S chri
Rscript run-scenarios.R --plan '...'
# Detach: Ctrl+A then D
screen -r chrinohup Rscript run-scenarios.R --plan '...' > run.log 2>&1 &
tail -f run.logAn AOI exists for testing the workflow—a small area in Cape Town. The aoi is sized
such that it requires only one CTCM tile and has features that meet the requirements
to get updated in all scenario scripts. The AOI boundary file is found at https://wri-cities-tcm.s3.us-east-1.amazonaws.com/OpenUrban/ZAF-Cape_Town_TEST/boundaries/city_polygon.geojson.
To generate all scenarios for the test AOI, run:
Rscript run-scenarios.R \
--plan 'ZAF-Cape_Town@TEST|aoi_path="https://wri-cities-tcm.s3.us-east-1.amazonaws.com/OpenUrban/ZAF-Cape_Town_TEST/boundaries/city_polygon.geojson"|copy_baseline=urban_extent:
baseline:baseline[g],
trees:pedestrian-achievable-90pctl[gdcp],
cool-roofs:all-buildings[gdcp],
cool-roofs_trees:all-buildings_pedestrian-achievable-90pctl[gdcp]'