{"cells":[{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"!pip --disable-pip-version-check install plotly==4.13.0 -q\n!pip --disable-pip-version-check install vega_datasets -q\n\nimport pandas as pd\nfrom google.cloud import storage\nimport geopandas as gpd\nimport plotly.express as px\nimport altair as alt\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Keys to Unlocking Climate Change: A Microlevel Urban Approach towards Macrolevel Global Sustainability "},{"metadata":{},"cell_type":"markdown","source":"## Table of Contents\n* [Introduction](#section-introduction)\n* [CDP Challenge Problem](#section-cdp-challenge)\n* [Submission Overview](#section-submission-overview)\n* [Literature Review](#section-introduction1)\n* [Methodology of Developing Key Performance Indicators](#section-methodology)\n* [External Data Sources](#section-external-data)\n* [CDP Sustainability Index Methodology](#section-index)\n    - [Buiding the CDP Sustainability Index](#section-index-sub)\n* [KPI Areas of Concentration](#section-kpi)\n    - [Renewable Energy](#section-one)\n    - [Water](#section-two)\n    - [Governance](#section-three)\n    - [Adaptation](#section-four)\n    - [Emissions](#section-five)\n    - [Mitigation Actions](#section-six)\n    - [Climate Hazards](#section-seven)\n    - [Opportunities](#section-eight)\n* [CDP Sustainability Index Results](#section-index-results)\n\n"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-introduction\"></a>\n\n## Introduction\nEfforts to deal with the consequences of climate change and the promotion of sustainable development, particularly in developing countries, often have related goals. However, achieving such goals first requires a change in policy, the development of actionable plans, continuous learning and cooperation at a micro level within cities towards the creation and development at a macro level of an environmentally sustainable global society. In order to plan and make actionable targets, there are three factors to consider; the current state of a problem, the risk associated of further exposure to it, and finally the level of adaptability to pivot and deal with the outcomes. \n"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-cdp-challenge\"></a>\n\n## CDP Challenge\n\nCDP is a global non-profit that drives companies and governments to reduce their greenhouse gas emissions, safeguard water resources, and protect forests. Each year, CDP takes the information supplied in its annual reporting process and scores companies and cities based on their journey through disclosure and towards environmental leadership.\nCDP houses the world’s largest, most comprehensive dataset on environmental action. As the data grows to include thousands more companies and cities each year, there is increasing potential for the data to be utilized in impactful ways. Because of this potential, CDP is excited to launch an analytics challenge for the Kaggle community. Data scientists will scour environmental information provided to CDP by disclosing companies and cities, searching for solutions to our most pressing problems related to climate change, water security, deforestation, and social inequity.\n\n* How do you help cities adapt to a rapidly changing climate amidst a global pandemic, but do it in a way that is socially equitable?\n* What are the projects that can be invested in that will help pull cities out of a recession, mitigate climate issues, but not perpetuate racial/social inequities?\n* What are the practical and actionable points where city and corporate ambition join, i.e. where do cities have problems that corporations affected by those problems could solve, and vice versa?\n* How can we measure the intersection between environmental risks and social equity, as a contributor to resiliency?\n\nDevelop a methodology for calculating key performance indicators (KPIs) that relate to the environmental and social issues that are discussed in the CDP survey data. Leverage external data sources and thoroughly discuss the intersection between environmental issues and social issues. Mine information to create automated insight generation demonstrating whether city and corporate ambitions take these factors into account.\n"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-submission-overview\"></a>\n\n## Submission Overview\nThis notebook consists of the following sections:\n\n**Literature review**: this section discusses the intersection between environmental issues and social issues at a high-level. A more thorough discussion is found relative to each of our KPIs that have been identified within their respective sections.\n\n**Key Performance Indicator Methodology**: this section discusses the overarching criteria that has been established for setting out KPIs and their various types. Again, a more thorough discussion of the methodology is found in each KPI section. Within this section you will also find a chart with clickable links leading to the various indicators.\n\n**CDP Sustainability Index Methodology**: this section covers the automated insight generation system that has been developed based on the KPIs that have been identified. The section discusses in detail how the index was built and indices have been used as a reference to help build this model.\n\n**Key Performance Indicators**: the section covers each of the key performance indicators that have been assessed.\n\n**CDP Sustainability Index Results**: this section covers the complete automated insight generation system that has been developed based on the KPIs that have been identified. "},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-introduction1\"></a>\n\n## Literature Review\nMany studies have shown that climate change has significantly worsened global economic inequality. This increase in inequality is a result of a variety of factors that are not limited to the impact of global warming on annual economic growth, a historical disparity in energy consumption across many regions around the world, increase in population growths, disparities in natural hazard risks and the ability to deal with the consequences of such hazards. (1) While many different regions of the world aim and set targets to reduce the impact or progression of climate change, their mitigation policies can in turn adversely affect those in lower socio-economic groups. In order to be an effective agent of change, governments need to consider the often indirect and complex social issues that are interconnected with climate change by having multi-stakeholder engagement, careful planning and willingly adapting their plans to changing environments. (2) This image below from the HappyCity Index demonstrates the connections between somt of the internal and external factors.\n"},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"import os\nfrom IPython.display import Image\nImage(filename=\"../input/dataset-1/metho.png\", width= 900, height=700)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"When assessing social inequality in a region, it is important to recognize that many of the indicators intersect and overlap with each other. For example, inequality in wealth can influence access to health care, housing opportunities, access to education and job opportunities. (2) This too can be considered when discussing indicators or determinants that influence climate change. For example, increasing levels of C02 emissions can have serious consequences for humans and their environment. Potential effects on human activity can results in increases in water depletion, a greater number of hazardous weather events which then lead to infrastructure damage, changes in food supply, and water quality. Building an automated insight generation system dependent on performance indicators that considers these factors, can help cities develop or adapt their plan and can also assess the efficacy of plans that are also in progress.\n\nReferences\n\n(1)- https://www.un.org/esa/desa/papers/2017/wp152_2017.pdf \n\n(2)- https://www.tandfonline.com/doi/full/10.1080/14693062.2019.1596873"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-methodology\"></a>\n\n## Methodology of Developing Key Performance Indicators\n\nWhen completing our explorative data analysis of the CDP city data, we recognized 8 thematic areas from the questionnaire that we wanted to focus on in our analysis and development of our KPIs. These 8 areas relate to both environmental and social issues in the assessment of cities participating in the CDP surveys. Within these areas, there are KPIs that are related to direct CDP survey responses while others explore opportunities to further delve into the assessment of the efficacy of a city meeting their goals. \n\nThe framework for developing effective performance measurements was to link indicator outputs to potential actionable outcomes that participating cities were already partaking in or could potentially invest in towards creating an environmentally sustainable society. A key part of this framework was to also identify, where possible, the potential social impact within a city that intersects and stands to be affected by the established KPI factors. As a result, the KPIs that have been developed were based on the following criteria:\n\n1.\tThe indicator is already being measured or could be measure and the data is currently available\n2.\tThere are appropriate baselines that exist for comparison to measure between cities\n3.\tThe measurement can show change over time for adaptation and modification of actionable outcomes\n4.\t The indicator is meaningful on both at a local (city) and global (country) scale \n\nOur KPIs also fall under one of three types of indicators:\n\n1.\tInput KPIs: are measures of the resources that go into a service\n2.\tOutput KPIs: are direct measures of the results of the deployment of resources. Often referred to as service management KPIs, they measure short-term changes as a result of inputs\n3.\tImpact KPIs: reflect long-term effects that are closely related to the purpose of the activity. Many cannot be measured within program timeframes. They usually involve changes to well-being or performance as a result of behaviour change.\n\n**NOTE:** When developing our KPIs we recognized that KPIs directly related to the CDP survey data questions were all input KPIs.\n\nIn total we developed 39 KPIs amongst the 8 areas of concentration we identified. For each of our impact and output KPIs we discuss the rationale and relevance, societal impact, methodology, units of measurement and data sources. Each of our input KPI’s are directly drawn from the CDP City Questionare responses. The questions involved primarily contain binary responses or are drawn from fixed set of response options. \n"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-external-data\"></a>\n\n## External Data Sources\n\n\n\n\n\n"},{"metadata":{},"cell_type":"markdown","source":"### 1. Environmental Insights Explorer\n\nGoogle’s Environmental Insights Explorer (EIE) uses exclusive data sources and modeling capabilities in a freely available platform to help cities measure emission sources, run analyses, and identify strategies to reduce emissions — creating a foundation for effective action. The insights are a modeled estimate based on actual measurements of activity and infrastructure (the same underlying information that is made available in Google Maps). They use advanced machine learning techniques to understand how people are moving around the world, and then apply scaling factors, efficiency and emissions factors.\n\n***Considerations:***\nEIE provides comprehensive data for 125 cities that are made public. Data for over 3000 cities are available by request for cities involved and research institutes. \n\n***Data Usage:***\nOpen sourced data for Google's EIE is available for each city on its webpage. For the analysis in this notebook, each publicly available dataset was downloaded and mapped to the corresponding CDP city.\n\n[Source](https://insights.sustainability.google/)\n"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"from vega_datasets import data\n\nsource = pd.read_csv(\"../input/dataset-1/insight_explorer_cities.csv\")\ncountries = alt.topo_feature(data.world_110m.url, feature='countries')\n\n# US states background\nbackground = alt.Chart(countries).mark_geoshape(\n    fill='lightgray',\n    stroke='white'\n).properties(\n    width=500,\n    height=300\n)\n\n# airport positions on background\npoints = alt.Chart(source).mark_circle().encode(\n    longitude='longitude:Q',\n    latitude='latitude:Q',\n    size=alt.Size('Population_2018:Q', title='Population Size'),\n    color=alt.value('steelblue'),\n    tooltip=['City:N','Population_2018:Q']\n).properties(\n    title='Google Insight Explorer Cities'\n)\n\nbackground + points","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### 2. Project Sunroof\nProject Sunroof primarily works to encourage the private adoption of solar energy by providing a set of tools to facilitate the purchase and installation of solar panels. Using data from Google Maps to calculate shadows from nearby structures and trees and taking into account historical weather and temperature patterns, the Project Sunroof website calculates how much money a user can expect to save yearly by making use of solar power. In addition, the Project Sunroof website also provides a list of local solar power retailers capable of installing solar panels in that area\n\n***Considerations:***\nAt this current time, rooftop solar potential data is only available for cities in the United States.\n\n***Data Usage:***\nOpen sourced data for Project Sunroof is available at the Census Tract and postal code level and hosted as part of Google's BigQuery public datasets. For the analysis in this notebook, geospatial analysis was completed to map the Census Tract data to the regions involved in the CDP study.\n\n[Source](https://www.google.com/get/sunroof)\n"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import os\nfrom IPython.display import Image\nImage(filename=\"../input/dataset-1/download (7).png\", width= 900, height=700)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### 3. Global Assessment Report on Disaster Risk Reduction\nThe UN Global Assessment Report on Disaster Risk Reduction (GAR) is the flagship report of the United Nations on worldwide efforts to reduce disaster risk. The GAR is published biennially by the UN Office for Disaster Risk Reduction (UNDRR), and is the product of the contributions of nations, public and private disaster risk-related science and research, amongst others.The GAR Atlas presents the output of a Global Risk Model (GRM) that can estimate the disaster risk associated with different kinds of hazard faced by national economies throughout the world.\n\n***Considerations:***\nThe risk assessments are provided at a large global extent. We leveraged this data in combination with other indicators effecting climate risk for our index. However, if one were to only use this as a sole data driver for a model, caution needs to be taken for extremely localized decisions.\n\n***Data Usage:***\nData for the GAR Atlas was obtained from its website. Geospatial analysis was leveraged to generate an aggregated risk measurement for the regions involved in the CDP survey.\n\n[Source](https://preview.grid.unep.ch/)\n"},{"metadata":{},"cell_type":"markdown","source":"\n### 4. Aqueduct Water Risk Atlas\nAqueduct's global water risk mapping tool helps companies, investors, governments, and other users understand where and how water risks and opportunities are emerging worldwide. The Atlas uses a robust, peer reviewed methodology and the best-available data to create high-resolution, customizable global maps of water risk.\n\n***Data Usage:***\nGeospatial analysis was leveraged to extract the water risk metrics for regions in the CDP survey.\n\n[Source](https://www.wri.org/aqueduct#aqueduct-tools)\n"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"from vega_datasets import data\n\n\n\nsource = pd.read_csv(\"../input/dataset-1/aquaduct.csv\")\nsource = source.rename(columns={\"udw_score\": \"Drinking Water Risk (0-5)\", \n                                \"state_name\": \"State\", \n                                \"county_name\": \"County\"\n                               })\ncounties = alt.topo_feature(data.us_10m.url, 'counties')\n\nalt.Chart(counties).mark_geoshape().encode(\n    color=alt.Color('Drinking Water Risk (0-5):Q',\n              scale=alt.Scale(domain=[0,5])),\n    tooltip=['State:N', \"County:N\", 'Drinking Water Risk (0-5):Q']\n).transform_lookup(\n    lookup='id',\n    from_=alt.LookupData(source, 'id', [\"Drinking Water Risk (0-5)\", \"County\", \"State\"])\n).project(\n    type='albersUsa'\n).properties(\n    title='Drinking Water Risk',\n    width=1000, height = 700\n               )","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### 5. Organisation for Economic Co-operation and Development\nStatistics include data and metadata for OECD countries and selected non-member economies at varying levels of regional granularity.\n\n***Considerations:***\nFor this analysis data was extracted for metropolitan regions when available. Smaller cities and regions maybe under-represented and would require the use of inference from national statistics.\n\n***Data Usage:***\nGeospatial analysis was leveraged to extract the metrics for regions in the CDP survey.\n\n[Source](https://stats.oecd.org/)\n\n"},{"metadata":{},"cell_type":"markdown","source":"### 6. Other Data Sources\n**1. Global Wind Atlas** GWA is an open-source dataset to help policymakers and investors identify potential high-wind areas for wind power generation virtually anywhere in the world, and perform preliminary calculations. Granular datasets for wind power estimates are available at a global scale.[Source](https://globalwindatlas.info/)\n\n**2. BigQuery Public Data Sets** BigQuery host open-source data sets from a wide-variety of data providers. [Source](https://cloud.google.com/public-datasets)\n\n**3. Green Space**\nGreen area per capita is calculated from Green area per million people and city population data source from OECD. [Source](https://data.humdata.org/dataset/green-area-per-capita-square-meters-per-capita)\n\n"},{"metadata":{},"cell_type":"markdown","source":"## Key Performance Indicators\n"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-toc\"></a>\n\n<table background=none >\n    <thead>\n        <tr>\n            <th style=\"text-align:center\">Section</th>\n            <th style=\"text-align:center\">KPI Name</th>\n            <th style=\"text-align:center\">Type</th>\n        </tr>\n    </thead>\n    <tbody>\n        <tr>\n            <td style=\"text-align:center\" rowspan=5>\n                <a href=\"#section-one\">1. Renewable Energy</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-one-one\"> 1.1 Set renewable energy target</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=2>Input KPI</td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-one-two\">1.2 Set energy efficiency target</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-one-three\">1.3 Rooftop Solar Potential</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=3>Output KPI</td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-one-four\">1.4 Wind Energy Potential</a>\n            </td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-one-five\">1.5 Renewable energy sources in electricity production</a>\n            </td>\n        </tr>\n                <tr>\n            <td style=\"text-align:center\" rowspan=6>\n                <a href=\"#section-two\">2. Water</a>\n                    </td>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-two-one\">2.1 Water resource management strategy present</a>\n                    </td>\n            <td style=\"text-align:center\" rowspan=2>Input KPI</td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-two-two\">2.2 Actions taken to reduce risk (when present)</a>       \n            </td></tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-two-three\">2.3 Water stress</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=4>Output KPI</td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-two-four\">2.4 Water depletion</a>\n            </td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-two-five\">2.5 Drinking Water Risk</a>\n            </td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-two-six\">2.6 Water Sanitation Risk</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-three\">3.0 Governance</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-three-one\">3.1 Goals & targets set for sustainability</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=1>Input KPI</td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-four\">4.0 Adaptation</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-four-one\">4.1 Creation of a climate change adaptation plan</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=1>Input KPI</td>\n        </tr>\n                <tr>\n            <td style=\"text-align:center\" rowspan=9>\n                <a href=\"#section-five\">5.0 Emissions</a>\n                    </td>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-five-one\">5.1 City-wide inventory present</a>\n                    </td>\n            <td style=\"text-align:center\" rowspan=3>Input KPI</td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-five-two\">5.2 City-wide inventory externally verified</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-five-three\">5.3 Detailed city-wide consumption-based inventory available</a>   \n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-five-four\">5.4 Energy usage for non-residential building</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=2>Output KPI</td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-five-five\">5.5 Energy usage for residential buildings</a>\n            </td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-five-six\">5.6 Total Degree Days</a>\n            </td><td style=\"text-align:center\" rowspan=1>Impact KPI</td></tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-five-seven\">5.7 Residential Emissions</a>\n            </td><td style=\"text-align:center\" rowspan=3>Output KPI</td></tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-five-eight\">5.8 Non-residential Emissions</a>\n            </td></tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-five-nine\">5.9 Transportation emissions by mode-share</a>\n            </td></tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=2>\n                <a href=\"#section-six\">6.0 Mitigation Actions</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-six-one\">6.1 Emission reduction targets in place</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=2>Input KPI</td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-six-two\">6.2 Emission reduction action plan in place</a>\n            </td></tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=10>\n            <a href=\"#section-seven\">7.0 Climate Hazards</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-seven-one\">7.1 Climate risk assessment complete</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=1>Input KPI</td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-seven-two\">7.2 Total population</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=9>Output KPI</td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-seven-three\">7.3 Percent of population living in poverty</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-seven-four\">7.4 Unemployment Rate</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-seven-five\">7.5 Household disposable income</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-seven-six\">7.6 Average yearly PM2.5</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-seven-seven\">7.7 Exposed economic capital stock</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-seven-eight\">7.8 Riverine flood risk</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-seven-nine\">7.9 Coastal flood risk</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-seven-ten\">7.10 Drought risk</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=5>\n                <a href=\"#section-eight\">8.0 Opportunities</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=1>\n                <a href=\"#section-eight-one\">8.1 Identified economic or social opportunities related to addressing climate change</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=2>\n                Input KPI\n            </td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-eight-two\">8.2 Collaboration with local businesses</a>\n            </td>\n        </tr>\n        <tr>\n            <td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-eight-three\">8.3 Green Space</a>\n            </td>\n            <td style=\"text-align:center\" rowspan=3>\n                Output KPI\n            </td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-eight-four\">8.4 Presence of a zero-emission zone</a>\n            </td>\n        </tr>\n        <tr><td style=\"text-align:center\" rowspan=1>\n            <a href=\"#section-eight-five\">8.5 Public transportation usage</a>\n            </td>\n        </tr>\n    </tbody>\n</table>\n\n"},{"metadata":{},"cell_type":"markdown","source":"Once measured, we developed an index that utilizes an interdisciplinary approach to highlight the intersection between environmental and social issues."},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-index\"></a>\n\n## CDP Sustainability Index Methodology\n\nIndices are helpful tools that can provide insights and help track the performance of something using composite indicators. A composite indicator is formed when individual indicators are compiled into a single index, on the basis of an underlying model of a multi-dimensional concept that is being measured. \n\nThere are currently a number of existing indices that tackle various aspects of climate change. The two that we identified as a foundation for to help build the CDP Sustainability Index are the following:\n\nClimate Change Performance Index (CCPI): the CCPI is an independent monitoring tool of countries’ climate protection performance. It aims to enhance transparency in international climate politics and enables the comparability of climate protection efforts and progress made by individual countries. The ranking results are defined by a country’s aggregated performance in 14 indicators within the four categories “GHG Emissions”, “Renewable Energy” and “Energy Use”, as well as on “Climate Policy”. (1)  \n\nEnvironmental Performance Index: provides a data-driven summary of the state of sustainability around the world. Using 32 performance indicators across 11 issue categories, the EPI ranks 180 countries on environmental health and ecosystem vitality (2)\n\nReferences:\n\n1: https://www.climate-change-performance-index.org/ \n\n2: https://epi.yale.edu/ \n"},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"import os\nfrom IPython.display import Image\nImage(filename=\"../input/dataset-1/CDP INDEX (1).png\", width= 900, height=700)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-index-sub\"></a>\n\n## Building the CDP Sustainability Index\n\nUsing our KPIs we developed an index that uses mix of quantitative and qualitative measures to evaluate each of CDP cities with respect to their current environmental performance across our 8 categories as well as their relative performance to their peer cities. \n\nTo develop the index, we used the [OECD’s handbook](https://www.oecd.org/els/soc/handbookonconstructingcompositeindicatorsmethodologyanduserguide.htm) as a guide to develop our methodology following an 8 step approach:\n\n1.\t**Theoretical Framework**: a theoretical framework is needed to combine individual indicators into a meaningful composite and to provide a basis for the selection of components. Our framework for our KPIs are discussed in more detail in the methodology section of the notebook.  \n\n2.\t**Data Selection**: the quality of composite indicators depends largely on the quality of individual indicators. Indicators should be selected on the basis of their analytical soundness, measurability, relevance to the phenomenon being measured, and relationship to each other. Our relevance, soundness, and measurability of our KPIs is discussed in further detail under each KPI section. The criteria for our KPIs are discussed in the methodology section.\n\n3.\t**Imputation of Missing Data**: in most statistical series, composite indicators are plagued by problems of missing values. In many cases, data are only available for a limited number of areas or only for certain data components. Missing values can render the composite indicator less reliable for the areas for which only limited information is available and can distort the relative standing of all indicators in the composite. For our index we account for missing data by using two approaches. (1) When there was sufficient regional data, we used a nearest neighbour approach to impute missing values (2) When the data for a certain KPI was only available for a limited subset of cities, we did not impute values given the risk of the value potentially representing incomparable areas (we took the average index of the remaining indicators)\n\n4.\t**Multivariate Analysis**: multivariate analysis can be helpful in assessing the suitability of the dataset and providing an understanding of the implications of the methodological choices (e.g. weighting, aggregation) during the development of a composite indicator. For our index, we considered the principal component/factor analysis, however due to the fact a significant amount of the input KPIs are binary indicators, this would affect the performance and usefulness of index. Instead we opted to use cluster analysis, to group comparable cities in terms of their similarity with respect to the different regional characteristics.  \n\n5.\t**Normalisation**: indicators are expressed in a variety of statistical units, ranges or scales. First, they must be adjusted on dimensions such as size/population/income and smoothed through time against cyclical variability. Next, they need to be put on a common basis to avoid adding up apples and pears. Normalisation serves this purpose. For our index we used a combination of normalisation techniques to ensure that cities and KPIs were compared appropriately. These techniques included min-max scaling and percentile ranking.\n\n6.\t**Weighting**: weights usually have an important impact on the composite indicator value and on the resulting ranking especially whenever higher weight is assigned to indicators on which some regions excel or fail. Weighting methods can be statistical, based on public/expert opinion, or both. For our index we used a relative weighing scheme that is in line with those used by the [Climate Change Performance Index](https://www.climate-change-performance-index.org/methodology), with modification made to accomodate the additional factors.\n\n7.\t**Aggregating Indicators**: aggregation combines the values of a set of indicators into a single summary ‘composite’ or ‘aggregate’ measure. For our index we took the average of the normalised scores.\n\n8.\t**Sensitivity Analysis**: sensitivity analysis quantifies the uncertainty caused by each individual assumption, which identifies particularly sensitive assumptions which might merit closer consideration. For our index we implemented a sensitivity assessment based on the imputation method leveraged. We compare the distributions of the index scores based on the two imputation schemes leveraged in order to assess the stability of the results. \n\n\nPlease see below a summary report documenting key findings of our CDP Index about each city which highlights the best performing cities, and making comparisons between regions. Using this index, cities can learn from each other as they establish their own policies and actions plan and pivot and make adaptations to existing plans to minimize their environmental footprint, accommodate population growth, promote economic opportunity all taking into account social inequality and creating opportunities for citizens within lower socioeconomic groups.\n\n"},{"metadata":{},"cell_type":"markdown","source":"Below you will find a radar plot of the Top 10 ranked cities in North America from our autogenerated CDP Sustainability Index.  You can double click on the legend to view the scores for each individual city. \n\nFor our full index results, please see [CDP Sustainability Index Results](#section-index-results)."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\ndf = df[df['imputation']==\"Regional\"]\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\nsubset_df = pd.melt(df, \n                    id_vars=['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region'], \n                    value_vars=[\"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"],\n        var_name='category', value_name='score').reset_index(drop=True)\n\nsubset_df[\"Region Name\"] = subset_df['Organization/City'] + \", \" + subset_df['Country']\n\nfig = px.line_polar(subset_df[(subset_df['Overall Rank (Regional)']<=10) & (subset_df['CDP Region']==\"North America\")], \n                    r=\"score\", theta=\"category\", color='Region Name', line_close=True,\n                    color_discrete_sequence=px.colors.qualitative.Plotly,\n                    template=\"plotly_dark\",)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-kpi\"></a>\n## KPI Areas of Concentration\n"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-one\"></a>\n    \n## 1. Renewable Energy \n\nRenewable energy comes from natural sources or processes that are constantly replenished. For example, sunlight or wind keep shining and blowing, even if their availability depends on time and weather. Many regions across the globe are increasingly evaluating the potential of harnessing renewable energy in an effort to displace the reliance and use of fossil fuels in the power sector as renewable energy offers the benefit of lower emissions of carbon and other types of pollution. Such expansion in renewables is happening at scales large and small, from rooftop solar panels on homes that can sell power back to the grid to giant offshore wind farms. There are even some entire rural communities that rely on renewable energy for heating and lighting. This concentration considers various types of renewable energy potential and the degree to which cities could harness this potential to produce a practical energy output.\n\nOur KPIs within this concentration are listed below.\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-one-one\"></a>\n\n### 1.1 Renewable Energy Target Set\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question assess whether the participating city has a renewable energy or electricity target.\n \n*Question 8.0 - Does your city have a renewable energy or electricity target?*\n\n\n#### Unit\n\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n* Do not know\n\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n#### Data Sources\n\nCDP Cities Questionaire"},{"metadata":{},"cell_type":"markdown","source":"#### Analysis\n\nWhen looking at the responses from the CDP Questionannire, question 8, we can see that although the total number of responses has decreased from 2019 to 2020, the ratio of cities indicating that they have or are planning to set a renewable energy or electricity target is stable. Part of the reason for a decrease in 2020, might be a result of the current COVID-19 pandemic. However, cities in East Asia are reporting higher respones of 'yes'or 'intending to undertake in the next two years'between 2019 and 2020. \n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/8.0_responses.csv\")\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-one-two\"></a>\n### 1.2 Energy Efficiency Target Set\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question asses whether the participating city has set an energy effeciency target.\n \n*Question 8.5/8.6 (2020/2019) - Does your city have a target to increase energy efficiency?*\n\n\n#### Unit\n\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n* Do not know\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n#### Data Sources\n\n\nCDP Cities Questionaire"},{"metadata":{},"cell_type":"markdown","source":"#### Analysis\n\nWhen looking at the responses from the CDP Questionannire, question 8.5-(2020) and 8.6-(2019), we can see that although the total number of responses has decreased from 2019 to 2020, the ratio of cities indicating that they have or are planning to set an energy effeciency target is stable. Part of the reason for a decrease in 2020, might be a result of the current COVID-19 pandemic.\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"data =  pd.read_csv(\"../input/dataset-1/8.5_responses.csv\")\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-one-three\"></a>\n### 1.3 Rooftop Solar Potential\n\n#### Description \n\nHere we look the technical estimated rooftop solar potential of buildings in a city using imagery, roof size and shape, shaded roof area calculations, local weather data and estimating the greenhouse gas emissions that could be avoided if solar power is used within a region. \n\nThe metric within this KPI indicates the potential amount of electricity that could be generated if all of the potential viable rooftop solar installations were implemented. \n\n#### Rationale\n\nSolar energy is one type of renewable energy that is capable of contributing to the reduction of energy dependence as well as energy-related environmental impacts and can reduce and offset the emissions from fossil fuel electricity generation. The potential for electricity to be generated from solar sources can avoid emissions from electricity from fossil fuels.\n\n#### Societal Impact\n\nJob creation: when cities or companies decide to build and operate solar energy facilities, the projects often help to create numerous jobs.\n\nEconomics: with more people able to find employment as a result of the increased number of jobs created by the development and operation of solar energy panels, more people would have money to contribute to a nation's economy. Also, manufacturing solar energy is less expensive than burning fossil fuels, which is the traditional method of generating electricity.\n\nHealth: generating energy from solar panels emits very little pollution into the air, and thus solar energy is a much cleaner source of energy than the burning of fossil fuels. Cities or areas that decide to use solar energy to power the buildings would thus enjoy a cleaner quality of air in the region, which in turn can make the citizens and workers in the area healthier.\n\n#### Methodology\n\nGoogle Insights Explorer estimates the technical solar potential of all buildings in a region. Knowledge about building shapes is calculated using a machine learning algorithm using data from Google Maps and overhead imagery.\n\nTechnical potential includes electricity generated by the rooftop area suitable for solar panels assuming economics and grid integration are not a constraint. There are many definitions of technical potential and other definitions may affect results by 25% or more. Based on their definition of technical potential, installations meet the following criteria:\n\n**Sunlight**: Every included panel receives at least 75% of the maximum annual sun in the area.\n\n**Installation size**: Every included roof has a total potential installation size of at least 2kW.\n\n**Space and obstacles**: Only areas of the roof with enough space to install 4 adjacent solar panels are included. Obstacles like chimneys are considered.\n\n\n#### Unit\n\nMetric tons of yearly CO2 savings\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the geospatial centres all of the census tracts in the Project Sunroof dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took a sum of the total solar potential for each census tract mapped to a CDP City. \n\n$$ Total Solar Potential_{City}= {\\sum_{i} Total Solar Potential_{CensusTract}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ Total Solar Potential Normalized_{City}= \\frac{(Total Solar Potential _{City} - \\min(Total Solar Potential _{City})}{\\max(Total Solar Potential _{City}) - \\min(Total Solar Potential _{City})}$$\n\n\n#### Data Sources\n\nGoogle Project Sunroof"},{"metadata":{},"cell_type":"markdown","source":"The data for this analysis was obtained in a granular format (Census Tract) and a subset of the data for Fresno County, in California, is mapped below. Regions with a brighter colour indicate a higher amount of estimated rooptop solar potential.  \n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"solar_potential_subset_gdf = gpd.read_file(\"../input/dataset-1/solar_potential_subset_gdf.gpkg\", layer='solar_potential_subset_gdf')\n\nfig = px.choropleth_mapbox(solar_potential_subset_gdf,\n                           geojson=solar_potential_subset_gdf.geometry,\n                           locations=solar_potential_subset_gdf.index,\n                           color=\"carbon_offset_metric_tons\",\n                           center={\"lat\": solar_potential_subset_gdf.centroid.y.iloc[0],\n                                   \"lon\": solar_potential_subset_gdf.centroid.x.iloc[0]},\n                           mapbox_style=\"open-street-map\",\n                           color_continuous_scale=\"Viridis\",\n                           hover_name = \"carbon_offset_metric_tons\",\n                           hover_data = {\"county_name\":True, \"state_name\":True, \"carbon_offset_metric_tons\":':.0f', \"kw_total\":':.0f', \n                                         \"existing_installs_count\":True, \"count_qualified\": True},\n                           labels = {\n                               \"carbon_offset_metric_tons\": \"Carbon Offset Potential (Metric Tons)\",\n                               \"kw_total\": \"Total # of kW of rooftop solar potential\",\n                               \"existing_installs_count\": \"Existing solar panel installations (# of buildings)\",\n                               \"count_qualified\": \"Potential solar panel installations (# of buildings)\",\n                               \"index\": \"Census Tract\",\n                               \"county_name\": \"County\",\n                               \"state_name\": \"State\"},\n                           title = \"Carbon Offset Potential (Metric Tons)\",\n                           opacity=.5,\n                           zoom=8)\nfig.update_layout(margin={\"r\":0,\"t\":0,\"l\":0,\"b\":0})\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"from vega_datasets import data\n\nsource = pd.read_csv(\"../input/dataset-1/project_sunroof_coverage.csv\")\nsource = source.rename(columns={\n    \"carbon_offset_metric_tons\": \"Carbon Offet Potential (Metric Tons)\",\n    \"county_name\": \"County\",\n    \"state_name\": \"State\",\n\n\n})\n\ncounties = alt.topo_feature(data.us_10m.url, 'counties')\n\nalt.Chart(counties).mark_geoshape().encode(\n    color='Carbon Offet Potential (Metric Tons):Q',\n    tooltip=['State:N', \"County:N\"]\n).transform_lookup(\n    lookup='id',\n    from_=alt.LookupData(source, 'id', [\"Carbon Offet Potential (Metric Tons)\", \"County\", \"State\"])\n).project(\n    type='albersUsa'\n)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"We then aggregated the data to asses the carbon offset potential if solar rooptops were utilized within major cities across the United States. Ideally, participating CDP cities with eletricity and emission targets that have already been set or are in progress can utilize this data and implement programs or services to advance and achieve their sustainability goals. Cities that have not yet set a target or action plan can also use this data to set realistic timelines and programs for renewable energy utilization and increased energy efficiency."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\nsolar_potential_cdf = pd.read_csv(\"../input/dataset-2/results-20201125-191757.csv\")\nsolar_potential_cdf[\"carbon_offset_metric_tons\"] = solar_potential_cdf[\"carbon_offset_metric_tons\"].where(pd.notnull(solar_potential_cdf[\"carbon_offset_metric_tons\"]), 0)\n\nsolar_potential_cdf = solar_potential_cdf[solar_potential_cdf['year_reported_to_cdp'] == 2019]\n\nsolar_potential_cdf['city_location'] = solar_potential_cdf['city_location'].apply(wkt.loads)\nsolar_potential_cdf_gdf = gpd.GeoDataFrame(solar_potential_cdf, geometry='city_location')\n\nfig = px.scatter_geo(solar_potential_cdf_gdf,\n                    lat=solar_potential_cdf_gdf.geometry.y,\n                    lon=solar_potential_cdf_gdf.geometry.x,\n                    hover_name=\"organization\",\n                    projection='albers usa',\n                    scope='usa',\n                    color=\"carbon_offset_metric_tons\",\n                    size = \"carbon_offset_metric_tons\",\n                    color_continuous_scale= \"viridis\",\n                    hover_data = {\n                        \"account_number\": True,\n                        \"organization\": True,\n                        \"carbon_offset_metric_tons\": True,\n                        \"existing_installs_count\": True,\n                        \"count_qualified\": True\n                    },\n                    labels = {\n                        \"lat\": \"Latitude\",\n                        \"lon\": \"Longitude\",\n                        \"account_number\": \"Account Number\",\n                        \"organization\": \"Organization\",\n                        \"city\": \"City\",\n                        \"carbon_offset_metric_tons\": \"Carbon Offset Potential (Metric Tons)\",\n                        \"existing_installs_count\": \"Existing solar panel installations (# of buildings)\",\n                        \"count_qualified\": \"Potential solar panel installations (# of buildings)\"\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-one-four\"></a>\n### 1.4 Wind Energy Potential\n\n#### Description\nHere we look at wind climate data that estimates the average wind power density at a 50meter height above a region. The average wind power density is a measure of the wind resource in a region. Higher average wind power densities indicate better wind resource potentials to generate mechanical power or electricity\n\nThe metric is also an indicator for the potential to generate electricity from wind turbines or comparable methods installed in suitable locations.\n\n#### Rationale\n\nThe potential for electricity to be generated from wind sources can avoid emissions from the generation of electricity directly sourced from fossil fuels.\nJob creation: wind energy projects result in jobs in various communities in manufacturing, transportation, and project construction.\n\n#### Societal Impact\n\nEconomics: with more people able to find employment as a result of the increased number of jobs created by the development and operation of wind energy farms, more people would have money to contribute to a nation's economy.\n\nHealth: another social impact is that citizens’ health would increase over time as people would not be exposed to as many hazardous wastes and emissions from the movement away from burning fossil fuels and using cleaner, greener energy in wind power.\n\n#### Methodology\n\nThe detailed wind-speed estimates are generated using a downscaling process. This process begins with large-scale wind climate data and ends with microscale wind climate data. The result is a set of generalized wind climates that have the same spacing as the mesoscale data that was used to create them. This generalization post-processing method has been used extensively in a number of wind resource assessment studies.\n\nFor more detailed instructions about how the estimates are generated, please see reference https://globalwindatlas.info/about/method.\n\n#### Unit \n\nAverage wind intensity by meters per second at a height of 50m.\n\n#### KPI Score Conversion\n\nGiven that we needed to map the meaurement points to the CDP cities, we complete the following steps to join datasets:\n\n2. For each region  in the CDP Cities, we calculated the distance to the centroids all of measurement points in the wind dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took a sum of the wind solar potential for each measurement point mapped to a CDP City. \n\n$$ Total Wind Potential_{City}= {\\sum_{i} Total Wind Potential_{MeasurementPoint}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ Total Wind Potential Normalized_{City}= \\frac{(Total Wind Potential _{City} - \\min(Total Wind Potential _{City})}{\\max(Total Wind Potential _{City}) - \\min(Total Wind Potential _{City})}$$\n\n\n#### Data Sources\n\nData/information/map obtained from the] “Global Wind Atlas 3.0, a free, web-based application developed, owned and operated by the Technical University of Denmark (DTU). The Global Wind Atlas 3.0 is released in partnership with the World Bank Group, utilizing data provided by Vortex, using funding provided by the Energy Sector Management Assistance Program (ESMAP). For additional information: https://globalwindatlas.info”\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"The data for this analysis was obtained in a granular format (Census Tract) and a subset of the data for Alameda County, in California, is mapped below. Regions with a brighter colour indicate a higher amount of wind energy potenial using wind intensity at a 50M elevation as an indicator."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"wind_potential_cdf = pd.read_csv(\"../input/dataset-1/wind_potential_subset_gdf.csv\")\nwind_potential_cdf['WKT'] = wind_potential_cdf['WKT'].apply(wkt.loads)\nwind_potential_cdf = gpd.GeoDataFrame(wind_potential_cdf, geometry='WKT')\n\n\nfig = px.choropleth_mapbox(wind_potential_cdf,\n                           geojson=wind_potential_cdf.geometry,\n                           locations=wind_potential_cdf.index,\n                           color=\"_mean\",\n                           center={\"lat\": wind_potential_cdf.centroid.y.iloc[0],\n                                   \"lon\": wind_potential_cdf.centroid.x.iloc[0]},\n                           mapbox_style=\"open-street-map\",\n                           color_continuous_scale=\"Viridis\",\n                           hover_name = \"lsad_name\",\n                           hover_data = {\"lsad_name\":True, \"area_land_meters\":':.0f', \"area_water_meters\":':.0f', \"_mean\":':.0f'},\n                           labels = {\n                               \"lsad_name\": \"Census Tract\",\n                               \"area_land_meters\": \"Total Area (Land)\",\n                               \"area_water_meters\": \"Total Area (Water)\",\n                               \"_mean\": \"Average Wind Intensity (50M Elevation)\"},\n                           opacity=.5,\n                           zoom=8)\nfig.update_layout(margin={\"r\":0,\"t\":0,\"l\":0,\"b\":0})\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"We then aggregated the data to asses the wind energy potential for major cities across the United States. Ideally, participating CDP cities with eletricity and emission targets that have already been set or are in progress can utilize this data and implement programs or services to advance and achieve their sustainability goals. Cities that have not yet set a target or action plan can also use this data to set realistic timelines and programs for renewable energy utilization and increased energy efficiency."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"wind_potential_cdf = pd.read_csv(\"../input/dataset-1/wind_potential_cdp.csv\")\nwind_potential_cdf = wind_potential_cdf[(wind_potential_cdf[\"country\"]==\"United States of America\") & (wind_potential_cdf[\"year_reported_to_cdp\"]== 2019)]\n\nfig = px.scatter_geo(wind_potential_cdf,\n                    lat=\"latitude\",\n                    lon=\"longitude\",\n                    hover_name=\"organization\",\n                    projection='albers usa',\n                    scope='usa',\n                    color=\"_mean\",\n                    size=\"_mean\",\n                    color_continuous_scale= \"viridis\",\n                    hover_data = {\n                        \"account_number\": True,\n                        \"organization\": True,\n                        \"_mean\": True\n                    },\n                    range_color = [0,500],\n                    labels = {\n                        \"latitude\": \"Latitude\",\n                        \"longitude\": \"Longitude\",\n                        \"account_number\": \"Account Number\",\n                        \"organization\": \"Organization\",\n                        \"city\": \"City\",\n                        \"_mean\": \"Average Wind Intensity (50M Elevation)\"\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-one-five\"></a>\n### 1.5 Renewable Energy Sources in Electricity Production\n\n#### Description\n\nHere we look at the primary electricity generation source in a region. The data assess whether the primary source is generated from a renewable energy sources or fossil fuel intensive sources.\n\n#### Rationale\n\nEnergy generated from renewable energy sources such as solar, wind, geothermal, bioenergy and hydropower produce lower levels of CO₂ emissions.\n\n#### Methodology\n\nWe grouped this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 – If electricity generated from Solar, wind, geothermal, bioenergy, hydro\n0 - otherwise\n\n#### Unit\n\nBinary Indicator\n\n\n#### KPI Score Conversion\n\nGiven that we needed to map the power plants to the CDP cities, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the locations all of power plants in the wind dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 200 kilometers to a CDP city.\n3. We sorted the power plants within a 200 kilometer radius based on their mW capacity and assigned the plant with the higher capacity as the primary energy source type.\n4. If the plant was of type solar, wind, geothermal, bioenergy, hydro set the value to 1\ntook a sum of the wind solar potential for each measurement point mapped to a CDP City. \n\n\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n#### Data Sources\n\nGlobal Energy Observatory, Google, KTH Royal Institute of Technology in Stockholm, Enipedia, World Resources Institute. 2018. Global Power Plant Database. Published on Resource Watch and Google Earth Engine; http://resourcewatch.org/ https://earthengine.google.com/\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"Here we used this data to identify the primary energy sources for major cities within the United States to first determine whether or not the main energy source is derived from a renewable energy source. You can view individual primary sources by double-clicking the fuel type in the legend on the right side of the map below. The size of each data point represents the total capacity of the energy source. Cities are mapped to their closest energy source available for use. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"renewable_energy_source_cdf = pd.read_csv(\"../input/dataset-1/kpi_output_files_4_renewable_energy_loc.csv\")\nrenewable_energy_source_cdf[\"generation_gwh\"] = renewable_energy_source_cdf[\"generation_gwh\"].where(pd.notnull(renewable_energy_source_cdf[\"generation_gwh\"])|renewable_energy_source_cdf[\"generation_gwh\"]<0, None)\nrenewable_energy_source_cdf[\"renewable_source\"] = renewable_energy_source_cdf[\"primary_fuel\"].isin([\"Solar\", \"Wind\", \"Geothermal\", \"Bioenergy\", \"Hydro\"])\n\nfig = px.scatter_geo(renewable_energy_source_cdf[renewable_energy_source_cdf[\"year\"]==2017],\n                    lat=\"latitude\",\n                    lon=\"longitude\",\n                    hover_name=\"name\",\n                    projection='albers usa',\n                    scope='usa',\n                    color=\"primary_fuel\",\n                    size = \"capacity_mw\",\n                    color_continuous_scale= \"viridis\",\n                    facet_col=\"renewable_source\",\n                    hover_data = {\n                        \"name\": True,\n                        \"owner\": True,\n                        \"country_long\": True,\n                        \"primary_fuel\": True,\n                        \"generation_gwh\":True,\n                        \"source\": True\n                        \n                    },\n                    labels = {\n                        \"latitude\": \"Latitude\",\n                        \"longitude\": \"Longitude\",\n                        \"name\": \"Plant Name\",\n                        \"owner\": \"Plant Owner\",\n                        \"country_long\": \"Country\",\n                        \"primary_fuel\": \"Fuel Type (Primary)\",\n                        \"capacity_mw\": \"Capacity (MW)\",\n                        \"generation_gwh\": \"Generation (GWH)\",\n                        \"renewable_source\": \"Renewable Energy Source\",\n                        \"source\": \"Reporting Source\"\n\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-two\"></a>\n\n## 2.0 Water\n\nThe assessment of water quality and consumption can help put in context a city’s ecological deficit or reserve that can ultimately affect the environmental quality with a region. They are interconnected as water quality has a huge impact on water supply and oftentimes can also determine the supply availability and options. Water quality standards for surface waters can vary significantly in regions due to different environmental conditions, ecosystems, and the reliance from both commercial and residential uses. There are two main ways in which we can classify water use. One type is in-stream use; this includes hydroelectric power, boating and swimming, for example. While in-stream activities do not use up the water, they can degrade the water quality through pollution. The other type of water use is the withdrawal of water, and this classification includes household use, industry use, irrigation, livestock watering and thermal and nuclear power. Most withdrawals are consumptions, meaning that the activity uses the water and does not return it to the source. This concentration will look at various KPIs related to water quality and consumption within a region.\n\nOur KPIs within this concentration are listed below.\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-two-one\"></a>\n\n### 2.1 Water Resource Management Strategy Present\n\n\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question asses whether the participating city has set a Water Resource Management Strategy.\n \n*Question 14.4/14.5 (2020/2019) - Does your city have a publicly available Water Resource Management strategy?*\n\n\n#### Unit\n\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionannire, we can see that the total number of 'yes'responses has increased from 2019 to 2020, in East Asia, Europe, and North America. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data =  pd.read_csv(\"../input/dataset-1/14.4_responses.csv\")\ndata.loc[data['response_answer']=='Intending to undertake in next 2 years','response_answer'] = 'Intending to undertake in the next 2 years'\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### <a id=\"section-two-two\"></a>\n\n### 2.2 Actions taken to reduce water risk (when present)\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question asseses whether the participating city has listed actions taken to reduce risks to city's water security, when a risk was identified.\n \n*Question 14.3/14.4 (2020/2019) - Please select the actions you are taking to reduce the risks to your city’s water security*\n\n\n#### Unit\n\nWe look at the listed *status* of the actions taken by cities to reduce risks to city's water security, when a risk was identified.\n\nThe options for participating cities are the following:\n* Scoping\n* Pre-feasibility study\n* Pre-implementation\n* Implementation\n* Implementation complete but not in operation\n* Operation\n* Monitoring and reporting\n\n\n#### KPI Score Conversion\n\nWe converted this into a percent for our CDP Sustainability Index analysis. \n\n*Percent of total actions that are in progress or complete.*\n\nProportion of declared actions that are in progress or complete based on statuses  listed as \"Monitoring and reporting\" ,\"Operation\", \"Implementation\", \"Implementation complete but not in operation\".\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"For this KPI we measure the number of adaptative actions taken by cities that are either in progress or complete. The statuses we use to denote an adaptative action as being in progress or complete are the following:\n* Monitoring and reporting\n* Operation\n* Implementation\n* Implementation complete but not in operation\n\nIn the chart below, we can see that there are significant increases in the number of adaptation actions that are in operation and implementation in Europe, Latin America between 2019 and 2020.\n"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/14.3_responses.csv\")\ndata = data[(data['column_number']== 3) & (data['response_answer'] != 'Question not applicable')]\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-two-three\"></a>\n\n### 2.3 Water Stress\n\n#### Description \n\nHere we look at the overall water consumption (for industry, domestic use as well as agriculture) that has been sourced from surface and/or groundwater resources per capita on a yearly basis. We will analyze water consumption as ratio of total water withdrawals to available renewable surface and ground water supplies.\n\n#### Rationale\n\nBaseline water stress measures the ratio of total water withdrawals to available renewable surface and groundwater supplies. Water withdrawals include domestic, industrial, irrigation, and livestock consumptive and non-consumptive uses. Available renewable water supplies include the impact of upstream consumptive water users and large dams on downstream water availability. \n\nHigher regional values are indicative of higher water consumption.\n\nBaseline water stress measures the ratio of total water withdrawals to available renewable surface and groundwater supplies. Water withdrawals include domestic, industrial, irrigation, and livestock consumptive and non-consumptive uses. Available renewable water supplies include the impact of upstream consumptive water users and large dams on downstream water availability. \n\nHigher regional values are indicative of higher water consumption.\n\n\n#### Societal Impact\n\nWater stress and scarcity can have far-reaching consequences for a community. This is particularly true in low-income communities where individuals often don’t have the disposable income to buy bottled water. In these communities, a lack of water can have a devastating effect.\n\n#### Unit\n\nRisk rating from 0-5.\n\n#### KPI Score Conversion\n\nGiven that we needed to map the meaurement points to the CDP cities, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the centroids all of measurement points in the water dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took a average of the water stress measurements for each measurement point mapped to a CDP City. \n\n$$ WaterStress_{City}= \\frac{1}{N}{\\sum_{i} WaterStress_{MeasurementPoint}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ WaterStressNormalized_{City}= \\frac{(WaterStress_{City} - \\min(WaterStress_{City})}{\\max(WaterStress_{City}) - \\min(WaterStress_{City})}$$\n\n#### Data Sources\n\nhttps://www.wri.org/aqueduct\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"The data for this analysis was obtained in a granular format; and a subset of the data was aggregated to the Census Tract level for Alameda County, in California, which is mapped below. In this particular subset, from the data we see that the water stress on the Eastern side of Alameda Country is much higher than in the Central and Western regions. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\nwater_risk_cdf = pd.read_csv(\"../input/dataset-1/water_subset.csv\")\nwater_risk_cdf = water_risk_cdf.where(pd.notnull(water_risk_cdf), None)\nwater_risk_cdf['blockgroup_geom'] = water_risk_cdf['blockgroup_geom'].apply(wkt.loads)\nwater_risk_cdf = gpd.GeoDataFrame(water_risk_cdf, geometry='blockgroup_geom')\nwater_risk_cdf = water_risk_cdf[~water_risk_cdf['bws_label'].isnull()]\n\n\nfig = px.choropleth_mapbox(water_risk_cdf,\n                           geojson=water_risk_cdf.geometry,\n                           locations=water_risk_cdf.index,\n                           color=\"bws_label\",\n                           color_discrete_sequence= px.colors.sequential.Plasma_r,\n                           center={\"lat\": water_risk_cdf.centroid.y.iloc[0],\n                                   \"lon\": water_risk_cdf.centroid.x.iloc[0]},\n                           labels={\"bws_label\": \"Baseline Water Risk\"},\n                           mapbox_style=\"open-street-map\",\n                           opacity=.5,\n                           zoom=8)\nfig.update_layout(margin={\"r\":0,\"t\":0,\"l\":0,\"b\":0})\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Using the same granular dataset, we calculated the aggregated baseline water stress metrics for large global cities. From the map below, we can see that there is a significant regional variation in the water stress levels. For example, in the United Stated we recognize that the water stress levels in cites within Southern California, Texas and New Mexico are significantly higher than in states that are closer in proximity to the Great Lakes (Michigan, Illinois, New York, etc.)."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"water_risk_cdp = pd.read_csv(\"../input/dataset-1/water_subset_cdp.csv\")\nwater_risk_cdp = water_risk_cdp[(~water_risk_cdp['bws_label'].isnull())]\n\nfig = px.scatter_geo(water_risk_cdp,\n                    lat=\"latitude\",\n                    lon=\"longitude\",\n                    hover_name=\"organization\",\n                    color=\"bws_label\",\n                   color_discrete_sequence= px.colors.sequential.Plasma_r,\n                    hover_data = {\n                        \"account_number\": True,\n                        \"organization\": True,\n                        \"bws_label\": True\n                    },\n                     category_orders={\"bws_label\": \n                                      ['Arid and Low Water Use', 'Low (<10%)', 'Low - Medium (10-20%)', 'Medium - High (20-40%)', 'High (40-80%)'\n                                       'Extremely High (>80%)']},\n                    labels = {\n                        \"latitude\": \"Latitude\",\n                        \"longitude\": \"Longitude\",\n                        \"account_number\": \"Account Number\",\n                        \"organization\": \"Organization\",\n                        \"city\": \"City\",\n                        \"bws_label\": \"Baseline water stress\"\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-two-four\"></a>\n\n### 2.4 Water Depletion\n\n#### Description \n\nHere we look at the baseline water depletion of a region which measures the ratio of total water consumption to available renewable water supplies.\n\n#### Rationale\n\nTotal water consumption includes domestic, industrial, irrigation, and livestock consumptive uses. Available renewable water supplies include the impact of upstream consumptive water users and large dams on downstream water availability. Here we consider water depletion where higher values indicate a larger impact on the local water supply and decreased water availability for downstream users. \n\nBaseline water depletion is similar to baseline water stress; however, instead of looking at total water withdrawal (consumptive plus non-consumptive), baseline water depletion is calculated using consumptive withdrawal only.\n\n\n#### Societal Impact\n\nA lack of water due to high water depletion can pose a major obstacle to economic prosperity with many sectors relying on the precious resource in their operations. \n\nThese macroeconomic ramifications can have far-ranging consequences on an individual level as well. With the slowing of business operations leading to reduced profits, businesses are likely to be forced into laying off some of their workforces, leading to reduced consumer spending power among vulnerable communities.\n\n#### Unit\n\nRisk rating from 0-5.\n\n#### KPI Score Conversion\n\nGiven that we needed to map the meaurement points to the CDP cities, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the centroids all of measurement points in the water dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took a average of the water depletion measurements for each measurement point mapped to a CDP City. \n\n$$ WaterDepletion_{City}= \\frac{1}{N}{\\sum_{i} WaterDepletion_{MeasurementPoint}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ WaterDepletionNormalized_{City}= \\frac{(WaterDepletion_{City} - \\min(WaterDepletion_{City})}{\\max(WaterDepletion_{City}) - \\min(WaterDepletion_{City})}$$\n\n#### Data Sources\n\nhttps://www.wri.org/aqueduct\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"The data for this analysis was obtained in a granular format; and a subset of the data was aggregated to the Census Tract level for Alameda County, in California, which is mapped below. In this particular subset, from the data we see that the water depletion on the Eastern side of Alameda Country is higher than in the Central and Western regions. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.choropleth_mapbox(water_risk_cdf,\n                           geojson=water_risk_cdf.geometry,\n                           locations=water_risk_cdf.index,\n                           color=\"bwd_label\",\n                           color_discrete_sequence= px.colors.sequential.Plasma_r,\n                           center={\"lat\": water_risk_cdf.centroid.y.iloc[0],\n                                   \"lon\": water_risk_cdf.centroid.x.iloc[0]},\n                           mapbox_style=\"open-street-map\",\n                           labels={\"bwd_label\": \"Baseline Water Depletion Risk\"},\n                           opacity=.5,\n                           zoom=8)\nfig.update_layout(margin={\"r\":0,\"t\":0,\"l\":0,\"b\":0})\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Using the same granular dataset, we calculated the aggregated baseline water depletion metrics for large global cities. From the map below, we can see that there is a significant regional variation in the water depletion levels. For example, in the United Stated we recognize that the water depletion levels in cites within Southern California, Texas and New Mexico are significantly higher than in states that are closer in proximity to the Great Lakes (Michigan, Illinois, New York, etc.)."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.scatter_geo(water_risk_cdp,\n                    lat=\"latitude\",\n                    lon=\"longitude\",\n                    hover_name=\"organization\",\n                    color=\"bwd_label\",\n                   color_discrete_sequence= px.colors.sequential.Plasma_r,\n                    hover_data = {\n                        \"account_number\": True,\n                        \"organization\": True,\n                        \"bwd_label\": True\n                    },\n                     category_orders={\"bwd_label\": \n                                      ['Arid and Low Water Use', 'Low (<10%)', 'Low - Medium (10-20%)', 'Medium - High (20-40%)', 'High (40-80%)'\n                                       'Extremely High (>80%)']},\n                    labels = {\n                        \"latitude\": \"Latitude\",\n                        \"longitude\": \"Longitude\",\n                        \"account_number\": \"Account Number\",\n                        \"organization\": \"Organization\",\n                        \"city\": \"City\",\n                        \"bwd_label\": \"Baseline water depletion\"\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-two-five\"></a>\n\n### 2.5 Drinking Water Risk\n\n#### Description \n\nHere we look at the percentage of the population collecting drinking water from an unprotected dug well or spring, or directly from a river, dam, lake, pond, stream, canal, or irrigation canal (WHO and UNICEF 2017).\n\n#### Rationale\n\nWater scarcity is one of the key challenges facing the world in the 21st century. The continuing availability of water underpins action on food security, energy security, poverty reduction, economic growth, conflict reduction, climate change adaptation and biodiversity loss. Assessing the accessibility to clean drinking water is an important indicator of the water supply and quality within a region. \n\nIn this assessment, higher values within a region indicate areas where people have less access to safe drinking water supplies.\n\n\n#### Societal Impact\n\nDrinking water is essential to health, and contaminated water has a myriad of harms other than diarrhea, which is a major source of worldwide disease alone. This KPI is important in assessing the accessibility of clean drinking water which can influence the implementation of community-based, evidence-supported, simple interventions to achieve rapid improvements in health with access to clean water.\n\n#### Unit\n\nRisk rating from 0-5.\n\n#### KPI Score Conversion\n\nGiven that we needed to map the meaurement points to the CDP cities, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the centroids all of measurement points in the water dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took a average of the drinking water risk measurements for each measurement point mapped to a CDP City. \n\n$$ DrinkingWaterRisk_{City}= \\frac{1}{N}{\\sum_{i} DrinkingWaterRisk_{MeasurementPoint}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ DrinkingWaterRiskNormalized_{City}= \\frac{(DrinkingWaterRisk_{City} - \\min(DrinkingWaterRisk_{City})}{\\max(DrinkingWaterRisk_{City}) - \\min(DrinkingWaterRisk_{City})}$$\n\n#### Data Sources\n\nhttps://www.wri.org/aqueduct\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"The data for this analysis was obtained in a granular format; and a subset of the data was aggregated to the Census Tract level for Alameda County, in California, which is mapped below. In this particular subset, from the data we see that the drinking water risk is extremely low across Alameda Country. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.choropleth_mapbox(water_risk_cdf,\n                           geojson=water_risk_cdf.geometry,\n                           locations=water_risk_cdf.index,\n                           color=\"udw_label\",\n                           color_discrete_sequence= px.colors.sequential.Plasma_r,\n                           center={\"lat\": water_risk_cdf.centroid.y.iloc[0],\n                                   \"lon\": water_risk_cdf.centroid.x.iloc[0]},\n                           mapbox_style=\"open-street-map\",\n                           labels={\"udw_label\": \"Drinking Water Risk\"},\n                           opacity=.5,\n                           zoom=8)\nfig.update_layout(margin={\"r\":0,\"t\":0,\"l\":0,\"b\":0})\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Using the same granular dataset, we calculated the aggregated baseline drinking water risk metrics for large global cities. From the map below, we can see that there is a significant regional variation in the drinking water risk levels. For example, in the majority of the Global South we recognize that the drinking water risk levels are significantly higher."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.scatter_geo(water_risk_cdp,\n                    lat=\"latitude\",\n                    lon=\"longitude\",\n                    hover_name=\"organization\",\n                    color=\"udw_label\",\n                   color_discrete_sequence= px.colors.sequential.Plasma_r,\n                    hover_data = {\n                        \"account_number\": True,\n                        \"organization\": True,\n                        \"udw_label\": True\n                    },\n                     category_orders={\"udw_label\": \n                                      ['Arid and Low Water Use', 'Low (<10%)', 'Low - Medium (10-20%)', 'Medium - High (20-40%)', 'High (40-80%)'\n                                       'Extremely High (>80%)']},\n                    labels = {\n                        \"latitude\": \"Latitude\",\n                        \"longitude\": \"Longitude\",\n                        \"account_number\": \"Account Number\",\n                        \"organization\": \"Organization\",\n                        \"city\": \"City\",\n                        \"udw_label\": \"Drinking Water Risk\"\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-two-six\"></a>\n\n### 2.6 Water Sanitation Risk\n\n#### Description \n\nHere we look at the percentage of the population within a region using pit latrines without a slab or platform, hanging/bucket latrines, or directly disposing human waste in fields, forests, bushes, open bodies of water, beaches, other open spaces, or with solid waste (WHO and UNICEF 2017).\n\n#### Rationale\n\nWater quality is an effective measurement to assess relative water demand and supply. The ability to secure adequate freshwater quality for both human and ecological needs is therefore a central aspect of sustainable development. In many regions, water quality is threatened due to industrial spillage, agricultural irrigation, and urban water pollution from residential and commercial use.\n\nIn this assessment, higher values within a region indicate areas where people have less access to improved sanitation services.\n\n#### Unit\n\nRisk rating from 0-5.\n\n#### KPI Score Conversion\n\nGiven that we needed to map the meaurement points to the CDP cities, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the centroids all of measurement points in the water dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took a average of the water sanitation risk measurements for each measurement point mapped to a CDP City. \n\n$$ WaterSanitationRisk_{City}= \\frac{1}{N}{\\sum_{i} WaterSanitationRisk_{MeasurementPoint}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ WaterSanitationNormalized_{City}= \\frac{(WaterSanitationRisk_{City} - \\min(WaterSanitationRisk_{City})}{\\max(WaterSanitationRisk_{City}) - \\min(WaterSanitationRisk_{City})}$$\n\n#### Data Sources\n\nhttps://www.wri.org/aqueduct\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"The data for this analysis was obtained in a granular format; and a subset of the data was aggregated to the Census Tract level for Alameda County, in California, which is mapped below. In this particular subset, from the data we see that the water sanitation risk is extremely low across Alameda Country. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.choropleth_mapbox(water_risk_cdf,\n                           geojson=water_risk_cdf.geometry,\n                           locations=water_risk_cdf.index,\n                           color=\"usa_label\",\n                           color_discrete_sequence= px.colors.sequential.Plasma_r,\n                           center={\"lat\": water_risk_cdf.centroid.y.iloc[0],\n                                   \"lon\": water_risk_cdf.centroid.x.iloc[0]},\n                           mapbox_style=\"open-street-map\",\n                           labels={\"usa_label\": \"Water Sanitation Risk\"},\n                           opacity=.5,\n                           zoom=8)\nfig.update_layout(margin={\"r\":0,\"t\":0,\"l\":0,\"b\":0})\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Using the same granular dataset, we calculated the aggregated baseline water sanitation risk metrics for large global cities. From the map below, we can see that there is a significant regional variation in the water sanitation risk levels. For example, in the majority of the Global South we recognize that the water sanitation risk levels are significantly higher."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.scatter_geo(water_risk_cdp,\n                    lat=\"latitude\",\n                    lon=\"longitude\",\n                    hover_name=\"organization\",\n                    color=\"usa_label\",\n                   color_discrete_sequence= px.colors.sequential.Plasma_r,\n                    hover_data = {\n                        \"account_number\": True,\n                        \"organization\": True,\n                        \"usa_label\": True\n                    },\n                     category_orders={\"usa_label\": \n                                      ['Arid and Low Water Use', 'Low (<10%)', 'Low - Medium (10-20%)', 'Medium - High (20-40%)', 'High (40-80%)'\n                                       'Extremely High (>80%)']},\n                    labels = {\n                        \"latitude\": \"Latitude\",\n                        \"longitude\": \"Longitude\",\n                        \"account_number\": \"Account Number\",\n                        \"organization\": \"Organization\",\n                        \"city\": \"City\",\n                        \"usa_label\": \"Sanitation Risk\"\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-three\"></a>\n\n## 3.0 Governance\n\nThis concentration considers the ambitions, willingness and policy-oriented commitments that cities make towards achieving environmental sustainability. These issues generally include air and water pollution, waste management, and the management of natural resources. Synergic to environmental policy is the depth and level of environmental research and innovation policy occurring with a city. Here we look at the priority’s cities set in energy, environment, the development of smart cities, and their plans to reduce CO₂ emissions by a set timeline. The willingness of a region to invest or create environmental policy surrounding sustainability through a C0₂ emission reduction target can be indicative of their commitment and overall action plan towards a more sustainable society. Setting a reduction target is preferred as it can hold a region more accountable for achieving their goals.\n\nOur KPIs within this concentration are the following.\n\n<a href=\"#section-toc\">Back to Table of Contents</a>\n\n<a id=\"section-three-one\"></a>\n\n### 3.1 Goals & targets set for sustainability\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question asses whether the participating city incorporates sustainability goals and targets into the master planning for a city.\n \n*Question 1.0 - Does your city incorporate sustainability goals and targets (e.g. GHG reductions) into the master planning for the city?*\n\n\n#### Unit\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n* Do not know\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionannire, question 1, we can see that although the total number of responses has decreased from 2019 to 2020, the ratio of cities indicating that they have or are planning to incorporate sustainability goals and targets (e.g. GHG reductions) into the master planning for the city is stable. Part of the reason for a decrease in 2020, might be a result of the current COVID-19 pandemic. However, cities in East Asia are reporting higher respones of 'yes'or 'intending to undertake in the next two years'between 2019 and 2020. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/1.0_responses.csv\")\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-four\"></a>\n\n## 4.0 Adaptation\n\nIncreasing frequency and intensity of extreme weather events as well as the long-term effects of climate change impact cities in a variety of different ways. Here we will look at CDP survey response data and whether or not cities create adaptation actions, to build greater resilience in the everchanging state of climate change and its side effects.\n\nOur KPIs within this concentration are the following.\n\n<a id=\"section-four-one\"></a>\n\n### 4.1 Creation Of A Climate Change Adaptation Plan\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question asses whether the participating city have a published plan that addresses climate change adaptation.\n \n*Question 3.2 - Does your city council, or similar authority, have a published plan that addresses climate change adaptation?*\n\n\n#### Unit\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n* Do not know\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionannire, question 3.2, we can see that generally although the total number of responses has decreased from 2019 to 2020, the ratio of cities indicating that they have or are planning to have a published plan that addresses climate change adaptation for the city is stable. Again,part of the reason for a decrease in 'yes' responses in 2020, might be a result of the current COVID-19 pandemic. However, cities in East Asia are reporting higher respones of 'yes'or 'in progress' between 2019 and 2020. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/3.2_responses.csv\")\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five\"></a>\n\n## 5.0 Emissions\n\nCarbon dioxide emissions are the primary driver of global climate change. It’s widely recognized that to avoid the worst impacts of climate change, the world needs to urgently reduce emissions. This concentration considers city profiles for CO₂ emissions. More specifically we will look at the CO2 emissions in a city from various sources such as buildings (both residential and corporate) and transport (both land and air transport). We will also look at energy usage within this area as global warming is caused by a number of different factors including the extensive use of electricity and its effect of putting too much carbon into the atmosphere. These gases are harmful as they spread around the planet whilst, keeping in solar heat that would otherwise be radiated out into space. \n\nOur KPIs within this concentration are the following.\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five-one\"></a>\n\n### 5.1 City-Wide Inventory Present\n\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question asses whether the participating city has calculated its city-wide emissions inventory.\n \n*Question 4.0 - Does your city have a city-wide emissions inventory to report?*\n\n\n#### Unit\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionannire, question 3.2, we can see that generally although the total number of responses has decreased from 2019 to 2020, the ratio of cities indicating that they have a city-wide emissions inventory to report for the city is stable. Again, part of the reason for a decrease in 'yes' responses in 2020, might be a result of the current COVID-19 pandemic. On a postitive note, there has been a decrease response of 'not intending to undetake' amongst many of the regions."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/4.0_responses.csv\")\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five-two\"></a>\n\n### 5.2 City-Wide Inventory Externally Verified\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question assesses whether the participating city has and an external verification of their GHG emissions data.\n \n*Question 4.12 - Has the city-wide GHG emissions data you are currently reporting been externally verified or audited in part or in whole?*\n\n\n#### Unit\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n* Do not know\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionannire, question 4.12, we can see that although the total number of responses for most regions has decreased from 2019 to 2020, the ratio of cities indicating that they have externally verified city-wide GHG emissions data is stable. Again, part of the reason for a decrease in 'yes' responses in 2020, might be a result of the current COVID-19 pandemic. On a postitive note, there has been an increase 'yes' response from cities in Europe, as well as an increase in 'intending to undertake in the next 2 years' responses in North America. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/4.12_responses.csv\")\ndata = data[data['response_answer']!='Question not applicable']\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five-three\"></a>\n\n### 5.3 Detailed City-Wide Consumption-Based Inventory Available\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question assesses whether the participating city has a consumption-based inventory for its residents.\n \n*Question 4.9 - Does your city have a consumption-based inventory to measure emissions from consumption of goods and services by your residents?*\n\n\n#### Unit\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n* Do not know\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionannire, question 4.9, we can see that although the total number of responses for most regions has decreased from 2019 to 2020, the ratio of cities indicating that they have a consumption-based inventory is stable. Again, part of the reason for a decrease in 'yes' responses in 2020, might be a result of the current COVID-19 pandemic. On a postitive note, there has been an increase 'yes' response from cities in Europe, as well as an increase in 'intending to undertake in the next 2 years' responses in North America. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/4.9_responses.csv\")\ndata = data[(data['column_number'] == 1) & (data['response_answer']!='Question not applicable')]\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five-four\"></a>\n\n### 5.4 Energy usage intensity for non-residential buildings\n\n#### Description \n\nHere we look at the total kilowatt per hours per square meter per year for non-residential building within a city.\n\n#### Rationale\n\nEnergy Use Intensity (EUI) represents a building’s annual total energy consumption per unit floor space. It is useful in setting energy use benchmarks and goals. Energy consumption can include electricity, fuel oil, natural gas, steam and other forms of thermal energy.\n\nThe energy consumption in a building is split between grid electricity used for activities such as lighting and fuel combustion used for heating or cooking. The total energy consumption can be broken out by percentage for each.\n\nLow values should be pursued.\n\nA declining trend is positive.\n\n\n#### Methodology\n\nFor a given year, calculate as:\n\nNumerator: Total kilowatt-hours for all non-residential buildings in a city\n\nDenominator: Total squared meters of non-residential floor space in a city. Floor space is a measurement of the total three-dimensional area of the unit that is enclosed from weather by exterior walls, which is also where most energy-consuming activities occur.\n\n#### Unit\n\nRatio: Total kilowatt-hours for all buildings in a city/ Total squared meters of non-residential floor space in a city.\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the cities in the Insights Explorer dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took the energy usage for each matched city. \n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ EnergyIntensityNormalized_{City}= \\frac{(EnergyIntensity_{City} - \\min(EnergyIntensity_{City})}{\\max(EnergyIntensity_{City}) - \\min(EnergyIntensity_{City})}$$\n\n\n#### Data Sources\n\nGoogle Environmental Insights Explorer (11/2020)\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the graph below we can analyze the engery usage intensity in non-residential buildings for a subset of 125 large global cities. The sizes of the datapoints are the estimated CO2 emissions for non-residential buildings within a city per year and the colour represents the energy usage intensity (see legend on the right). Some of the highest energy usage intensities are found within various cities in the United Kingdom (though they have lower CO2 emissions per year), whereas some of lowest are in major cities in Latin America and Australia. However, from the graph below we can see the there are several cities within North America and highly populated cities with the UK have some of the highest CO2 emissions compared to other cities and regions in the graph."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\nbuilding_data =  pd.read_csv(\"../input/dataset-1/building_data.csv\")\nbuilding_data['City_Location_Geocoded'] = building_data['City_Location_Geocoded'].apply(wkt.loads)\nbuilding_data = gpd.GeoDataFrame(building_data, geometry='City_Location_Geocoded')\n\nfig = px.scatter(\n    building_data[building_data['sector']=='Non-residential'], \n    hover_name=\"Address\",\n    color=\"energy_intensity\",\n    size=\"co2e_tons\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"Geocoded_Address\": True,\n        \"energy_intensity\": True,\n        \"co2e_tons\": True,\n        \"Geocoded_Address\": True\n    },\n    labels = {\n        \"Geocoded_Address\": \"Location\",\n        \"energy_intensity\": \"Energy usage intensity (Buildings)\",\n        \"co2e_tons\": \"Building emissions (Total tCO2e per year)\"\n    },\n    x=\"Geocoded_Address\", \n    y=\"energy_intensity\",\n    template=\"simple_white\",\n    title=\"Energy usage intensity (Non-Residential Buildings)\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five-five\"></a>\n\n### 5.5 Energy usage intensity for residential buildings\n\n#### Description \n\nHere we look at the total kilowatt per hours per square meter per year for residential building within a city.\n\n#### Rationale\n\nEnergy Use Intensity (EUI) represents a building’s annual total energy consumption per unit floor space. It is useful in setting energy use benchmarks and goals. Energy consumption shall include electricity, fuel oil, natural gas, steam and other forms of thermal energy.\n\nThe energy consumption in a building is split between grid electricity used for activities such as lighting and fuel combustion used for heating or cooking. The total energy consumption can be broken out by percentage for each.\n\nLow values should be pursued.\n\nA declining trend is positive.\n\n\n#### Methodology\n\nFor a given year, calculate as:\n\nNumerator: Total kilowatt-hours for all residential buildings in a city\n\nDenominator: Total squared meters of residential floor space in a city. Floor space is a measurement of the total three-dimensional area of the unit that is enclosed from weather by exterior walls, which is also where most energy-consuming activities occur.\n\n#### Unit\n\nRatio: Total kilowatt-hours for all residential buildings in a city/ Total squared meters of residential floor space in a city.\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the cities in the Insights Explorer dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took the energy usage for each matched city. \n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ EnergyIntensityNormalized_{City}= \\frac{(EnergyIntensity_{City} - \\min(EnergyIntensity_{City})}{\\max(EnergyIntensity_{City}) - \\min(EnergyIntensity_{City})}$$\n\n#### Data Sources\n\nGoogle Environmental Insights Explorer (11/2020)\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the graph below we can analyze the engery usage intensity in residential buildings for a subset of 125 large global cities. The sizes of the datapoints are the estimated CO2 emissions for residential buildings within a city per year and the colour represents the energy usage intensity (see legend on the right). Some of the highest energy usage intensities are found within various cities in North America and Europe, whereas some of lowest are in major cities in Latin American cities. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.scatter(\n    building_data[building_data['sector']=='Residential'], \n    hover_name=\"Address\",\n    color=\"energy_intensity\",\n    size=\"co2e_tons\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"Geocoded_Address\": True,\n        \"energy_intensity\": True,\n        \"co2e_tons\": True,\n        \"Geocoded_Address\": True\n    },\n    labels = {\n        \"Geocoded_Address\": \"Location\",\n        \"energy_intensity\": \"Energy usage intensity (Buildings)\",\n        \"co2e_tons\": \"Building emissions (Total tCO2e per year)\"\n    },\n    x=\"Geocoded_Address\", \n    y=\"energy_intensity\",\n    template=\"simple_white\",\n    title=\"Energy usage intensity (Residential Buildings)\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five-six\"></a>\n\n### 5.6 Total Degree Days\n\n#### Description \n\nHere we look at the Total Degree Days (Heating Degree Days (HDD) & Cooling Degree Days (CDD)) in Celsius: these days are total number of yearly days where building (both residential and non-residential) heating or cooling is required based on the average daily temperature.\n\n#### Rationale\n\nIn heated or cooled buildings, energy consumption tends to depend on the outside air temperature:\n\nThe colder the outside air temperature, the more energy it takes to heat a building to a comfortable temperature.\nThe warmer the outside air temperature, the more energy it takes to cool an air-conditioned building to a comfortable temperature.\n\nThere importance of this measuring this KPI can help evaluate the success of a cities ability to manage localized temperatures from increasing or decreasing relative to regional thresholds. Cities that are successful in keeping temperatures below the threshold can reduce their energy usage and therefore mitigate CO2 emissions.\n\n\n#### Methodology\n\nDegree days assume that when the outside temperature is 18°C, we don't need heating or cooling to be comfortable. Degree days are the difference between the daily temperature mean, (high temperature plus low temperature divided by two) and 18°C. If the temperature mean is above 27°C, we subtract 27°C from the mean and the result is Cooling Degree Days. If the temperature mean is below 18°C, we subtract the mean from 18°C and the result is Heating Degree Days.\n\n#### Unit\n\nTotal number of days exceeding temperature thresholds (Upper: 27°C /Lower: 18°C)\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the global temperature measurement stations.\n2. We filtered the pairs based on distance, keeping mappings of less than 200 kilometers to a CDP city.\n3. We took the average of all of the daily temperage measurements for each location matched to the cities. \n\n$$ Temperature_{City}= \\frac{1}{N}{\\sum_{i} Temperature_{MeasurementStation}}$$\n\n4. We took the sum of all days in a year where the temperature was above 27 degrees (celsius) or below 18 degrees (celsius)\n\n$$ TotalDegreeDays_{City}= {\\sum_{i} \\mathbb{1}_{(Temp>27 | Temp<18)}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$TotalDegreeDaysNormalized_{City}= \\frac{(TotalDegreeDays_{City} - \\min(TotalDegreeDays_{City})}{\\max(TotalDegreeDays_{City}) - \\min(TotalDegreeDays_{City})}$$\n\n\n#### Data Sources\n\nhttps://cloud.google.com/public-datasets/weather\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the animation below we have two separate maps representing the total monthly degree days from 2015-2020 within large global cities. The map on the left represents the total heating days whereas the map on the right represents the total cooling days. When analyzing the animation we can see that the map on the left shows little change and variation amongst regions over time in total heating days (heating usage). Whereas the map on the right shows an increase in the amount of total cooling days (A/C usage) across many global cities with can be indicative of increasing global temperatures."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\ntotal_degree_days_data =  pd.read_csv(\"../input/dataset-1/kpi_output_files_total_degree_days.csv\")\ntotal_degree_days_data = total_degree_days_data[total_degree_days_data['year_reported_to_cdp'] == 2019]\ntotal_degree_days_data = total_degree_days_data.sort_values([\"date\"])\ntotal_degree_days_data = pd.melt(total_degree_days_data, \n                                      id_vars=['id', \"date\",\"year_reported_to_cdp\",\"account_number\",\"organization\", \"cdp_region\", \"longitude\", \"latitude\"], \n                                      value_vars=['total_heating_days','total_cooling_days'],\n                                      var_name='Day Type', value_name='Total Days')\ntotal_degree_days_data['Day Type'][total_degree_days_data['Day Type']=='total_heating_days'] = \"Heating Days\" \ntotal_degree_days_data['Day Type'][total_degree_days_data['Day Type']=='total_cooling_days'] = \"Cooling Days\" \n\nfig = px.scatter_geo(\n    total_degree_days_data, \n    hover_name=\"organization\",\n    color=\"Total Days\",\n    color_continuous_scale= \"viridis\",\n    facet_col = \"Day Type\",\n    animation_frame = \"date\",\n    projection=\"natural earth\",\n    hover_data = {\n        \"cdp_region\": True,\n        \"organization\": True,\n        \"account_number\": True,\n        \"Total Days\": True,\n        \"date\": True\n    },\n    labels = {\n        \"cdp_region\": \"Region\",\n        \"organization\": \"Organization\",\n        \"account_number\": \"CDP Account Number\",\n        \"Total Days\": \"Total Days\",\n        \"longitude\": \"Longitude\",\n        \"latitude\": \"Latitude\"\n\n    },\n    lat=\"latitude\",\n    lon=\"longitude\",\n    range_color = [0,31],\n    template=\"simple_white\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five-seven\"></a>\n\n### 5.7 Non-Residential Building CO2 Emissions\n\n#### Description \n\nHere we look at the total estimated metric tons of carbon dioxide emissions equivalent per year in non-residential buildings in a city. Non-residential may include offices, retail, warehouses, commercial and mixed-use buildings.\n\n#### Rationale\n\nBuildings generate greenhouse gas emissions from direct combustion of fossil fuels (heating, for example) and indirectly by the electricity the residents and equipment consume. \n\nLow values should be pursued.\n\nA declining trend is positive.\n\n#### Societal Impact\n\nCarbon emissions contribute to climate change, which can have serious consequences for humans and their environment. Effects on human activity can include shrinking water supplies, incidents of sever weather leading to structural damage, changes in food supply, and geographical changes on shorelines and rising sea levels that can impact residential and non-residential populations living nearby.\n\n#### Methodology\n\nAnnual building emissions are calculated based on the aggregated floor space of the building by type, the consumption of the building (energy intensity) and the emissions associated with the type of energy consumed (grid intensity).\n\nFloor space is modeled using data sourced from Google Maps, imagery and 3D modeling. The location and size of buildings guides assumptions about whether a building is residential or non-residential as well as the type of energy used to power the structure.\nHere the data applies regional assumptions from the Climate Action for Urban Sustainability (CURB) tool — an internationally recognized third-party data source — to estimate the energy consumption of buildings.\n\nFor more information please visit: https://insights.sustainability.google/methodology \n\n#### Unit\n\ntCO2e/yr = metric tons of carbon dioxide equivalent per year.\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the cities in the Insights Explorer dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took the emissions values for each matched city. \n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ EmissionsAmountNormalized_{City}= \\frac{(EmissionsAmount_{City} - \\min(EmissionsAmount_{City})}{\\max(EmissionsAmount_{City}) - \\min(EmissionsAmount_{City})}$$\n\n#### Data Sources\n\nGoogle Environmental Insights Explorer (11/2020)\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the graph below we can analyze the total yearly CO2 emissions for non-residential buildings for a subset of 125 large global cities. The sizes of the datapoints are the total population counts and the colour represents the CO2 emissions (see legend on the right). Some of the highest CO2 emissions are found within various cities in North America, Europe and Japan, whereas some of lowest emissions are in major cities in Latin American cities. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.scatter(\n    building_data[building_data['sector']=='Non-residential'], \n    hover_name=\"Address\",\n    color=\"co2e_tons\",\n    size=\"Population_2018\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"Geocoded_Address\": True,\n        \"energy_intensity\": True,\n        \"co2e_tons\": True,\n        \"Geocoded_Address\": True\n    },\n    labels = {\n        \"Geocoded_Address\": \"Location\",\n        \"Population_2018\": \"Population (2018)\",\n        \"co2e_tons\": \"Building emissions (Total tCO2e per year)\"\n    },\n    x=\"Geocoded_Address\", \n    y=\"co2e_tons\",\n    template=\"simple_white\",\n    title=\"Non-Residential Buildings Emissions (Total tCO2e per year)\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five-eight\"></a>\n\n### 5.8 Residential Building CO2 Emissions\n\n#### Description \n\nHere we look at the total estimated metric tons of carbon dioxide emissions equivalent per year in residential buildings in a city. Residential buildings may include may include houses and apartments.\n\n#### Rationale\n\nBuildings generate greenhouse gas emissions from direct combustion of fossil fuels (heating, for example) and indirectly by the electricity the residents and equipment consume.\n\nLow values should be pursued.\n\nA declining trend is positive.\n\n#### Societal Impact\n\nCarbon emissions contribute to climate change, which can have serious consequences for humans and their environment. Effects on human activity can include shrinking water supplies, incidents of sever weather leading to structural damage, changes in food supply, and geographical changes on shorelines and rising sea levels that can impact residential and non-residential populations living nearby.\n\n#### Methodology\n\nAnnual building emissions are calculated based on the aggregated floor space of the building by type, the consumption of the building (energy intensity) and the emissions associated with the type of energy consumed (grid intensity).\n\nFloor space is modeled using data sourced from Google Maps, imagery and 3D modeling. The location and size of buildings guides assumptions about whether a building is residential or non-residential as well as the type of energy used to power the structure.\nHere the data applies regional assumptions from the Climate Action for Urban Sustainability (CURB) tool — an internationally recognized third-party data source — to estimate the energy consumption of buildings.\n\nFor more information please visit: https://insights.sustainability.google/methodology \n\n#### Unit\n\ntCO2e/yr = metric tons of carbon dioxide equivalent per year.\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the cities in the Insights Explorer dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took the emissions values for each matched city. \n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ EmissionsAmountNormalized_{City}= \\frac{(EmissionsAmount_{City} - \\min(EmissionsAmount_{City})}{\\max(EmissionsAmount_{City}) - \\min(EmissionsAmount_{City})}$$\n\n#### Data Sources\n\nGoogle Environmental Insights Explorer (11/2020)\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the graph below we can analyze the total yearly CO2 emissions for residential buildings for a subset of 125 large global cities. The sizes of the datapoints are the total population counts and the colour represents the CO2 emissions (see legend on the right). Some of the highest CO2 emissions are found within various cities in southern USA, Mexico, UK and Japan, whereas some of lowest emissions are in major cities in Latin America and the northern and western coastal USA. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"fig = px.scatter(\n    building_data[building_data['sector']=='Residential'], \n    hover_name=\"Address\",\n    color=\"co2e_tons\",\n    size=\"Population_2018\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"Geocoded_Address\": True,\n        \"energy_intensity\": True,\n        \"co2e_tons\": True,\n        \"Geocoded_Address\": True\n    },\n    labels = {\n        \"Geocoded_Address\": \"Location\",\n        \"Population_2018\": \"Population (2018)\",\n        \"co2e_tons\": \"Building emissions (Total tCO2e per year)\"\n    },\n    x=\"Geocoded_Address\", \n    y=\"co2e_tons\",\n    template=\"simple_white\",\n    title=\"Residential Buildings Emissions (Total tCO2e per year)\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-five-nine\"></a>\n\n### 5.9 Automobile Transportation Emissions\n\n#### Description \n\nHere we look at the percentage of total travel emissions using various forms of transportation citizens within a city use to travel.\n\n#### Rationale\n\nPassenger transport mode share refers to the percentage of passenger journeys or trips by the main mode of transport and is typically reported through travel surveys.\n\nSince traffic congestion is generally highest during the time when people are travelling to and from work, collecting data during these periods is most relevant to initiate actions to reduce congestion.\n\nCities should report on the modes of public transportation, personal vehicles, bicycles, walking, and paratransit going to and from work.\n\nAn improving trend and higher value for public and more sustainable options are considered positive.\n\n#### Societal Impact\n\nCarbon emissions contribute to climate change, which can have serious consequences for humans and their environment. Effects on human activity can include shrinking water supplies, incidents of sever weather leading to structural damage, changes in food supply, and geographical changes on shorelines and rising sea levels that can impact residential and non-residential populations living nearby.\n\n#### Methodology\n\nFor a given year, it is calculated as:\n\nNumerator: Total CO2 from automobiles (Automobiles & Motorcycle)\n\nDenominator: Total CO2 from all modes\n\n#### Unit\n\nPercentage of per-capita emissions\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the cities in the Insights Explorer dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took the emissions values for each mode for each matched city. \n4. We took the percentage of the emissions from automobile sources. \n\n$$ AutomobileEmissionsPercentage_{City}= \\frac{AutomobileEmissions_{City}}{TotalTransportEmissions_{City}}$$\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n#### Data Sources\n\nGoogle Environmental Insights Explorer (11/2020)\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the graph below we can analyze the total yearly CO2 emissions for personal and public modes of transportation. Public transportation is categorized as travel by train, rail, tram, ferry or bus, while personal transit is categorized as travel by automobile or motorcycle. The sizes of the data points are the total population counts and the colour represents the CO2 emissions (see legend on the right). Overall, we see that total yearly emissions from personal transit modes is significantly higher than public transit for most cities. Moreover, we can also see that several of the cities with the highest emissions are located in the southern US, Mexico and Brazil."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\ntransport_emissions_data =  pd.read_csv(\"../input/dataset-1/transportation_emissions.csv\")\ntransport_emissions_data[\"transit_type\"] = None\ntransport_emissions_data.loc[transport_emissions_data[\"mode\"].isin(['RAIL', 'TRAM', 'SUBWAY','FERRYBOAT', 'STANDARD BUS']),\"transit_type\"] = \"Public Transit\"\ntransport_emissions_data.loc[~transport_emissions_data[\"mode\"].isin(['RAIL', 'TRAM', 'SUBWAY','FERRYBOAT', 'STANDARD BUS']),\"transit_type\"] = \"Personal Transit\"\ntransport_emissions_data = transport_emissions_data[transport_emissions_data[\"travel_bounds\"] == \"TOTAL\"]\ntransport_emissions_data = transport_emissions_data.groupby(['transit_type', \"Address\", \"Population_2018\",\"year\",\"filename\"]).agg({\"trips\":sum, \"distance_km\": sum, \"co2e_tons\": sum}).reset_index()\n\n\nfig = px.scatter(transport_emissions_data, \n    hover_name=\"Address\",\n    color=\"co2e_tons\",\n    size=\"Population_2018\",\n    color_continuous_scale= \"viridis\",\n    facet_col = \"transit_type\",\n    hover_data = {\n        \"Address\": True,\n        \"co2e_tons\": True,\n    },\n    labels = {\n        \"Address\": \"Location\",\n        \"co2e_tons\": \"Per-Capita Emissions (tCO2e/yr/per capita)\",\n        \"transit_type\": \"Transit Type\",\n        \"Population_2018\": \"Population (2018)\"\n    },\n    x=\"Address\", \n    y=\"co2e_tons\",\n    template=\"simple_white\",\n    title=\"Total Transportation Emissions Per Capita (tCO2e/yr)\")\n\nfig.for_each_annotation(lambda a: a.update(text=a.text.split(\"=\")[-1] ))\n\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-six\"></a>\n\n## 6.0 Mitigation Actions\n\nThere are many ways in which cities can take steps to reduce and prevent greenhouse gas emissions though a variety of innovative mitigation actions. Here we will look at CDP survey response data, and the ambitious mitigations cities take with their action plans and emission-reduction targets.\n\nOur KPIs within this concentration are the following.\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-six-one\"></a>\n\n### 6.1 Emission reduction targets in place \n\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question asses whether the participating city has emission reduction targets in place at a city-wide level.\n \n*Question 5.0 - Do you have a GHG emissions reduction target(s) in place at the city-wide level?*\n\n#### Unit\n\nThe options for participating cities are the following:\n\n* Base year emissions (absolute) target\n* Fixed level target\n* Base year intensity target\n* Baseline scenario (business as usual) target\n* No target\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n0 if responses are \"No target\", 1 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n "},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionannire, question 5, we can see that generally although the total number of responses has decreased from 2019 to 2020, the proportion of the responses for the emission reduction targets options is fairly consistent between 2019 and 2020, with the exception of \"No Target\" responses, which have a higher decrease from 2019 to 2020 relative to the other response options."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/5.0_responses.csv\")\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-six-two\"></a>\n\n### 6.2 Emission reduction action plan in place\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question asses whether the participating city has a climate change mitigation or energy access plan for reducing emission levels.\n \n*Question 5.5 - Does your city have a climate change mitigation or energy access plan for reducing city-wide GHG emissions?*\n\n#### Unit\n\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n* Do not know\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n \n <a href=\"#section-toc\">Back to Table of Contents</a>\n"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionannire, question 5.5, similarily to other responses, we can see that generally although the total number of responses has decreased from 2019 to 2020, the proportion of the responses for the emission reduction targets options is fairly consistent between 2019 and 2020, with the exception of Latin Americal cities who indicated \"Do not know\", which have a higher decrease from 2019 to 2020 relative to the other response options."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/5.5_responses.csv\")\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven\"></a>\n\n## 7.0 Climate Hazards\n\nNatural hazards fall primarily within two categories; tectonic and climactic. Tectonic hazards such as earthquakes, tsunamis, volcanoes and mountain avalanches are a result of the movement of the Earth’s crust. These types of hazards are generally not preventable and usually unpredictable. Climactic hazards such as flooding, tropical storms, and droughts occurs when a particular region as has specific weather conditions that results in such weather events. Such hazard risks are increasing due to population growth, urbanization, pressure on marginal land and changes to the natural environment. In addition, due to climate change and increasing global surface temperatures, the possibility of more droughts and increased intensity of storms will likely occur. As more water vapor is evaporated into the atmosphere it becomes fuel for more powerful storms to develop. More heat in the atmosphere and warmer ocean surface temperatures can lead to increased wind speeds in tropical storms. Rising sea levels expose higher locations not usually subjected to the power of the sea and to the erosive forces of waves and currents. Droughts are also becoming longer and more extreme around the world. This concentration considers various environmental natural hazards and their prevalence within a city.\n\nOur KPIs within this concentration are the following.\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-one\"></a>\n\n### 7.1 Climate risk assessment complete\n\n\n#### Description \n\nHere we specifically look at data provided from the CDP Cities Questionaire. This particular question asses whether the participating city has undertaken a climate change risk or vulnerability assessment.\n \n*Question 2.0 - Has a climate change risk or vulnerability assessment been undertaken for your city?*\n\n#### Unit\n\nThe options for participating cities are the following:\n\n* Yes\n* In progress\n* Intending to undertake in the next 2 years\n* Not intending to undertake\n* Do not know\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n\n#### Data Sources\n\nCDP Cities Questionaire"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionannire, question 2.0, we can see that there is a significant indication from cities in the Middle East responding that they do not intend to undertake a change risk or vulnerability assessment.\n"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/7.1_responses.csv\")\ndata = data[~data['response_answer'].isnull()]\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-two\"></a>\n\n\n### 7.2 Total Population\n\n#### Description \n\nHere we look at the total regional population estimates.\n\n#### Rationale\n\nPopulation growth, in particular, places increasing pressures on the planet’s resources -- water, forests, land and the earth’s atmosphere -- contributing to climate change and challenging environmental sustainability. However, population dynamics do not only affect critical development objectives; they are themselves affected by social, economic and environmental changes.\n\nIn our analyses, higher values indicate more populated regions.\n\n#### Societal Impact\n\nPopulation growth can affect consumption, production, employment, income distribution, poverty and social protections, including pensions; they can also complicate efforts to ensure universal access to health, education, housing, sanitation, water, food and energy.\n\n\n#### Unit\n\nYearly regional population counts.\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we identified the metropolitan area that contained the the region.\n2.  We took the values of the metropolitan areas that contained the city. \n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$PopulationNormalized_{City}= \\frac{(Population_{City} - \\min(Population_{City}))}{(\\max(Population_{City}) - \\min(Population_{City}))}$$\n\n#### Data Sources\n\nhttps://stats.oecd.org/\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the geospatial analysis below we can see that from a subset of the data within the United States, that the highest population density areas are typically along the western and eastern coastal regions which are potentially more susceptible to environmental hazards; particularly those perpetuated by global warming."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\npopulation_data =  pd.read_csv(\"../input/dataset-1/kpi_output_files_population_data.csv\")\npopulation_data = population_data[(population_data['population_year']==2018) & (population_data['iso3']==\"USA\")].drop_duplicates(subset=['fuacode_si', \"population_year\", \"population_var\"])\npopulation_data = population_data.sort_values(['population_values'])\n\npopulation_data = population_data.pivot(index=['fuaname_en', 'name', \"population_year\", \"longitude\", \"latitude\"], \n                                        columns='population_var', values='population_values').reset_index()\n\nfig = px.scatter_geo(\n    population_data, \n    hover_name=\"fuaname_en\",\n    color=\"Population, all ages, administrative data\",\n    size=\"Population, all ages, administrative data\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"fuaname_en\": True,\n        \"name\": True,\n        \"population_year\": True,\n        \"Population, all ages, administrative data\": True,\n        \"Population of the hinterland area\": True,\n        \"Population of the core area\": True,\n        \"Population density of the hinterland area (inhabitants per km2)\": True,\n        \"Population density of the core area (inhabitants per km2)\": True,\n        \"Population density (inhabitants per km2)\": True,\n        \"Growth/shrinking index of the total population (2001=100)\": True\n\n        \n        \n\n    },\n    labels = {\n        \"fuaname_en\": \"City\",\n        \"name\": \"Country\",\n        \"population_year\": \"Year\",\n        \"longitude\": \"Longitude\",\n        \"latitude\": \"Latitude\"\n    },\n    projection='albers usa',\n    scope='usa',\n    lat=\"latitude\",\n    lon=\"longitude\",\n    title=\"Total Population (Metropolitan Areas)\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-three\"></a>\n\n### 7.3 Poverty Rate (after taxes and transfers)\n\n#### Description \n\nHere we look at the poverty rate are defined as individuals who have a yearly income after taxes and transfers that is less than 60% of the median income.\n\n#### Rationale\n\nPoverty is both a driver and consequence of disasters, and the processes that further disaster risk related poverty are permeated with inequality \n\nHigher values indicate regions with a higher prevalence of poverty.\n\n#### Societal Impact\n\nPoverty and disaster risk can also be also prevalent in urban areas. Housing is usually the principal economic asset of poor urban households, providing not only shelter and personal security, but also often their livelihood. Damage or loss to housing, due to a natural hazard, together with essential domestic possessions, therefore, places enormous strain on household economies, given the high monetary cost of replacing lost assets. Urban poverty is understood to have many additional dimensions - including inadequate provision of infrastructure and basic services. \n\n#### Methodology\n\nFor any given year we calculate this as a ratio of number of individuals with an income after taxes and transfers that is less than 60% of the median income over the total number individuals in a region.\n\n#### Unit\n\nRatio.\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we identified the metropolitan area that contained the the region.\n2.  We took the values of the metropolitan areas that contained the city. \n\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n\n#### Data Sources\n\nhttps://stats.oecd.org/\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the geospatial analysis below we can see that from a subset of the data within the United States, that the highest poverty rates are within cities that are in closer proximity to the Global South. However, pockets are prevalent in other areas, specifically in regions where manufacturing was previously a dominant industry and in cities where the cost of living is extremely high (e.g. San Francisco)."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\nincome_data =  pd.read_csv(\"../input/dataset-1/kpi_output_files_income_data.csv\")\nincome_data = income_data.drop_duplicates(subset=['fuacode_si', \"income_year\", \"income_var\"])\nincome_data = income_data.sort_values(['income_values'])\nincome_data = income_data.pivot(index=['fuaname_en','iso3', 'name', \"income_year\", \"longitude\", \"latitude\"], \n                                        columns='income_var', values='income_values').reset_index()\nincome_data = income_data[(income_data['income_year']==2016) & \n                          (income_data['iso3']==\"USA\") &\n                          (~income_data['Poverty rate after taxes and transfers, poverty line 60%'].isnull()) \n                         ]\n\nfig = px.scatter_geo(\n    income_data, \n    hover_name=\"fuaname_en\",\n    color=\"Poverty rate after taxes and transfers, poverty line 60%\",\n    size=\"Poverty rate after taxes and transfers, poverty line 60%\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"fuaname_en\": True,\n        \"name\": True,\n        \"income_year\": True,\n        \"Poverty rate after taxes and transfers, poverty line 60%\": True,\n        \"Gini (at disposable income, after taxes and transfers)\": True},\n    labels = {\n        \"fuaname_en\": \"City\",\n        \"name\": \"Country\",\n        \"income_year\": \"Year\",\n        \"longitude\": \"Longitude\",\n        \"latitude\": \"Latitude\"\n    },\n    projection='albers usa',\n    scope='usa',\n    lat=\"latitude\",\n    lon=\"longitude\",\n    title=\"Poverty rate after taxes and transfers, poverty line 60%\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-four\"></a>\n\n### 7.4 Unemployment Rate\n\n#### Description \n\nHere we look the yearly estimates of the regional unemployment rates.\n\n#### Rationale\n\nThe less labor developed economies use, the more resources and energy they use, thus resulting in more greenhouse gases they emit in urban areas\n\nHigher values indicate regions with a higher prevalence of unemployment.\n\n\n#### Methodology\n\nFor a given year, calculate as:\n\nNumerator: Total population unemployed between 15-64 years old in a region\n\nDenominator: Total population between 15-64 years old in a region\n\n#### Unit\n\nRatio.\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we identified the metropolitan area that contained the the region.\n2.  We took the values of the metropolitan areas that contained the city. \n\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n\n#### Data Sources\n\nhttps://stats.oecd.org/\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"Similar to the results from the previous KPI subset above, in the geospatial timeseries animation below we can see that from a subset of the data within the United States, that unemployment rates are correlated with high poverty rates. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\nlabour_data =  pd.read_csv(\"../input/dataset-1/kpi_output_files_labour_data.csv\")\nlabour_data = labour_data.drop_duplicates(subset=['fuacode_si', \"labour_year\", \"labour_var\"])\nlabour_data = labour_data.sort_values(['labour_values'])\nlabour_data = labour_data.pivot(index=['fuaname_en','iso3', 'name', \"labour_year\", \"longitude\", \"latitude\"], \n                                        columns='labour_var', values='labour_values').reset_index()\nlabour_data = labour_data[ \n                          (labour_data['iso3']==\"USA\")  &\n                          (~labour_data['Unemployment rate (unemployment 15+ over labour force 15+)'].isnull()) \n                         ]\n\nfig = px.scatter_geo(\n    labour_data, \n    hover_name=\"fuaname_en\",\n    color=\"Unemployment rate (unemployment 15+ over labour force 15+)\",\n    size=\"Unemployment rate (unemployment 15+ over labour force 15+)\",\n    color_continuous_scale= \"viridis\",\n    animation_frame=\"labour_year\",\n    hover_data = {\n        \"fuaname_en\": True,\n        \"name\": True,\n        \"labour_year\": True,\n        \"Unemployment rate (unemployment 15+ over labour force 15+)\": True,\n        \"Unemployment (15 years old and over) of the metropolitan area as share of the national value\": True,\n        \"Participation rate growth index (2007=100), 15 years old and over\": True,\n        \"Labour force (15 years old and over) as a share of the national value\": True,\n        \"Employment rate growth index (2007=100), 15 years old and over\": True\n\n    },\n    labels = {\n        \"fuaname_en\": \"City\",\n        \"name\": \"Country\",\n        \"labour_year\": \"Year\",\n        \"longitude\": \"Longitude\",\n        \"latitude\": \"Latitude\"\n    },\n    projection='albers usa',\n    scope='usa',\n    lat=\"latitude\",\n    lon=\"longitude\",\n    range_color = [0, 20],\n    title=\"Unemployment rate (unemployment 15+ over labour force 15+)\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-five\"></a>\n\n### 7.5 Household Disposable Income\n\n#### Description \n\nHere we look at the disposable income per household.\n\n#### Rationale\n\nIncreases in household incomes have the potential to improve societal well-being as well as provide the capacity for citizens to invest in residential sustainable technology for daily living.\n\nHigher values indicate regions with a more affluent population.\n\n\n#### Methodology\n\nFor any given year, we calculate this as a ration of the total yearly income in a region over the total population in a region (number of households).\n\n#### Unit\n\nAverage household disposable income in US dollars.\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we identified the metropolitan area that contained the the region.\n2.  We took the values of the metropolitan areas that contained the city. \n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$HouseholdIncomeNormalized_{City}= \\frac{(HouseholdIncome_{City} - \\min(HouseholdIncome_{City}))}{(\\max(HouseholdIncome_{City}) - \\min(HouseholdIncome_{City}))}$$\n\n#### Data Sources\n\nhttps://stats.oecd.org/\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"Similar to the results from the previous KPI subset above, in the geospatial timeseries animation below we can see that from a subset of the data within the United States, that unemployment rates, high poverty rates are also correlated with lower rates of disposable income."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\nincome_data =  pd.read_csv(\"../input/dataset-1/kpi_output_files_income_data.csv\")\nincome_data = income_data.drop_duplicates(subset=['fuacode_si', \"income_year\", \"income_var\"])\nincome_data = income_data.sort_values(['income_values'])\nincome_data = income_data.pivot(index=['fuaname_en','iso3', 'name', \"income_year\", \"longitude\", \"latitude\"], \n                                        columns='income_var', values='income_values').reset_index()\nincome_data = income_data[(income_data['income_year']==2016) & \n                          (income_data['iso3']==\"USA\") &\n                          (~income_data['Disposable Income per equivalised household (in USD constant prices, constant PPP, base year 2010)'].isnull()) \n                         ]\n\nfig = px.scatter_geo(\n    income_data, \n    hover_name=\"fuaname_en\",\n    color=\"Disposable Income per equivalised household (in USD constant prices, constant PPP, base year 2010)\",\n    size=\"Disposable Income per equivalised household (in USD constant prices, constant PPP, base year 2010)\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"fuaname_en\": True,\n        \"name\": True,\n        \"income_year\": True,\n        \"Disposable Income per equivalised household (in USD constant prices, constant PPP, base year 2010)\": True},\n    labels = {\n        \"fuaname_en\": \"City\",\n        \"name\": \"Country\",\n        \"income_year\": \"Year\",\n        \"longitude\": \"Longitude\",\n        \"latitude\": \"Latitude\"\n    },\n    projection='albers usa',\n    scope='usa',\n    lat=\"latitude\",\n    lon=\"longitude\",\n    title=\"Disposable Income per equivalised household (in USD constant prices, constant PPP, base year 2010)\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-six\"></a>\n\n### 7.6 Average Yearly PM2.5\n\n#### Description \n\nHere we look at the average yearly PM2.5 regional estimates.\n\n#### Rationale\n\nParticulate matter contains microscopic solids or liquid droplets that are so small that they can be inhaled and cause serious health problems. Some particles less than 10 micrometers in diameter can get deep into your lungs and some may even get into your bloodstream. Of these, particles less than 2.5 micrometers in diameter, also known as fine particles or PM2.5, pose the greatest risk to health.\n\nLow values indicate regions with less air pollution.\n\n#### Societal Impact\n\nSocially and economically disadvantaged people may experience increased susceptibility to negative air pollution-related health effects, ranging from conditions such as respiratory irritation and cardiovascular disease to premature death, as a result of higher underlying baseline disease rates in deprived communities.\n\n\n#### Methodology\n\nFor any given year we calculate this as a ratio of total daily PM2.5 measurements over the total number of days in a year.\n\n#### Unit\n\nug/m^3\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we identified the metropolitan area that contained the the region.\n2.  We took the values of the metropolitan areas that contained the city. \n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$PollutionNormalized_{City}= \\frac{(Pollution_{City} - \\min(Pollution_{City}))}{(\\max(Pollution_{City}) - \\min(Pollution_{City}))}$$\n\n\n#### Data Sources\n\nhttps://openaq.org/\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\npollution_data =  pd.read_csv(\"../input/dataset-1/kpi_output_files_pollution_data.csv\")\npollution_data = pollution_data.drop_duplicates(subset=['fuacode_si', \"pollution_year\", \"pollution_var\"])\npollution_data = pollution_data.sort_values(['pollution_values'])\npollution_data = pollution_data.pivot(index=['fuaname_en','iso3', 'name', \"pollution_year\", \"longitude\", \"latitude\"], \n                                        columns='pollution_var', values='pollution_values').reset_index()\npollution_data = pollution_data[(pollution_data['iso3']==\"USA\")]\n\n\nfig = px.scatter_geo(\n    pollution_data, \n    hover_name=\"fuaname_en\",\n    color=\"Mean population exposure to PM2.5 air pollution\",\n    size=\"Mean population exposure to PM2.5 air pollution\",\n    animation_frame=\"pollution_year\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"fuaname_en\": True,\n        \"name\": True,\n        \"pollution_year\": True,\n        \"Mean population exposure to PM2.5 air pollution\": True,\n        \"Share of population exposed to a level of PM2.5 above 10 Âµg/m3\":True,\n        \"Share of population exposed to a level of PM2.5 above 15 Âµg/m3\":True,\n        \"Share of population exposed to a level of PM2.5 above 25 Âµg/m3\":True,\n        \"Share of population exposed to a level of PM2.5 above 35 Âµg/m3\":True\n    \n    },\n    labels = {\n        \"fuaname_en\": \"City\",\n        \"name\": \"Country\",\n        \"pollution_year\": \"Year\",\n        \"longitude\": \"Longitude\",\n        \"latitude\": \"Latitude\"\n    },\n    projection='albers usa',\n    scope='usa',\n    lat=\"latitude\",\n    lon=\"longitude\",\n    range_color = [0, 20],\n    title=\"Mean population exposure to PM2.5 air pollution\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-seven\"></a>\n\n### 7.7 Exposed Economic Capital Stock (Susceptibility to environmental conditions)\n\n#### Description \n\nHere we look at the regional estimates of the economic value of the exposed assets, as well as their physical characteristics in urban and rural scenarios including an estimation of population too. The global exposure dataset is developed at 1km spatial resolution at coastal areas and at 5km spatial resolution everywhere else on the globe. It includes economic value, number of residents, and construction type of residential, commercial and industrial buildings, as well as hospitals and schools.\n\n#### Rationale\n\nThis information is key to assess the potential damages from different environmental natural hazards to each of the exposed elements. \n\nHigher values indicate regions with a larger potential disaster impact.\n\n#### Societal Impact\n\nDisaster events impact both developed and developing countries, in the latter, they can cause a sharp increase in poverty. As disasters pose an important challenge to development, it is important to assess their global, regional, economic, and social impacts. Most economic assessments of the impacts of disasters have concentrated on direct losses—that is, the financial cost of physical damage.\n\n\n#### Methodology\n\nA top-down approach where statistical information including socio-economic, building type, and capital stock at a national level are transposed onto the grids of 5x5 or 1x1 using geographic distribution of population data and gross domestic product (GDP) as proxies.\n\nFor more information please see: https://risk.preventionweb.net/ \n\n#### Unit\n\nUs dollar value per region\n\n#### KPI Score Conversion\n\nGiven that we needed to map the meaurement points to the CDP cities, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the centroids all of regions in the risk exposure dataser.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took an average of the risk exposure measurements for each measurement point mapped to a CDP City. \n\n$$ RiskExposure_{City}= \\frac{1}{N}{\\sum_{i} RiskExposure_{region}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ RiskExposureNormalized_{City}= \\frac{(RiskExposure_{City} - \\min(RiskExposure_{City})}{\\max(RiskExposure_{City}) - \\min(RiskExposure_{City})}$$\n\n\n#### Data Sources\n\nhttps://risk.preventionweb.net/\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the geospatial analysis below we can see that from a subset of the data within the United States, that cities that have the highest potential to be impacted by environmental risk are in the southern west area of the US. As result, they have the highest estimated total risk exposure dollar value."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"from vega_datasets import data\n\nsource = pd.read_csv(\"../input/dataset-1/gar_data.csv\")\n\ncounties = alt.topo_feature(data.us_10m.url, 'counties')\n\nalt.Chart(counties).mark_geoshape().encode(\n    color='tot_val:Q',\n    tooltip=['state_name:N', \"county_name:N\"]\n).transform_lookup(\n    lookup='id',\n    from_=alt.LookupData(source, 'id', [\"tot_val\", \"county_name\", \"state_name\"])\n).project(\n    type='albersUsa'\n)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\ngar_data =  pd.read_csv(\"../input/dataset-1/kpi_output_files_gar_files.csv\")\n\n\nfig = px.scatter_geo(\n    gar_data, \n    hover_name=\"name\",\n    color=\"tot_val\",\n    size=\"tot_val\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"name\": True\n    },\n    labels = {\n        \"name\": \"City\",\n        \"tot_val\": \"Total \",\n        \"longitude\": \"Longitude\",\n        \"latitude\": \"Latitude\"\n    },\n    projection='albers usa',\n    scope='usa',\n    lat=\"latitude\",\n    lon=\"longitude\",\n    title=\"Global Exposure Risk\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-eight\"></a>\n\n### 7.8 Riverine Flood Risk\n\n#### Description \n\nHere we look at the percentage of the population expected to be affected by river flooding in any given year.\n\n#### Rationale\n\nFlood risk is assessed using hazard (inundation caused by river overflow), exposure (population in flood zone), and vulnerability. The existing level of flood protection is also incorporated into the risk calculation. It is important to note that this indicator represents flood risk not in terms of maximum possible impact but rather as average annual impact. The impacts from infrequent, extreme flood years are averaged with more common, less frequent flood years to produce the “expected annual affected population.” \n\nHigher values indicate that a greater proportion of the population is expected to be impacted by riverine floods on average.\n\n#### Societal Impact\n\nImmediate impacts of flooding include loss of human life, damage to property, destruction of crops, loss of livestock, non-functioning of infrastructure facilities and deterioration of health condition owing to waterborne diseases. In addition, economic activities come to a standstill, resulting in dislocation and the dysfunction of normal life for a period much beyond the duration of the flooding. Similarly, the direct effect on production assets, be it in agriculture or industry, can inhibit regularly activity and lead to loss of livelihoods. The spillover effects of the loss of livelihoods can be felt in business and commercial activities even in adjacent non-flooded areas and can more adversely affect individual in lower socio-economics groups.\n\n\n#### Unit\n\nRisk rating from 0-5.\n\n#### KPI Score Conversion\n\nGiven that we needed to map the meaurement points to the CDP cities, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the centroids all of measurement points in the water dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took a average of the water stress measurements for each measurement point mapped to a CDP City. \n\n$$ FloodRisk_{City}= \\frac{1}{N}{\\sum_{i} FloodRisk_{MeasurementPoint}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ FloodRiskNormalized_{City}= \\frac{(FloodRisk_{City} - \\min(FloodRisk_{City})}{\\max(FloodRisk_{City}) - \\min(FloodRisk_{City})}$$\n\n#### Data Sources\n\nhttps://www.wri.org/aqueduct\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the map below, river flood risk is highest in river basin areas with poor drainage capabilities and high average rainfall."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"water_risk_cdp = water_risk_cdp[(~water_risk_cdp['rfr_label'].isnull())]\n\nfig = px.scatter_geo(water_risk_cdp,\n                    lat=\"latitude\",\n                    lon=\"longitude\",\n                    hover_name=\"organization\",\n                    color=\"rfr_label\",\n                   color_discrete_sequence= px.colors.sequential.Plasma_r,\n                    hover_data = {\n                        \"account_number\": True,\n                        \"organization\": True,\n                        \"rfr_label\": True\n                    },\n                     category_orders={\"rfr_label\": \n                                      ['Low (0 to 1 in 1,000)', 'Low - Medium (1 in 1,000 to 2 in 1,000)', 'Medium - High (2 in 1,000 to 6 in 1,000)', \n                                       'High (6 in 1,000 to 1 in 100)', 'Extremely High (more than 1 in 100)']},\n                    labels = {\n                        \"latitude\": \"Latitude\",\n                        \"longitude\": \"Longitude\",\n                        \"account_number\": \"Account Number\",\n                        \"organization\": \"Organization\",\n                        \"city\": \"City\",\n                        \"rfr_label\": \"Riverine flood risk\"\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-nine\"></a>\n\n### 7.9 Coastal Flood Risk\n\n#### Description \n\nHere we look at the percentage of the population expected to be affected by coastal flooding in an average year, accounting for existing flood protection standards.\n\n#### Rationale\n\nFlood risk is assessed using hazard (inundation caused by storm surge), exposure (population in flood zone), and vulnerability. The existing level of flood protection is also incorporated into the risk calculation. It is important to note that this indicator represents flood risk not in terms of maximum possible impact but rather as average annual impact. The impacts from infrequent, extreme flood years are averaged with more common, less newsworthy flood years to produce the “expected annual affected population.” \n\nHigher values indicate that a greater proportion of the population is expected to be impacted by coastal floods on average.\n\n#### Societal Impact\n\nImmediate impacts of flooding include loss of human life, damage to property, destruction of crops, loss of livestock, non-functioning of infrastructure facilities and deterioration of health condition owing to waterborne diseases. In addition, economic activities come to a standstill, resulting in dislocation and the dysfunction of normal life for a period much beyond the duration of the flooding. Similarly, the direct effect on production assets, be it in agriculture or industry, can inhibit regularly activity and lead to loss of livelihoods. The spillover effects of the loss of livelihoods can be felt in business and commercial activities even in adjacent non-flooded areas and can more adversely affect individual in lower socio-economics groups.\n\n\n#### Unit\n\nRisk rating from 0-5.\n\n#### KPI Score Conversion\n\nGiven that we needed to map the meaurement points to the CDP cities, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the centroids all of measurement points in the water dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took a average of the water stress measurements for each measurement point mapped to a CDP City. \n\n$$ FloodRisk_{City}= \\frac{1}{N}{\\sum_{i} FloodRisk_{MeasurementPoint}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ FloodRiskNormalized_{City}= \\frac{(FloodRisk_{City} - \\min(FloodRisk_{City})}{\\max(FloodRisk_{City}) - \\min(FloodRisk_{City})}$$\n\n\n#### Data Sources\n\nhttps://www.wri.org/aqueduct\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the map below, coastal flood risk is highest in areas closer to shorelines and the coast with poor drainage capabilities and high average rainfall."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"water_risk_cdp = water_risk_cdp[(~water_risk_cdp['cfr_label'].isnull())]\n\nfig = px.scatter_geo(water_risk_cdp,\n                    lat=\"latitude\",\n                    lon=\"longitude\",\n                    hover_name=\"organization\",\n                    color=\"cfr_label\",\n                   color_discrete_sequence= px.colors.sequential.Plasma_r,\n                    hover_data = {\n                        \"account_number\": True,\n                        \"organization\": True,\n                        \"cfr_label\": True\n                    },category_orders={\"cfr_label\": \n                                      ['Low (0 to 9 in 1,000,000)', 'Low - Medium (9 in 1,000,000 to 7 in 100,000)', \n                                       'Medium - High (7 in 100,000 to 3 in 10,000)', 'High (3 in 10,000 to 2 in 1,000)',\n                                       'Extremely High (more than 2 in 1,000)']},\n                    labels = {\n                        \"latitude\": \"Latitude\",\n                        \"longitude\": \"Longitude\",\n                        \"account_number\": \"Account Number\",\n                        \"organization\": \"Organization\",\n                        \"city\": \"City\",\n                        \"cfr_label\": \"Coastal flood risk\"\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-seven-ten\"></a>\n\n### 7.10 Drought Risk\n\n#### Description \n\nHere we look at the likelihood of a drought to occur in a region.\n\n#### Rationale\n\nDrought risk measures where droughts are likely to occur, the population and assets exposed, and the vulnerability of the population and assets to adverse effects. \n\nHigher values indicate higher risk of drought.\n\n#### Societal Impact\n\nDrought events affect freshwater resources and can become a great threat to urban water supply systems. According to climate change projections with an increase of air temperature and duration of dry periods, cities may experience a serious water shortage in the future that can limit sustainable urban development.\n\nIn addition, impact on society can also include anxiety or depression about economic losses, conflicts when there is not enough water, reduced incomes, fewer recreational activities, higher incidents of heat stroke, and even loss of human life.\n\n#### Unit\n\nRisk rating from 0-5.\n\n#### KPI Score Conversion\n\nGiven that we needed to map the meaurement points to the CDP cities, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the centroids all of measurement points in the water dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took a average of the water stress measurements for each measurement point mapped to a CDP City. \n\n$$ DroughtRisk_{City}= \\frac{1}{N}{\\sum_{i} DroughtRisk_{MeasurementPoint}}$$\n\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ DroughtRiskNormalized_{City}= \\frac{(DroughtRisk_{City} - \\min(DroughtRisk_{City})}{\\max(DroughtRisk_{City}) - \\min(DroughtRisk_{City})}$$\n\n#### Data Sources\n\nhttps://www.wri.org/aqueduct\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"In the map below, the data shows that drought risk is highest in regions with low average rainfall."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"water_risk_cdp = water_risk_cdp[(~water_risk_cdp['drr_label'].isnull())]\n\nfig = px.scatter_geo(water_risk_cdp,\n                    lat=\"latitude\",\n                    lon=\"longitude\",\n                    hover_name=\"organization\",\n                    color=\"drr_label\",\n                   color_discrete_sequence= px.colors.sequential.Plasma_r,\n                    hover_data = {\n                        \"account_number\": True,\n                        \"organization\": True,\n                        \"drr_label\": True\n                    },\n                     category_orders={\"drr_label\": \n                                      ['Low (0.0-0.2)', 'Low - Medium (0.2-0.4)', 'Medium (0.4-0.6)', 'Medium - High (0.6-0.8)', 'High (0.8-1.0)']},\n                    labels = {\n                        \"latitude\": \"Latitude\",\n                        \"longitude\": \"Longitude\",\n                        \"account_number\": \"Account Number\",\n                        \"organization\": \"Organization\",\n                        \"city\": \"City\",\n                        \"drr_label\": \"Drought risk\"\n                    }\n                    )\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-eight\"></a>\n\n## 8.0 Opportunities\nWhile climate change poses a serious threat to society, it can also pose as an economic opportunity for cities to better energy security, a more accessible and developed tourism industry and increased opportunities for climate smart financial solutions. \n\nOur KPIs within this concentration are the following.\n\n<a href=\"#section-toc\">Back to Table of Contents</a>\n\n<a id=\"section-eight-one\"></a>\n\n\n### 8.1 Identified Opportunities Related To Addressing Climate Change\n\n#### Description \n\nOppotunities selected in response to Question 6.0 in the CDP Cites Questionaire.\n \n*Question 6.0 - Please indicate the opportunities your city has identified as a result of addressing climate change and describe how the city is positioning itself to take advantage of these opportunities.*\n\n\n#### Unit\n\nNumber of opportunities selected\n\n#### KPI Score Conversion\n\nWe converted this into a count of identifed opportunites based CDP responses for our CDP Sustainability Index analysis.\n\n#### KPI Normalization\n\nIn other to map the values to a 0 ot 1 scale, we leveraged Min-Max Standardization.\n\n$$ OpportunityCountNormalized_{City}= \\frac{(OpportunityCount_{City} - \\min(OpportunityCount_{City})}{\\max(OpportunityCount_{City}) - \\min(OpportunityCount_{City})}$$\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n\n<a href=\"#section-toc\">Back to Table of Contents</a>\n"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionnaire, question 6.0, we can see that most cities have within 1-5 opportunities from addressing climate change."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"question_6_data = pd.read_csv(\"../input/dataset-1/8.1_responses.csv\")\nquestion_6_data = question_6_data[question_6_data['column_number']==1]\nquestion_6_data = question_6_data.groupby(['year_reported_to_cdp','account_number','organization','country','cdp_region','longitude', 'latitude'])['response_answer'].nunique().reset_index()\nquestion_6_data = question_6_data[question_6_data['year_reported_to_cdp']==2020]\nquestion_6_data = question_6_data.groupby(['response_answer'])['account_number'].count().reset_index()\nquestion_6_data\n\nalt.Chart(question_6_data).mark_bar().encode(\n    x=alt.X(\"response_answer:Q\", bin=True, axis=alt.Axis(title='# Of Opportunities')),\n    y=alt.Y(\"account_number:Q\", axis=alt.Axis(title='# Of Cities')),\n    color = alt.Color(\"account_number:Q\", sort = \"-x\", legend=alt.Legend(title=\"# of Cities\"))\n)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-eight-two\"></a>\n\n### 8.2 Identified Collaboration Opportunities With Local Businesses\n\n#### Description \n\nOpportunities listed in response to Question 6.2 in the CDP Cites Questionaire.\n \n*Question 6.2 - Does your city collaborate in partnership with businesses in your city on sustainability projects?*\n\n\n#### Unit\n\nBinary indicator\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 if responses are \"Yes\" or \"In Progress\", 0 Otherwise\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n#### Data Sources\n\nCDP Cities Questionaire\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the responses from the CDP Questionnaire, question 6.2, we can see that there is not a significant change in response from 2019 to 2020 with regards to whether a city collaborates in partnership with businesses in the city on sustainability projects."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/8.2_responses.csv\")\ndata = data[~data['response_answer'].isnull()]\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N',  axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-eight-three\"></a>\n\n### 8.3 Green Space\n\n#### Description \n\nHere we look at the estimated percentage of the total area of a city comprised of public green space.\n\n#### Rationale\n\nGreen spaces in cities contribute to the mitigation of and adaptation to climate change, minimize the risks of natural disaster, and support biodiversity conservation by cooling, noise reduction and air filtration of pollutants.\n\nIn this assessment, cities with a higher percentage of green spaces are optimal.\n\n#### Societal Impact\n\nGreen space contributes to the reduction of environmental and health inequalities by providing all population groups with equal opportunities to engage in and benefit from natural environments, and with equal ecosystem services. Urban green space, such as parks, playgrounds, and residential greenery, can also promote mental and physical health and reduce morbidity and mortality in urban residents by providing psychological relaxation and stress alleviation, stimulating social cohesion, supporting physical activity, and reducing exposure to air pollutants, noise and excessive heat.\n\n\n#### Methodology\n\nRatio of green space/total area in a region.\n\n#### Unit\n\nPercentage of green space in a region.\n\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the cities in the green space dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We assigned to the CDP region the green space value of the matched city. \n\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n\n#### Data Sources\n\nGoogle Project Sunroof\n\n#### Data Sources\n\nhttps://data.humdata.org/dataset/green-area-per-capita-square-meters-per-capita\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the scatter plot below we can see that cities that have some of the highest green space per capita fall primarily within North America."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\ngreen_space_data =  pd.read_csv(\"../input/dataset-1/green-space.csv\")\n\nfig = px.scatter(\n    green_space_data, \n    hover_name=\"City\",\n    color=\"green_area_per_capita_2014\",\n    size=\"green_area_per_capita_2014\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"City\": True,\n        \"green_area_per_capita_2014\": True\n    },\n    labels = {\n        \"green_area_per_capita_2014\": \"Total Green Space Per-Capita (2014)\"\n    },\n    x=\"City\", \n    y=\"green_area_per_capita_2014\",\n    template=\"simple_white\",\n    title=\"Total Green Space Per-Capita (2014)\")\n\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-eight-four\"></a>\n\n### 8.4 Presence of zero-emission zone\n\n#### Description \n\nHere we look at regions that indicate that they have a designated zero-emission zone.\n\n#### Rationale\n\nZero-emission or low emission zones are achieved when people with polluting vehicles replace them with vehicles that attain a higher emission standard. Cities can help enforce these zones when public transport is available, or electric taxis or bikeshare options are subsidized. As cities continue to add more and more residents into their downtown core areas, it is crucial that they try to make their cities as healthy as possible.\n\n#### Societal Impact\n\nHaving a greater presence of zero-emission or low-emission zones can help better the air quality in a city. Increasing air quality positively impacts society as citizens enjoy a cleaner quality of air in the region, which in turn can make the citizens in the area healthier.\n\n#### Unit\n\nBinary indicator\n\n#### KPI Score Conversion\n\nWe converted this into a binary indicator for our CDP Sustainability Index analysis.\n\n1 – if a region has a designated zero-emission zone, 0 – if not\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n#### Data Sources\n\nhttps://stats.oecd.org/\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the chart below, we can we see that in a year over year change from 2019 to 2020, regions in both Europe and South and West Asia have increased their declaration of having zero-emission zones."},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"data = pd.read_csv(\"../input/dataset-1/zero-emissions-zone.csv\")\ndata = data[~data['response_answer'].isnull()]\ndata = data.rename(columns={\"account_number\": \"Number of Cities\", \n                                            \"year_reported_to_cdp\": \"CDP Survey Year\", \n                                            \"response_answer\": \"Response\"})\n\ndropdown_category = alt.binding_select(options=list(data[\"CDP Survey Year\"].unique()))\nselection_category = alt.selection_single(fields=[\"CDP Survey Year\"], \n                                          bind=dropdown_category,\n                                          name=\" \")\n\nbar_chart_1 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Proportion of Responses')),\n    y=alt.Y('cdp_region:N', sort='-x', axis=alt.Axis(title='CDP Region')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nbar_chart_2 = alt.Chart(data).mark_bar().encode(\n    x=alt.X('count(Response)', stack=\"normalize\", axis=alt.Axis(title='Number of Cities')),\n    y=alt.Y('Response:N', sort='-x', axis=alt.Axis(title='Response Type')),\n    color=alt.Color('Response', scale=alt.Scale(scheme='category20c'), sort = \"-x\", legend=alt.Legend(orient=\"top\"))\n).add_selection(\n    selection_category\n).transform_filter(\n    selection_category\n).properties(\n    width=300,\n    height=200\n)\n\nalt.hconcat(bar_chart_2, bar_chart_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-eight-five\"></a>\n\n### 8.5 Public Transportation Usage\n\n#### Description \n\nHere we look at the percentage of kilometers travelled using public transportation modes in a region as recent trends indicate that an increased adoption of sustainable technologies in mass transit have the potential to help mitigate CO₂ emissions.\n\n#### Rationale\n\nIncreased public transportation usage reduces pollution, with further reduction potential if sustainable transit technologies are in place. Many regions are implementing this strategy in an effort to meeting sustainable development goals for their region. Fuel technologies such as biofuel (biodiesel and ethanol) buses, and electric transit; or electric-biofuel, electric-diesel, electric-natural gas hybrid buses, represent new trends in environmentally sound, cost-efficient, and energy-efficient mass transit.\n\n#### Societal Impact\n\nThe social benefits of public transport flow from the access it provides to employment opportunities, education and health services as well as recreational facilities. By providing a communal access point to vital goods and services, public transport is a vehicle for social cohesion between diverse demographics in society.\n\n\n#### Methodology\n\nThe percentage is a calculation of the total kilometers traveled using public transportation modes divided by the total kilometers travelled in a region.\n\n#### Unit\n\nPercentage\n\n#### KPI Score Conversion\n\nGiven that the name of the cities were note consistent, we complete the following steps to join datasets:\n\n1. For each region  in the CDP Cities, we calculated the distance to the cities in the Insights Explorer dataset.\n2. We filtered the pairs based on distance, keeping mappings of less than 5 kilometers to a CDP city.\n3. We took the total distance travelled values for each mode for each matched city. \n4. We took the total distance travelled percentage for public transportation modes. \n\n$$ TransportationPercentagePublic_{City}= \\frac{TransportationPublic_{City}}{TransportationTotal_{City}}$$\n\n#### KPI Normalization\n\nGiven that the value was already in the 0 to 1 scale, no further normalization was required.\n\n#### Data Sources\n\nGoogle Environmental Insights Explorer (11/2020)\n\n<a href=\"#section-toc\">Back to Table of Contents</a>"},{"metadata":{},"cell_type":"markdown","source":"When looking at the scatter plot below, we can we see that percent of public transportation usage within total travel is highest in cities within Japan and whereas the lowest are in cities across the US and Canada. The size of the datapoint reflect the total population within these cities. "},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"import pandas as pd\nfrom shapely import wkt\nimport geopandas as gpd\nimport plotly.express as px\n\ntransport_emissions_data =  pd.read_csv(\"../input/dataset-1/transportation_emissions.csv\")\ntransport_emissions_data['co2e_tons'] = transport_emissions_data['co2e_tons']/transport_emissions_data['Population_2018']\n#transport_emissions_data = transport_emissions_data[transport_emissions_data[\"travel_bounds\"] == \"TOTAL\"]\ntransport_emissions_data['Public Transit'] = transport_emissions_data[\"mode\"].isin(['RAIL', 'TRAM', 'SUBWAY', 'FERRYBOAT','STANDARD BUS' ])\n\ntransport_emissions_data_public = transport_emissions_data.groupby(['Public Transit', \"travel_bounds\", \"Address\", \"Population_2018\"])[['trips', 'co2e_tons']].sum().reset_index()\ntransport_emissions_data_public_whole = transport_emissions_data.groupby([\"travel_bounds\", \"Address\", \"Population_2018\"])[['trips', 'co2e_tons']].sum().reset_index()\ntransport_emissions_data_public_whole= transport_emissions_data_public_whole.rename(columns={\"trips\": \"trips_whole\", \n                                                                                     \"co2e_tons\": \"co2e_tons_whole\"})\ntransport_emissions_data_public = transport_emissions_data_public.merge(transport_emissions_data_public_whole, on=[\"travel_bounds\", \"Address\", \"Population_2018\"])\ntransport_emissions_data_public['trips_perc'] = transport_emissions_data_public['trips']/transport_emissions_data_public['trips_whole']\ntransport_emissions_data_public['co2e_perc'] = transport_emissions_data_public['co2e_tons']/transport_emissions_data_public['co2e_tons_whole']\n\ntransport_emissions_data_public = transport_emissions_data_public[transport_emissions_data_public['trips_perc']<1]\n\nfig = px.scatter(transport_emissions_data_public[\n        (transport_emissions_data_public[\"Public Transit\"] == True) & (transport_emissions_data_public[\"travel_bounds\"] == \"TOTAL\")\n    ], \n    hover_name=\"Address\",\n    color='trips_perc',\n    size=\"Population_2018\",\n    color_continuous_scale= \"viridis\",\n    hover_data = {\n        \"Address\": True,\n        \"trips_perc\": True,\n        \"co2e_tons\": True,\n        \"Population_2018\": True\n    },\n    labels = {\n        \"Address\": \"Location\",\n        \"trips_perc\": \"% of Total Travel (km)\",\n        \"co2e_tons\": \"Per-Capita Emissions (tCO2e/yr/per capita)\",\n        \"Population_2018\": \"Population (2018)\"\n    },\n    x=\"Address\", \n    y=\"trips_perc\",\n    template=\"simple_white\",\n    title=\"Public Transportation Usage (%)\")\n\nfig.for_each_annotation(lambda a: a.update(text=a.text.split(\"=\")[-1] ))\nfig.update_layout(yaxis_tickformat = '%')\nfig.update_xaxes(showticklabels=False)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"section-index-results\"></a>\n\n## CDP Sustainability Index Results"},{"metadata":{},"cell_type":"markdown","source":"Below you will find a visualization illustrating the results of our CDP Sustainability Index for 2019. We selected 2019 as the base year for our analysis as not all 2020 data is yet available for our specific indicators in our model. The colour scale on the right is based on the percentile ranking of the cities relative to their score on the index."},{"metadata":{"_kg_hide-input":true,"trusted":true,"_kg_hide-output":true},"cell_type":"code","source":"import pandas as pd\ndf = pd.read_csv('../input/dataset-1/rank_data.csv')\npd.set_option('display.max_rows', 10)\n\nsections = ['Organization/City', 'Country', 'CDP Region', \"Renewable Energy\", \"Water\", \"Governance\", \"Adaptation\", \"Emissions\", \"Mitigation Actions\", \"Climate Hazards\", \"Opportunities\"]\n\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\ncolumns_select = ['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region', \"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"\n                 ]\n\ntooltip_fields = ['Organization/City:N', 'Country:N','CDP Region:N',\"Overall Rank (Global):Q\",\"Overall Rank (Regional):Q\", \"Percentile (Overall):N\",\"Percentile (Regional):N\",\n                  \"Renewable Energy:Q\", \"Water Risk:Q\", \"Governance:Q\", \"Adaptation Capacity:Q\",\"Emissions Reduction:Q\", \n                  \"Mitigation Action:Q\", \"Hazard Mitigation:Q\", \"Opportunity:Q\"\n                 ]\ndf_full = df[df['imputation']==\"Full\"][columns_select].reset_index(drop=True)\ndf_regional = df[df['imputation']==\"Regional\"][columns_select].reset_index(drop=True)\n","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"from vega_datasets import data\n\ncountries = alt.topo_feature(data.world_110m.url, feature='countries')\nbackground = alt.Chart(countries)\\\n    .mark_geoshape(fill='lightgray',stroke='white')\\\n    .project('equirectangular')\n\ncdp_cities = alt.Chart(df_regional)\\\n    .mark_circle()\\\n    .encode(\n        longitude='longitude:Q',\n        latitude='latitude:Q',\n        color=alt.Color(\"Percentile (Overall)\" , \n                        scale=alt.Scale(scheme='inferno')\n                       ),\n        tooltip=tooltip_fields)\\\n    .properties(\n    title='CDP Sustainability Index (Global Rankings)',\n    width=1000, height = 700\n               )\n\nbackground + cdp_cities","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"plots_dict = {}\n\nfor region in df_regional['CDP Region'].unique():\n    plots_dict[region] = {\n        \"data\": df_regional[df_regional['CDP Region']==region],\n        \"boundary\": alt.Chart(countries)\\\n                .mark_geoshape(fill='lightgray',stroke='white')\\\n                .project(\n                scale=250, \n                center=[df_regional[df_regional['CDP Region']==region].longitude.mean(), \n                        df_regional[df_regional['CDP Region']==region].latitude.mean()]\n            ),\n        \"points\": alt.Chart(df_regional[df_regional['CDP Region']==region])\\\n                    .mark_circle()\\\n                    .encode(\n                        longitude='longitude:Q',\n                        latitude='latitude:Q',\n                        color=alt.Color(\"Percentile (Regional)\" , \n                                        scale=alt.Scale(scheme='inferno')\n                                       ),\n                        tooltip=tooltip_fields)\\\n                    .properties(\n                    title=f'CDP Sustainability Index (Regional Rankings) - {region}',\n                    width=400, height = 400\n                               )\\\n                    .project(\n                    scale=250, \n                    center=[df_regional[df_regional['CDP Region']==region].longitude.mean(), \n                            df_regional[df_regional['CDP Region']==region].latitude.mean()]\n)\n\n\n    }","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"We’ve also mapped below the ranking and relative percentile scores for cities in each of the CDP regions."},{"metadata":{},"cell_type":"markdown","source":"### North America"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"(plots_dict['North America']['boundary'] + plots_dict['North America']['points']) ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The radar plot demonstrates the scores for the Top 20 cities in North America. The sub index score values for each category are plotted along their corresponding axis. We can see that for the best performing cities in North America, the scores are relatively similar for governance and adaptation (input KPIs  derived from the CDP surveys). However, the best performing cities amongst this group differentiate themselves in regards to their renewable energy, emission reduction and water risk scores. "},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\ndf = df[df['imputation']==\"Regional\"]\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\nsubset_df = pd.melt(df, \n                    id_vars=['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region'], \n                    value_vars=[\"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"],\n        var_name='category', value_name='score').reset_index(drop=True)\n\nsubset_df[\"Region Name\"] = subset_df['Organization/City'] + \", \" + subset_df['Country']\n\nfig = px.line_polar(subset_df[(subset_df['Overall Rank (Regional)']<=20) & (subset_df['CDP Region']==\"North America\")], \n                    r=\"score\", theta=\"category\", color='Region Name', line_close=True,\n                    color_discrete_sequence=px.colors.qualitative.Plotly,\n                    template=\"plotly_dark\",)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Europe"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"(plots_dict['Europe']['boundary'] + plots_dict['Europe']['points']) ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The radar plot demonstrates the scores for the Top 20 cities in Europe. The sub index score values for each category are plotted along their corresponding axis. We can see that for the best performing cities in Europe, the scores a relatively similar for governance and adaptation (input KPIs from derived from the CDP surveys) as well as water risk. However, the best performing cities amongst this group differentiate themselves in regards to their renewable energy, emission reduction and climate mitigation action scores."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\ndf = df[df['imputation']==\"Regional\"]\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\nsubset_df = pd.melt(df, \n                    id_vars=['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region'], \n                    value_vars=[\"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"],\n        var_name='category', value_name='score').reset_index(drop=True)\n\nsubset_df[\"Region Name\"] = subset_df['Organization/City'] + \", \" + subset_df['Country']\n\nfig = px.line_polar(subset_df[(subset_df['Overall Rank (Regional)']<=20) & (subset_df['CDP Region']==\"Europe\")], \n                    r=\"score\", theta=\"category\", color='Region Name', line_close=True,\n                    color_discrete_sequence=px.colors.qualitative.Plotly,\n                    template=\"plotly_dark\",)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Latin America"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"(plots_dict['Latin America']['boundary'] + plots_dict['Latin America']['points']) ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The radar plot demonstrates the scores for the Top 20 cities in Latin America. The sub index score values for each category are plotted along their corresponding axis. We can see that for the best performing cities in Latin America, the scores a relatively similar for governance and adaptation (input KPIs from derived from the CDP surveys) as well as water risk. However, the best performing cities amongst this group differentiate themselves in regards to their renewable energy, emission reduction and climate opportunity scores. "},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\ndf = df[df['imputation']==\"Regional\"]\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\nsubset_df = pd.melt(df, \n                    id_vars=['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region'], \n                    value_vars=[\"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"],\n        var_name='category', value_name='score').reset_index(drop=True)\n\nsubset_df[\"Region Name\"] = subset_df['Organization/City'] + \", \" + subset_df['Country']\n\nfig = px.line_polar(subset_df[(subset_df['Overall Rank (Regional)']<=20) & (subset_df['CDP Region']==\"Latin America\")], \n                    r=\"score\", theta=\"category\", color='Region Name', line_close=True,\n                    color_discrete_sequence=px.colors.qualitative.Plotly,\n                    template=\"plotly_dark\",)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### South and West Asia"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"(plots_dict['South and West Asia']['boundary'] + plots_dict['South and West Asia']['points']) ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The radar plot demonstrates the scores for the Top 20 cities in South and West Asia. The sub index score values for each category are plotted along their corresponding axis. We can see that for the best performing cities in South and West Asia, the scores a relatively similar for governance and adaptation (input KPIs from derived from the CDP surveys). However, the performance amongst the 6 other sub index categories is fairly variable."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\ndf = df[df['imputation']==\"Regional\"]\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\nsubset_df = pd.melt(df, \n                    id_vars=['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region'], \n                    value_vars=[\"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"],\n        var_name='category', value_name='score').reset_index(drop=True)\n\nsubset_df[\"Region Name\"] = subset_df['Organization/City'] + \", \" + subset_df['Country']\n\nfig = px.line_polar(subset_df[(subset_df['Overall Rank (Regional)']<=20) & (subset_df['CDP Region']=='South and West Asia')], \n                    r=\"score\", theta=\"category\", color='Region Name', line_close=True,\n                    color_discrete_sequence=px.colors.qualitative.Plotly,\n                    template=\"plotly_dark\",)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Southeast Asia and Oceania"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"(plots_dict['Southeast Asia and Oceania']['boundary'] + plots_dict['Southeast Asia and Oceania']['points']) ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The radar plot demonstrates the scores for the Top 20 cities in Southeast and Oceania. The sub index score values for each category are plotted along their corresponding axis. We can see that for the best performing cities in Southeast and Oceania, the scores a relatively similar for governance and adaptation (input KPIs from derived from the CDP surveys) and water risk as well. However, the performance amongst the 5 other sub index categories is fairly variable."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\ndf = df[df['imputation']==\"Regional\"]\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\nsubset_df = pd.melt(df, \n                    id_vars=['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region'], \n                    value_vars=[\"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"],\n        var_name='category', value_name='score').reset_index(drop=True)\n\nsubset_df[\"Region Name\"] = subset_df['Organization/City'] + \", \" + subset_df['Country']\n\nfig = px.line_polar(subset_df[(subset_df['Overall Rank (Regional)']<=20) & (subset_df['CDP Region']=='Southeast Asia and Oceania')], \n                    r=\"score\", theta=\"category\", color='Region Name', line_close=True,\n                    color_discrete_sequence=px.colors.qualitative.Plotly,\n                    template=\"plotly_dark\",)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### East Asia"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"(plots_dict['East Asia']['boundary'] + plots_dict['East Asia']['points']) ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The radar plot demonstrates the scores for the Top 20 cities in East Asia. The sub index score values for each category are plotted along their corresponding axis. We can see that for the best performing cities in East Asia, the scores a relatively similar for governance and adaptation (input KPIs from derived from the CDP surveys) and water risk as well. However, the performance amongst the 5 other sub index categories is fairly variable."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\ndf = df[df['imputation']==\"Regional\"]\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\nsubset_df = pd.melt(df, \n                    id_vars=['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region'], \n                    value_vars=[\"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"],\n        var_name='category', value_name='score').reset_index(drop=True)\n\nsubset_df[\"Region Name\"] = subset_df['Organization/City'] + \", \" + subset_df['Country']\n\nfig = px.line_polar(subset_df[(subset_df['Overall Rank (Regional)']<=20) & (subset_df['CDP Region']=='East Asia')], \n                    r=\"score\", theta=\"category\", color='Organization/City', line_close=True,\n                    color_discrete_sequence=px.colors.qualitative.Plotly,\n                    template=\"plotly_dark\",)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Africa"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"(plots_dict['Africa']['boundary'] + plots_dict['Africa']['points']) ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The radar plot demonstrates the scores for the Top 20 cities in Africa. The sub index score values for each category are plotted along their corresponding axis. We can see that for the best performing cities in Africa, the scores a relatively similar for governance and adaptation (input KPIs from derived from the CDP surveys) and water risk as well. However, the performance amongst the 5 other sub index categories is fairly variable."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\ndf = df[df['imputation']==\"Regional\"]\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\nsubset_df = pd.melt(df, \n                    id_vars=['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region'], \n                    value_vars=[\"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"],\n        var_name='category', value_name='score').reset_index(drop=True)\n\nsubset_df[\"Region Name\"] = subset_df['Organization/City'] + \", \" + subset_df['Country']\n\nfig = px.line_polar(subset_df[(subset_df['Overall Rank (Regional)']<=20) & (subset_df['CDP Region']=='Africa')], \n                    r=\"score\", theta=\"category\", color='Region Name', line_close=True,\n                    color_discrete_sequence=px.colors.qualitative.Plotly,\n                    template=\"plotly_dark\",)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Middle East"},{"metadata":{"trusted":true,"_kg_hide-input":true},"cell_type":"code","source":"(plots_dict['Middle East']['boundary'] + plots_dict['Middle East']['points']) ","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\ndf = df[df['imputation']==\"Regional\"]\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n\nsubset_df = pd.melt(df, \n                    id_vars=['account_number', 'longitude', 'latitude', \"Percentile (Overall)\", \"Percentile (Regional)\",\n                  \"Overall Rank (Regional)\",\"Overall Rank (Global)\", 'Organization/City', 'Country',\n                  'CDP Region'], \n                    value_vars=[\"Renewable Energy\", \"Water Risk\", \"Governance\", \"Adaptation Capacity\", \n                  \"Emissions Reduction\", \"Mitigation Action\", \"Hazard Mitigation\", \"Opportunity\"],\n        var_name='category', value_name='score').reset_index(drop=True)\n\nsubset_df[\"Region Name\"] = subset_df['Organization/City'] + \", \" + subset_df['Country']\n\nfig = px.line_polar(subset_df[(subset_df['Overall Rank (Regional)']<=20) & (subset_df['CDP Region']=='Middle East')], \n                    r=\"score\", theta=\"category\", color='Region Name', line_close=True,\n                    color_discrete_sequence=px.colors.qualitative.Plotly,\n                    template=\"plotly_dark\",)\nfig.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Sensitivity Assessment"},{"metadata":{},"cell_type":"markdown","source":"In order to ensure that are index results were not sensitive to assumptions we made in the imputation processed, we analyzed the distribution of the scores for the categories where we needed to impute data."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"df = pd.read_csv('../input/dataset-1/rank_data.csv')\npd.set_option('display.max_rows', 10)\n\nsections = ['Organization/City', 'Country', 'CDP Region', \"Renewable Energy\", \"Water\", \"Governance\", \"Adaptation\", \"Emissions\", \"Mitigation Actions\", \"Climate Hazards\", \"Opportunities\"]\n\ndf = df.rename(columns = {\"organization\": \"Organization/City\", \"city\": \"City\", \"country\": \"Country\",\"cdp_region\": \"CDP Region\",\n                          \"renewable_energy\": \"Renewable Energy\", \n                          \"water\": \"Water Risk\", \n                          \"governance\": \"Governance\", \n                          \"adaptation\": \"Adaptation Capacity\",\n                          \"emissions\": \"Emissions Reduction\",\n                          \"mitigation_actions\": \"Mitigation Action\", \n                          \"climate_hazards\": \"Hazard Mitigation\", \n                          \"opportunities\": \"Opportunity\", \n                          \"overall_rank\": \"Overall Rank (Global)\",\n                          \"overall_rank_regional\": \"Overall Rank (Regional)\",\n                          \"Percentile_Overall\": \"Percentile (Overall)\",\n                          \"Percentile_Overall_Regional\" : \"Percentile (Regional)\"\n                         })\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"When looking at the distribution of Emission Reduction Scores for imputation using the overall mean compared to imputation using the regional mean, we see that there is not a significant variation in the distributions as the modes are in strong alignment."},{"metadata":{"_kg_hide-input":false,"trusted":true},"cell_type":"code","source":"bar_1 = alt.Chart(df.loc[df['imputation']==\"Full\",:])\\\n        .mark_bar()\\\n        .encode(x=alt.X('Emissions Reduction:Q', bin=True, axis=None),y='count()')\\\n        .properties(title='Emissions Reduction Scores - Overall Mean Imputation')\n    \nbar_2 = alt.Chart(df.loc[df['imputation']==\"Regional\",:])\\\n        .mark_bar()\\\n        .encode(x=alt.X('Emissions Reduction:Q', bin=True, axis=None),y='count()')\\\n        .properties(title='Emissions Reduction Scores - Regional Mean Imputation')\n    \nrule_1 = alt.Chart(df.loc[df['imputation']==\"Full\",:])\\\n        .mark_rule(color='red')\\\n        .encode(x='mean(Emissions Reduction):Q',size=alt.value(5))\nrule_2 = alt.Chart(df.loc[df['imputation']==\"Regional\",:])\\\n        .mark_rule(color='red')\\\n        .encode(x='mean(Emissions Reduction):Q',size=alt.value(5))\n\nalt.hconcat(bar_1+rule_1, bar_2+rule_2)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"When looking at the distribution of Climate Hazard Mitigation Scores for imputation using the overall mean compared to imputation using the regional mean, we see that there is not a significant variation in the distributions as the modes are in strong alignment.![image.png](attachment:image.png)","attachments":{"image.png":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAdQAAAAzCAYAAAAuEfniAAAgAElEQVR4Ae3dBbRkTXAX8MLd3SW4u7sGCO4SnADB4eDu7pZAgru7BAiuSQju7gR3l/N72/8vlU73zDxbyXads3tn7tzbUl7V3fWqDhwMHAwcDBwMHAwcDBwMHAy8kRj4JFX1CTYj/yhV9Yk3v53bH3Ew8JGq6lNVFXq/ajCGT/OajOVV4+L0/0gM/KWq+vatjV9SVf+7qj7huPfRquo/V9Vvqqof3Z577EcM/L8e0Mgnrar/V1UfeXr3r1TVV5ruPdXXH1xVn2Vq7ONW1c8e975JVf3R6feHfP3CVfWPxouX5tP7nvvJe7+wqn7k/OOF71+rqr5BVe3we+HVe/30U6vqf1bVL5veYmB/c1X9x6r6r1X1Z6rqq49n/nZVfemq+kZV9cem9+779bNV1Q+4x0u/pap+2PS8OZCT54bOD72v/1tVf7ffqCpOCnn6VROewruPoetTtNGH+/2q6j+M8aL1z6sqeuZVwKevqn9dVf+uqj7PPQdg3D/mnu/c+vgtfPqyZHYe82N4qbcVvvrkQ6dzsl5X+JZV9QfG4KKPlmP9WVX1vu2Xf1pV/n3jce9LVNW/rSoK+ikN6qd9oEH9ZBuD+oUuRD1teg/6+C+r6vNOb37Oqvo3495zGNRL8+l9T8OqvPdeVfWj5h8vfP/1VfU9quqjVtWXufDcY3/6a1X19aZGKNM/VVWM16erqo9RVd+nqv5VVaH33xkGldGY6TA1dfXrdx2G++qD44GVQf1pVfVLb23gEc/tDCqH0j+/B95j3GNQO57Cu4+h61O0kXGS+/8znCWR4ecb+uXd88BLvpLdv/DAPt+lqhjk54Bb+PRlyew8v8fwUm8rfPUmGNRv1Qxq9FGfyzuf362q/sb4hrn/YVX98GZkefO/sap+QVX91qr67VX1j6vqh4x3PvZQfn+9qn5nixJ/x4jgtMeif+13enzxoRvUzzr6+ydV9YuqisEAq/vdoH6xqvqgqnL9bVX1xUc0wfj/5ar6Zy1KE9X92qpCxN9TVX+k9TO6qy85FDsHQgQgIvqxI2L3/TPkwfE+xfCHq4pQ/tWq+rlV9c+r6tdU1cesqh1uWjP1uUdb3oPbRKiZz5cdc2G8/1BVfeap768x6IPIv7LhgUFFA+P7e1VF4QJz/4Lj8+cabX6dERn+i6r6NlUlypUBgLOfOHCBtl9tvHeNth77KlX1u0bfDDsljy6i079fVe862nJBv39fVR+/3fPxu1cVpRUG1v8vHynhPz2MGnriy289nhPZftGq+uhV9fNHX9r2DH6CZ1HwT76RPpcM6qqPj1dVP2HgEB45EK6fsarec/CJ/v9c1R3tZ/rt+KGjhjH9vVX1k9pNdPaPQQ2eOu+S7dBVH+8/ZIFj8GdHO9f4v7exkk3NXOMNfcuAfZE2dpklNAPfs6roEvLEwQMrXhIl/cmqer+BY985YbMe+m5Dp6G7rMjHGm26iEgFD/9l6K4dv+PjX11V9BMdE/ihg0ctUVzjR9kWPOg5+lOWAwhSIpu+4wuOUufTFV2eWmY/RVX9xRdDuvufHsBfn3LwCp3od/P4RI2XZG9W+nbHY+mi86YgAE//wCGvf6KqPtN4UGBHV//5qvoOVTVHsSuafcWq+v3paOgacrzTxzJ56Mte4JeVnN5sUCkASo6hYjwZNAoOo4HfXVXfaRjUfzCMEOMIAdLC33EwCQQgsvSJCIMigQj3MR5G79ANKkZDFPcQEULB6n4MKsb+kGH0PEsACSbDL7JBpK9QVdJjmIKBIXwU248Y4/dMB2MklHACyX9rzEU/IvVOTO9iMkRiUOGQc0LReF4UtsNN7xOeRDzwREkSNpD5wOEPGsbtvcfn3vc3Hx4/xqOk8p75Ekr3pIYoMQY0xkkfBJeS4HFiuO8/1rXQlkH9XoMW5sS5oHjg5hpt0Z9xtpSQef244WRwTL7qtF5FiYbmL2b/Yf/PmM1RyjceLWHmYBAEwm6cP3MY2m865vqpxzPmKW2DvhwXY7yFPvDCyTG+/CMbDNGqj28xaEXB47s/XlW/YfC29OaXGs4FJU3WZvrt+KFjBH2+XUv7Wos0PzzLoAZP5hjeDc7QlQP9U4aDyHFj4ME1/u9trGRTG9d4wzOyYuRSf5xQBgNQ1mSKE8mp5gjh0RUvmTM8UMzkfkXL6DbLBfQGWvRlIbigpDkiDO2O3//mcEQ5Kh9njNWFwyblG7xc4kc6wnjxjOUjQYYxv8/Qj2n2Pw0+7ny6ostTy2zXx8YiLY+XOMPkheH6LsNhjw6Gv52+3fFY5tl5kzGHG31ZCpRaxSPwhAfo+i9QVegQXkk7K5oZnxR+MjgCQgHgikeMg14V+HHctL+S05sNqoFRFF93eCLfcChTEVGYWmQGcSYZwPg81t9XVX9wRDKiGREDw0qweDkAMhi5DiGgq0hPqg+IUv7HMGCr+6IryIdo0UoghsQ4ezrOc7wlitzcACP434bRHbfuLoTl6w/FZE4EGSQ1Mb7eXXradU4bUcKMxA43aSeMROkDRng2qDxZtCB4fpcm631TyN2zDB4YVP8CPDyeV4yT+zGoPid91IWFQ4GRAqI/keA12jIq+gmIRuEfrNYfeIU88x1kzDEUUWCiXsDp490Chj/GGX9SApw1hsXnnkq7Rh/toaXIXySZf+6Fx1Z9vBjJC/zDWaIiykJqE03R6dcNgxr6XeKHtOmK/ykbhp3DRKlYz6fQu0H1bHg3dCXLjBmDD3jzMajX+D9tSHOuZFPb13hjdHuXKhWZMczWfuGFM835CFhX3/FSDKpoCexo+QGD52QkOMUz9LWxHb9T5PTCDLNBvcSPdATeD3BoZLJWBhVtO5/u6PKUMht9nPHFoAqe/vugE4MkiAofxKBGFrxL337lCzyW9l3Dm5Hn7NuhO8mYQAJN2BX/6Iif0RsYv690FNpwrrUpEDC/HY8wqNkPo/mVnN7LoEo78BRZ5uy+RCyDx0yAoeprqIzN5x8pV6kUUWz+uU+wCCtg0ESuHUJAxBE9hRmlSo3Du7v7FIpo2nPxQmJI5nEy5FI7frfpBvBKILlHqJiDYqOMRdSiNQQHIfz4enfpRo2w9E1JFCUlJx29wk3a4USYS+bOM58NqqiYIjcvRkF7vW8GVfouEDwwplKPAWuUxsk4fflx88uNyMbXlXDasBaceYYn/71voK13YiS8pz+CBlYGlaKz8Y0XHDBvhpITtDOoyRhIR+M9oG80ZHxtfCFYlPIHDiXVFdU1+miPYDNUHbKGuuvDswy8jA4jCaSu4QCeKQxKyOdOv0v8MJq5u+AZkTkHl6FAWzi8xaAyRF2u8ByDegv/R5GaU28jMstxvib3IrQZnxQn+fnx02Yv2SSKbMVL5sExCOxoyRjBMUPNiRbZd+gGdcfvdCBZmWE2qJf4kewx7gFzRX8GNZsHOcuci25QL9HlKWWWPobPzEEWj3MGBDEyASJljrHMCx6MQe12gb4l750/wmOjuXcu0asxqOmb48vR+ukj+xm74koXdtjRjKMpQ6cthhTseIRBNV+wk9N7GVQTxmzx7DUsXeceQwtmQxWDShikKkV9EAPhhPuaYMWgapuiZsAgVAqGsbM+tbrPewgxpRGtlXo2hmQeZwwqBpZmM0ZGQRvdoMbjzTopZyKbjhi5OdUA8YyA1MvOoO5w8wKjL/6XTvy+I/I09tmgwkE2bDAGNlD0vrtC1mLwwKB6Fr44NDFYmCprUwyDVCEQhdl1F6VJWAi6nbciLEZcWlv67Bpt8YL+pGrQxo5YET9YGVQ4lI6TfqSspeooXTzGwXuIQTX/eM4Us4yKeeOvrK/cQp9LBnXXB6OhP3gPfLOxPuQ7h44RhNuZfjt+SDuuMah4En8n+l8Z1PBup6u1R0pQlGrtiEG9hf97GyvZROtrvEHZ4g0Rn+etP3KIfvFwjo2XjOIB9Ldss+Kl2aCuaCmFLIonL4AB6lk297pB3fH7UxlUUT05ElUzBBwrRgMfgCylMajh00t0eUqZlRlkUG36Qxf8yaDiE0sTwNg9Y2klOninb1c8Npp55xLe3BlUdoRRlMHjbLAzdGWHHc08wzaQD/IIVjyij25Qd3J6L4Nql6Xcvc1IgRgu64IA4vquUcwu3UUBUlwm7h8lDa4JlvZzbMa6kg03lJD1sGxYWd2nBEJMionXxHuy4SJrqH2cMajGaQ1V1JLNMZ99jDUXQm1eNvFgJuNDbN4tYehGlVcu7w5vCGatMyBCJSw73OQ5V3Mk9Mb1wW1TUuYDF4we5mPgCV3ve1bIec8cCa3xSdlkExnG8B1e+pqttKs5WhMKftEIHniSoqtEFtdoa17fdvCA98yLUQMMqjnPAFccHniQeaCwrbWCGOEcm5kF0EYY6ShAUXMMbXKx+claDh7RnmMOnCiOos1Zt9BnZVBzbGbXhz7hkiHgHPqHR6Ss8Ix/1nXQigD3DMOOH8b07i6UmrVpDqi2komIQQ2ePBze5dmHrpQIxwuvy3iQW3CN/3sbK9nUxi28wTHEf+SLk4YWydKYC6fCmLJxZ8VLoiR4COxoie+jV/CB4ygdGFR6Aez4HT1XEWqOzdzCj5zuDxkyjMdtkMwuZ3OVwfuAIWscgM6nO7o8tczSGdENHGAGG07oETqA4xVHLLw024Xo2x2PDVTfXcKbX3PwZo9QyR0QNMn04NUEbuOnu8uOZn60Dm0tlb4EOx7hGCdCldFYyWl3vKKPRrPPczGQx54ly3rIPMLd/fm5S9+/84iuPCMKJcg8sRl4xlnz6r/NO1D9RiDM+xpcww1GikJZteV3XloYzjO39i2NKmLswBFJar/f96x2Z4ATUeRD4L6000/WUh7S3/yOqGoGAgYHgWv0yXO766qP3bPovMJxf/4aP/Rnb/k88640MYMEZD9kBwL34X/v3Je+6cdV9BVl1++Ty9X9W/pa0RKtGb1b4TH8vusjWSw6cpY92aAVD3U+3dHlqWXW2LpsZD6M0Upf5vf5eonH+rMzb/bf8pm8mP8luA/NVjwyt32LnM7vvFXfRdo8RNGMKNimgAMHA28jBmz+kYWxRs2DtyHxwPNiIAb1eXt5fVo/PPb60OLZRsIbsgPtuQ5jP9vAT8MHA0+MAXsYyMItUd8Td/1WNifyy1ru24KAw2NvC6XPPA8GDgYOBg4GnhQDUqlSwwcOBq5iwE7EXvPYC7fU20zDfTNV7j3V1TpKP0e1arePNZspVs89x72n6K+Pv298eY7x7trMhq/d7/e5bzNFNuXd57237dlO93lH6TVcpFbs/FzuP3catm8Om8fw2O+Zw2Pb8f5Dx9nfs2xgX4qNgNmw9BRjS73ip2jrtPEaYWBlUPuZxmtDtdnmuWrk9nOpu3H0sUo9vcy091P018f/qgyqnZfzhpIdvq/d78fGrj37Nv/e6X5fg5pzjjP+cv+5DaqNLY+tPT2PPd8zh3x/zPWh4+zvoY0jSU+t53LW9jHze6nvOqtl0I592L7t2ISt6zbuKDlljYXw28Jui74zO7xG4BiJ80q2pTsLx2NJXUsHlhFd7co8P167uzhWYhu77fs5F7mq2Zn2HM3RngO/c91Wc3B/rpPJaJiDLdf+5XjBXJvTAX3zn+tF2iJuC79t1JR4j1DtUIQvW8ntaHM2yx8ZcMSl1yPOnOFRhGNHn+MNnjF3eDMf28ThPJVAbJ4yZ/fswnRQWTqlH3JPvU1jd0zD0RA78Rw45yk6sgIvxtbHmhqkxubgs/k5n6pyjR118Onoj6NMtsHb3j7vFIabuQapwgS28uMT/TmSYcd0+rvUrvZsj3d2Vn9wEphxjRaEV7EGn227Bzs+HT/fnbu8pf6r86OrWreprywjcJ8axys52RlUdBfROyaFJqqOOU5hq35w4riOKjs2Ftnub1f0iu52Pl7CefCSqyNVjk4AThp+jePlCAX5XPU9Xrm72D0Md3QCXtU/2L23kz3vzHSntPEzmYafHAVb4bfXis3Zcm32+3iVDM41uD23Gpczj73m625O3gepqUymHH2xKZK8r/7aEbrLMpEdtHY8Dqx0Yp9Dn9uOB0ZTdxc1B5zPdAQvtcEzTg/Q4WTQOH7FwE108KzT855iGTa3mR8dGz2Hx218o3vpN0fndjqZTsR7vQZ7r1dsXG8E8NKknjC+TQrCdSX9IIOBorSdRXRWB4M745mD8QziXPs2Z7KUfXLUQ2QXIQ1C9EXgEJfgUvy7mp1pD8J3dVvNwbid9XMoGkM6l6hfzoKoAvE9Y0wOajv75h4PUv9zvUhtOh+q+ouSf868OWwdcLSh19sk6PqDt16POM/3Q/EUA+PB0BFS41II3ncGGuMxFAyl1CCDxLBjxp4mTHkwkRN8MnpwoBCCecIXA+8MVR9rKryYGycFHSgHRpgAB5/OuDrvSHlpt8OqZBpapviD+aZ2avrbtesspj5UZHHW0Rz7Ae4Z13BDUM2RYaMAwI5Px8/vFC+gkHb1Xx0Z2NUhpXy9t6ofyniFZnCGZuQDrORkZ1C1Qbn6HY86F8hgqBiFPnCBF/AifmDkpf9WdFchaofzMbQPc0E/ZyRFGfCPLylL8uMsLadw1XdvhH6Ya7/uxkxWV7KX9ma6R26MM0UQOBMr/KIjBe88pHYC/T6c4de5BvduXIIJhoaMkK1ruGCU1Z5WnIKDadmHnjPe+WjYineMlTGaa2L3OfS57Xggc3elUxQ44BSaj88ZJ73jjDZeoxeV/cOL0cGzTs97jgJxngVj9BW+ETiwHxwJgQAdwFHe6WS05bzTZanBTgYYYkV/8OQbAQSOVxAgOIwL4ClTWJS86MtnlT1SVsoi9Fz7NsiP56QqkUPsHe5TszPtSS8AinSu22oOjGggdTIxGwUYwyOK+xzDoKY2J4Za1YtE+FQI0S6l3Q2qe0lHIby253rEwYFnZ4OaClQMmeILYRjeHYElYAwhsDuZkXG4fGVQKZhUdfL8qr5sxur3GDjzYxgD6KKqEXxS3gFKmzffYWVQKaJEU6J2ygykv127eCv48LwydN2gutfHDzecHGCu5k7J7Ph0PPqOQc3O1lVtT8qL80T5gV7rNgZ1V/PVuFb1q1dycsmgpuY0ReIwO8gavEpVal2TRf/8nWKZFbCi+w7n45UPdyFHlib0i+4iU20oWI6eu77TEEPHCeBgpvbr7r2d7KUt1053SrdXOuJEmvMKv97dpUVz37zijHme8pY5242LAcpehd2c+thjcNBaBKfgCN3FGM+w4p1dHWPvZg5zOyse6M/INJIX8pva4BmnM8ndFsgadYMafRadnve0z3ByIqPnGGw60R/kAKJn2aqdTkbbVDbzPEdLpuiNS/liql6HlnIXKYGfMyofQQwm6zUVpXakdDAJRKb2bQxgPCeKmNB3uE/Nzrk9Ee9ct9UcKPJA6mRyCKRYKB5KiiPA+PRSYrt6kbOSlx7ZGVRMFCfDGBzIVu1HBBgIo/HcMA9mBTxWkXBAVZIYVAvygMKgyOK5Bbept9kNKiYXZTBiuxq2MXDo619AtEyJzjzBIRJBdyCQngdSWgw9g2qsIlveKG9XhJP+du36vY8Drq8Z1NSJ5iBRVozkik/xT0CGpVfXWdX25IB1WoreGWoQg4pGt9Y4Ru+VnFwyqJkbR1CKEUi78fwpQYakyyInYEf3Hc5Hsx/uQh44pPqQMcCbUn/kmLFc9T03Mtd+tWFl9d5O9np7s0GN3HhG9KavFX79vjM6uT/jJjW4d+NiUFNR5xZcdIOD3gyRCJFuiKHJXBnU0J0hUTnpUk3szCHvu+54oD9Dd8gC0UEieJFlxumKtwMq53WDGr0TnZ73PD8bVFkNOitBBp1o6W+nk7tO1F4qLn2EM6hKP/HkKU/KAdGlFCGHgMdrSe3b2QAG+SGSKyMixedZqTKCsavZObe3M6iUKcNCsWIKnqbUXSIG+XjjlcroBpWnKR0jfcgw8Mwpc8aTMRYZSOHxumeD6nvS37vappn3QwwqRSZy5eljMGkiBsEceHypt2nTjzJ3nt3Vl+1jjYFTV9U6HOdIBoBi4hzNimZlUCmduQapdV4KOOftCIOIIv3t2lViUESsFKSSdgRxNqh9/F35xKDC84pPeyWW2aByElPODJ+hN37Y1SGNQSULt9Y41udKTh5qUDksvHeGH1B6osEd3Xc4R29yOIMsSEo/+s2SgbSo8coCrPrubTB4yeyQR/wKB6v3drLX2+t0n5UuvZFlqlkPaYOOkS6fIfdn3MSg7sbVDeotuIjBsbSk/CaZpWPsi0iGJWPrPB2DeqkmduaQ9113PNCfoafm2uAZJ13MCVbulM4TrT7UoLIVdDUZA9aNyedOJ8+0jUFNveLRzOt/wVS8pgBvXKQBpDcYVGlJigcDW/sT+QBeiXu99i3PiwKZvZnxyjuXW2t2zgYVgee6rebA25LK6HUybZrhySGiOVKYFrd977U5V/UiMQSDBh8iIKmwvinJRHq9zV1t00w4KTvtYp7UG9YGpRVg1BKh6tN8GHwOB5CKnutt8v6s7cguSNczTuZorWZVw5aXaL3DWEQjhNM8ZRIoipknVgZVasm45hqkq9qp6W/XLkcATihdKX1pb6UiO3Rcd+XDoIp+wI5Px893jkOPUK3trOpQU6iMJ97utW6NiyHb1Q/t44pS1PdKTvxFpp6+zxh7G5wK68KAo0iu4Ir8SVUanysHK2vgM913OKdEKfYZKHw05VgB8+/Zn1Xf49G7C9xwaMkdnkpEuXtvJXu9vU73LjeeMX98uMIvvSFLwtGejWru25fRdV9qcGt7NS4GKxGqZ3ZzyvjpGmuo5IzTg0/pKDw+b/LrdO+8s6pjrP3Moc9txwMZj+uqNnjG6Xc6k1PMmFrDV3N41sEJkvp7aED2u57zd7WzsdGyBJ7f6eSZtjGo+kLDLPP1ubzxn+eFdBPi1axq394yWR4bYzBD1rjm+7vvlIa09apOpnu3tEeRmMsMIhzj3IHxM0KBW/rKs5euETCRRJyTPC+d0vt03/hFLwER8QzzWPO7+fV3c//alaJY9WNshPBWYKQoDsBgMAoijxl245+fW/Hp/Ez/bu74JHBrHVL8Yry3wGPkZNf+ap4reqze9y7F/lBY9d3b4qys5Gb13k720t4tdN/ht2co0p7r7n5/5tq48uxqTvmtX8ntSsf0Z3afV3plN4drPECfyMjNesU9gU7uW/ayge+xYN4dbtXJecd6LFoceEkYiEF9Sd29lG5iUF9KZ6+4E8qXRyp9zjPmHD3USXuKqbwNdUhFQauU71Pg77Tx5mLAzlzH6GS2ZM6SrXxzZ3RGfm8M8ICybnfvl1/TF6wnPiRqfE2nc3VYvFa7S/0xeJHvqwZrhqfW7aumwun/VWDAEoIlLJmBAwcDBwMHAwcDBwMHAwcDbxYGskljN2o7gVMV5Nqzuzb6/fu00WtAPlX61DEGG5X6YnwfXz73vnPPNe9JcdpgcitYQ8j5t7Rx67sv47nUFX0dUu+h0cuY96U+noJOOz661O9T/tb/qPJ9ZO8pxzC31XXK/Nv5fjDwRmPADrx5wblPqJ8hu/Zsf2/3+T5t9PNLT21QbRSSFtlB77s/k/ccU7mPQe3nTNNGb/dVf86ZuGNQP5QST0GnHR99aC/P+0kpQgUdwH1kb7zyLJeuU56lg9PowcBjMOBIRP8Dw46lWDt6z3F0wNZ3i9Q2MTgQ7HnnUJ0PUgTAMY1VfUZnzxyr8L5dk3nWWFf1Y1e1HOd5pY1rz841IBnUVe1X28znmqhznyINxwAcDbLFXoSaGpZ2ntku7siOIzmi8bnvXjfY2VhlHWNQHZ2xRd1uS/gSuTo2E1jV6k3fnnG8RvvGpi1KfFe7VZ+rGqvpy45M50UduXF8xTZ/OxKvvdfritri7rjJrbVR07crml6rb6zgiJ2HNkt4lqMBVjRy39EQNOs1mle1TF+08uL/HR6cPX1IHVetkqlVndb0e42PFMfoNYjtoFasBM8564cnwE4uyO6qNvF47e6ykvduUCN7siWOUnCiHKuAX3TYzdF9x6YczbpPbeIVH6sw1HVKH//5fDDwWmDA+R5CCWwIoUxt8HG428I0JU1pU2Aq4DgTRFE5xJ+D7qv6jM6j9fqxeXZXP9Y5JDs9ecKpCESZd0gb1551lKHXgGRQGa1e+9XW8Gu1ODkKDjpT2MbtDC5HIgehjZOAO3tlx6Rznz73vnvdYArKubQYVErWgXRjcwZuPuyfkolw4gybs2vp29EU5/DmOp+iRNHvXId3VWO143ZXB/Tae8bBoXB28761UXv/aHqtvjEjj9fgKfWSdzSyOxEvzzWaGQCHzRmG1DLt49jhwbMPqeOqbfyn37nGb/q9xkeqzaBpahDvagnv5MIxJOeN8RrDyMntQFZX8t4NamTPWcz3G/Wmnck0Lvy5m6P7jCqa3ac28YqP1XzuOqXP4Xw+GHgtMCAyYjQYApEkxQEImYoaaj8SJgqfku4RVISMcXKWMAaA0XXgvqdn8izDvKofSxmsajmO4dxd0sYtz/Z0GaFOZRIHwR2uZgCu1SWlXNVtDYhyu0GlJFY1OnvfDGrqBscYxqDCPRDVMko7g9pTvmnDoXKZgoAD2yIWimhVh3dVYzXv5rqqA3rLez3le5/aqOnXFU1Tz1fmYK5vHGcupcycwUM/UfGKRozmqkbzqpZpH4fPKzyQi6xj38I7oZP28F8qdnHMOI4drvERPmG4chZxV0t4JReyTYpZkG+g0tlsUN1fyfvKoOKx1Brm4NEdMairOZp7nr9PbeIdH3ed8mJG5/+DgdcMAyJQtVqlZSgLESrvnmGQpmTofKbUpI4CMXC7+oyd+fPsrn4sZZCqKtpPpYz05Zo2bnm2GzVCnTqZKVV3Sy3OuVi0Mm/doBoTZTjX6Ox99zKHUbIMKqcj29Kl7IxRW5RfDlbvavWKcnd1PimiXpu5Vzmaa6z2w9LGtqoBbI6X3vN7N6i97wyHKXsAAAP2SURBVJRy29VG9W6g01S0LxUekHJPLWYZEwB3oippzl7QOzTa9Qm3cy3T0eTdZYcHBjVVcm7hndBao53/ehWc3u8lPmJQe4Un+FjVEu441DYZUl5yV5s4/e/kfWVQyWD6lp3wxzRiUCNjfY597hzuW2sT7/i465SM/1wPBl4rDFBWhE/KEkitJMohNGrGql26M6hSSvFOe83cXoczxnBXP3alDKSgO6SNW55l+Ow+BV2oY1DNi9Mw10Qdr9xdrNlRRhS89UR/f7MbVIZwVaOz970zqCIO0ZXzl9ZlFfQXdVGcl2r1RlHv6nzuFNGqxqqC64FdHdBr73k/dUXnvmNQOWlS43O95PTt2mm6MqjWi1f1kpW6XNFo1+eqlmkfxw4P3aDewjuhk7Y7/3Vjk36v8dFsUHe1hDsOtR2ndFebOP3v5H1lUPEpB9w6Lkeyp3wfYlCdtV7J4cxLcQy7TsG/shkHDgZeKwzYiEH4Ui8Rk9uIZM3IP8xs2zzB6xFqttLv6jPyXKWErJ3k2V39WMrAel0gyiDfXdPGLc/2GpBdofXar9dqcerTHz8n8KI36e5+bGZXo7P3zdlI3eAcpbD5SD1e41LU3tXfIgTXavV2Rb2q80kRWa8LRBFJ6a1qrOa5XR3Qa+95P3VFRYu9bwZVhgOsaqOOn+4unab4ZlXfeFcveUWjXZ+rWqZ9HDs8PLSOq7Y7/60M6jU+grseoaKJGr8yA3gT3kHHoe+RIc4FZ3SuTfzirRcFRFbyvjo2g3etoZIHvKpwviIkuzn2+/epTbzj465TLOPAwYGDgTcCA9JrPS14adC7+oy7OpyM+HNXArq1BuS1WpzGuqubCSerGp239r2qeas9UVAHdNjhK2tr/fndZwrRfHawqwN67b1L+Elf5vDQWqZpw3U13x2NVn1K+65qmfY+dnjoz/h8jXfm5y99vy8fweUttYRvrU18i7z7owX+JiuwyYlBvcRP49GbLrficqdTburkPHQwcDBwMHAwcDDwUAw8ZW3idxsb6Ozc9ddq7B4+cDBwMHAwcDBwMPDWYMCmp6eqTSwboS1Hlg4cDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDBwMHAwcDLxBGPj/Khyl9KXD/nUAAAAASUVORK5CYII="}}},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"bar_1 = alt.Chart(df.loc[df['imputation']==\"Full\",:])\\\n        .mark_bar()\\\n        .encode(x=alt.X('Hazard Mitigation:Q', bin=True, axis=None),y='count()')\\\n        .properties(title='Climate Hazard Mitigation Scores - Overall Mean Imputation')\n    \nbar_2 = alt.Chart(df.loc[df['imputation']==\"Regional\",:])\\\n        .mark_bar()\\\n        .encode(x=alt.X('Hazard Mitigation:Q', bin=True, axis=None),y='count()')\\\n        .properties(title='Climate Hazard Mitigation Scores - Regional Mean Imputation')\n    \nrule_1 = alt.Chart(df.loc[df['imputation']==\"Full\",:])\\\n        .mark_rule(color='red')\\\n        .encode(x='mean(Hazard Mitigation):Q',size=alt.value(5))\nrule_2 = alt.Chart(df.loc[df['imputation']==\"Regional\",:])\\\n        .mark_rule(color='red')\\\n        .encode(x='mean(Hazard Mitigation):Q',size=alt.value(5))\n\nalt.hconcat(bar_1+rule_1, bar_2+rule_2)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"When looking at the distribution of Renewable Energy Scores for imputation using the overall mean compared to imputation using the regional mean, we see that there is not a significant variation in the distributions as the modes are in strong alignment."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"bar_1 = alt.Chart(df.loc[df['imputation']==\"Full\",:])\\\n        .mark_bar()\\\n        .encode(x=alt.X('Renewable Energy:Q', bin=True, axis=None),y='count()')\\\n        .properties(title='Renewable Energy Scores - Overall Mean Imputation')\n    \nbar_2 = alt.Chart(df.loc[df['imputation']==\"Regional\",:])\\\n        .mark_bar()\\\n        .encode(x=alt.X('Renewable Energy:Q', bin=True, axis=None),y='count()')\\\n        .properties(title='Renewable Energy Scores - Regional Mean Imputation')\n    \nrule_1 = alt.Chart(df.loc[df['imputation']==\"Full\",:])\\\n        .mark_rule(color='red')\\\n        .encode(x='mean(Renewable Energy):Q',size=alt.value(5))\nrule_2 = alt.Chart(df.loc[df['imputation']==\"Regional\",:])\\\n        .mark_rule(color='red')\\\n        .encode(x='mean(Renewable Energy):Q',size=alt.value(5))\n\nalt.hconcat(bar_1+rule_1, bar_2+rule_2)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"When looking at the distribution of Water Risk Scores for imputation using the overall mean compared to imputation using the regional mean, we see that there is not a significant variation in the distributions as the modes are in near perfect alignment. This is largely due to the fact that most of the data used in the index was globally available and imputation was minimal."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"bar_1 = alt.Chart(df.loc[df['imputation']==\"Full\",:])\\\n        .mark_bar()\\\n        .encode(x=alt.X('Water Risk:Q', bin=True, axis=None),y='count()')\\\n        .properties(title='Water Risk Scores - Overall Mean Imputation')\n    \nbar_2 = alt.Chart(df.loc[df['imputation']==\"Regional\",:])\\\n        .mark_bar()\\\n        .encode(x=alt.X('Water Risk:Q', bin=True, axis=None),y='count()')\\\n        .properties(title='Water Risk Scores - Regional Mean Imputation')\n    \nrule_1 = alt.Chart(df.loc[df['imputation']==\"Full\",:])\\\n        .mark_rule(color='red')\\\n        .encode(x='mean(Water Risk):Q',size=alt.value(5))\nrule_2 = alt.Chart(df.loc[df['imputation']==\"Regional\",:])\\\n        .mark_rule(color='red')\\\n        .encode(x='mean(Water Risk):Q',size=alt.value(5))\n\nalt.hconcat(bar_1+rule_1, bar_2+rule_2)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Comparisons to CDP Responses"},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true},"cell_type":"code","source":"cdp_index = pd.read_csv(\"../input/dataset-1/cdp_index_inputs.csv\")\ndf_regional_compare = df_regional.merge(cdp_index[['account_number', \n                             'values_1_1', 'values_1_2',\n                             'values_2_1',\n                             'values_6_1','values_6_2',\n                             'values_7_1']], on = 'account_number')\n\nresponse_columns = {\n    'values_1_1': \"Question_8_0\", \n    'values_1_2': \"Question_8_6\",\n    'values_2_1': \"Question_14_5\",\n    'values_6_1': \"Question_5_0\",\n    'values_6_2': \"Question_5_5\",\n    'values_7_1': \"Question_2_0\"}\n\nmapping = {1: \"Yes\", 0: \"No\"}\ndf_regional_compare[list(response_columns.keys())] = df_regional_compare[list(response_columns.keys())].replace(mapping)\n\ndf_regional_compare = df_regional_compare.rename(columns=response_columns)\n\nna_subset = df_regional_compare[df_regional_compare['CDP Region']==\"North America\"].dropna()\n\nbackground = alt.Chart(countries)\\\n    .mark_geoshape(fill='lightgray',stroke='white')\\\n    .project(\n                    scale=250, \n                    center=[na_subset.longitude.mean(), \n                            na_subset.latitude.mean()]\n)\n\ncdp_cities_1 = alt.Chart(na_subset)\\\n    .mark_point()\\\n    .encode(\n        longitude='longitude:Q',\n        latitude='latitude:Q',\n        color=alt.Color(\"Renewable Energy\" , \n                        scale=alt.Scale(scheme='inferno')\n                       ),\n        shape=alt.Shape('Question_8_0:N', title=\"Response\"),\n        tooltip=tooltip_fields)\\\n    .properties(\n    title='Does your city have a renewable energy or electricity target?',\n    width=400, height = 400\n               )\\\n    .project(                    scale=250, \n\n                    center=[na_subset.longitude.mean(), \n                            na_subset.latitude.mean()]\n)\n\ncdp_cities_2 = alt.Chart(na_subset)\\\n    .mark_point()\\\n    .encode(\n        longitude='longitude:Q',\n        latitude='latitude:Q',\n        color=alt.Color(\"Renewable Energy\" , \n                        scale=alt.Scale(scheme='inferno')\n                       ),\n        shape=alt.Shape('Question_8_6:N', title=\"Response\"),\n        tooltip=tooltip_fields)\\\n    .properties(\n    title='Does your city have a target to increase energy efficiency?',\n    width=400, height = 400\n               )\\\n    .project(                    scale=250, \n\n                    center=[na_subset.longitude.mean(), \n                            na_subset.latitude.mean()]\n)\n\ncdp_cities_3 = alt.Chart(na_subset)\\\n    .mark_point()\\\n    .encode(\n        longitude='longitude:Q',\n        latitude='latitude:Q',\n        color=alt.Color(\"Water Risk\" , \n                        scale=alt.Scale(scheme='inferno')\n                       ),\n        shape=alt.Shape('Question_14_5:N', title=\"Response\"),\n        tooltip=tooltip_fields)\\\n    .properties(\n    title='Does your city have a publicly available Water Resource Management strategy?',\n    width=400, height = 400\n               )\\\n    .project(                    scale=250, \n\n                    center=[na_subset.longitude.mean(), \n                            na_subset.latitude.mean()]\n)\n\ncdp_cities_4 = alt.Chart(na_subset)\\\n    .mark_point()\\\n    .encode(\n        longitude='longitude:Q',\n        latitude='latitude:Q',\n        color=alt.Color(\"Emissions Reduction\" , \n                        scale=alt.Scale(scheme='inferno')\n                       ),\n        shape=alt.Shape('Question_5_0:N', title=\"Response\"),\n        tooltip=tooltip_fields)\\\n    .properties(\n    title='Do you have a GHG emissions reduction target(s) in place at the city-wide level?',\n    width=400, height = 400\n               )\\\n    .project(                    scale=250, \n\n                    center=[na_subset.longitude.mean(), \n                            na_subset.latitude.mean()]\n)\n\ncdp_cities_5 = alt.Chart(na_subset)\\\n    .mark_point()\\\n    .encode(\n        longitude='longitude:Q',\n        latitude='latitude:Q',\n        color=alt.Color(\"Emissions Reduction\" , \n                        scale=alt.Scale(scheme='inferno')\n                       ),\n        shape=alt.Shape('Question_5_5:N', title=\"Response\"),\n        tooltip=tooltip_fields)\\\n    .properties(\n    title='Does your city have a climate change mitigation or energy access plan for reducing city-wide GHG emissions?',\n    width=400, height = 400\n               )\\\n    .project(                    scale=250, \n\n                    center=[na_subset.longitude.mean(), \n                            na_subset.latitude.mean()]\n)\n\ncdp_cities_6 = alt.Chart(na_subset)\\\n    .mark_point()\\\n    .encode(\n        longitude='longitude:Q',\n        latitude='latitude:Q',\n        color=alt.Color(\"Hazard Mitigation\" , \n                        scale=alt.Scale(scheme='inferno')\n                       ),\n        shape=alt.Shape('Question_2_0:N', title=\"Response\"),\n        tooltip=tooltip_fields)\\\n    .properties(\n    title='Has a climate change risk or vulnerability assessment been undertaken for your city?',\n    width=400, height = 400\n               )\\\n    .project(                    scale=250, \n\n                    center=[na_subset.longitude.mean(), \n                            na_subset.latitude.mean()]\n)\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The maps below illustrate the comparisons of the indicated city ambitions from the CDP survey responses against the amalgamated category scores that primarily consist of our output KPIs. We mapped this based on a subset of the data in North America."},{"metadata":{},"cell_type":"markdown","source":"Here we look at the responses from cities that indicated in their survey response whether they had a renewable energy target. From the map below we can see that cities that responded ‘yes’ in the survey are more likely to have a higher renewable energy score than those that responded ‘no’."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"(background + cdp_cities_1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Here we look at the responses from cities that indicated in their survey response whether they had a target to increase their energy efficiency. From the map below we can see that cities that responded ‘yes’ in the survey are more likely to have a higher renewable energy score, and thus higher energy efficiency than those that responded ‘no’."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"(background + cdp_cities_2)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Here we look at the responses from cities that indicated in their survey response whether they had a publicly available Water Resource Management strategy. From the map below we can see that cities that responded ‘yes’ in the survey are more likely to have a water risk score, and thus higher energy efficiency than those that responded ‘no’. A higher score means that there is lower water related risk."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"(background + cdp_cities_3)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Here we look at the responses from cities that indicated in their survey response whether they had a GHG emissions reduction target in place at a city-wide level. From the map below we can see that there is not a strong statistical relationship between the responses and the scores. "},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"(background + cdp_cities_4)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Here we look at the responses from cities that indicated in their survey response whether they had a climate change mitigation or energy access plan for reducing city-wide GHG emissions. From the map below we can see that there is not a strong statistical relationship between the responses and the scores. Although the relationship is not clear, their emission reduction scores maybe influenced by other external factors."},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"(background + cdp_cities_5)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Here we look at the responses from cities that indicated in their survey response whether they had a climate risk or vulnerability assessment undertaken for the city. From the map below we can see that cities that responded ‘yes’ in the survey are more likely to have a higher hazard mitigation score, than those that responded ‘no’"},{"metadata":{"_kg_hide-input":true,"trusted":true},"cell_type":"code","source":"(background + cdp_cities_6)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Thank you \n\nThank you for taking the time to read through our notebook. We hope that you found our report helpful.\n\nPlease feel free to reach out if you have any questions.\n"}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}