├── .gitignore ├── LICENSE ├── README.html ├── README.md ├── assets └── validation_gui.jpg ├── data ├── GFDabove.13.csv ├── GFDabove_13_wBias.csv ├── SSP2010.csv ├── SSP2030.csv ├── aqueduct_dictionary.xlsx ├── aqueductcountrydata.csv ├── compiled_pop_ghsl_ts_2019_08_04.csv ├── compiled_pop_ghsl_ts_wbias_2019_08_04.csv ├── flood_mechanism │ ├── flood_mechanism_wbias.csv │ ├── hotspot_countries_jrc_20210112_Dam.csv │ ├── hotspot_countries_jrc_20210112_HeavyRain.csv │ ├── hotspot_countries_jrc_20210112_SnowIceRain.csv │ └── hotspot_countries_jrc_20210112_Surge.csv ├── gfd_floodmechanism.csv ├── gfd_popdictionary.xlsx ├── gfd_popsensitivity.csv ├── gfd_popsummary.csv ├── gfd_qcdatabase_2019_08_01.csv ├── gfd_validation_metrics.csv ├── gfd_validation_points_2018_12_17.csv ├── gfd_validation_sensitivity.csv ├── pop_sensitivity_analysis │ ├── gee_hrsl_countries.csv │ ├── sensitivity_analysis_africa_20210105.csv │ ├── sensitivity_analysis_australia_20210105.csv │ ├── sensitivity_analysis_canada_20210105.csv │ ├── sensitivity_analysis_caribbean_20210105.csv │ ├── sensitivity_analysis_centralamerica_20210105.csv │ ├── sensitivity_analysis_centralasia_20210105.csv │ ├── sensitivity_analysis_easia_20210105.csv │ ├── sensitivity_analysis_europe_20210105.csv │ ├── sensitivity_analysis_indianocean_20210105.csv │ ├── sensitivity_analysis_mexico_20210105.csv │ ├── sensitivity_analysis_mongolia_20210105.csv │ ├── sensitivity_analysis_oceania_20210105.csv │ ├── sensitivity_analysis_sasia_20210105.csv │ ├── sensitivity_analysis_satlantic_20210105.csv │ ├── sensitivity_analysis_seasia_20210105.csv │ ├── sensitivity_analysis_southamerica_20210105.csv │ ├── sensitivity_analysis_swasia_20210105.csv │ └── sensitivity_analysis_usa_20210105.csv ├── popchange_Aque_GFD.csv ├── sample_frame_CC20_D1_051618.csv └── shp_files │ ├── dfo_polys_20191203.dbf │ ├── dfo_polys_20191203.prj │ ├── dfo_polys_20191203.shp │ └── dfo_polys_20191203.shx ├── ext.datafig10.R ├── ext.datafig8.R ├── flood_detection ├── __init__.py ├── modis.py ├── modis_toolbox.py └── utils │ ├── __init__.py │ ├── export.py │ ├── misc.py │ └── otsu.py ├── flood_stats ├── __init__.py └── pop_utils.py ├── gee_landsatTools.txt ├── gee_mainFig3.txt ├── gee_misc.txt ├── gee_sampleFrameLandsat.txt ├── gee_validationGUI.txt ├── main_floodmechanism.txt ├── main_gfd.py ├── main_gfdsummarystats.R ├── main_popchange.txt ├── main_popsensitivity.txt ├── main_popstats.py ├── main_sensitivityanalysis.R ├── main_validation.ipynb └── uncertaintyanalysis.R /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Jonathan Sullivan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Global Flood Database Scripts & Data 2 | 3 | This repository includes code and supporting data for the Global Flood Database. Below are descriptions of the data and code and how they relate to *Tellman et al, Satellite imaging reveals increased proportion of population exposed to floods; Nature; https://doi.org/10.1038/s41586-021-03695-w* 4 | 5 | ### Data 6 | #### Flood Maps 7 | 8 | The flood maps (.tif files) can be accessed through a visualization and data portal at: http://global-flood-database.cloudtostreet.info/ 9 | 10 | You can also download the entire database as GeoTIFF files directly from Google Cloud Storage (GCS) using the [gsutil](https://cloud.google.com/storage/docs/gsutil_install) [cp command](https://cloud.google.com/storage/docs/gsutil/commands/cp) from the GCS bucket "gfd_v1_4". You can use the following command to download the entire database to a local directory: 11 | 12 | `gsutil -m cp -r gs://gfd_v1_4 your/local/directory/to/save/to` 13 | 14 | 15 | #### Flood Mapping 16 | 1. `data\shp_files\dfo_polys_20191203.shp`: the Dartmouth Flood Observatory (DFO) flood polygon dataset used in our analyses and processing of satellite imagery. 17 | 2. `data\gfd_qcdatabase_2019_08_01.csv`: the Quality Control (QC) database described in Tellman et al. 18 | 19 | 20 | #### Validation 21 | 3. `data\gfd_validation_points_2018_12_17.csv`: validation data of 123 selected flood events that includes geo-location of each assessment point, the classified data for different methods (e.g. 3day Standard), analyst initials and spectral data from the interpretation imagery (i.e. Landsat-5, 7 & 8). Field values are explained in the `main_validation.ipynb` (see below) 22 | 4. `data\gfd_validation_sensitivity.csv`: assessed validation points up to 400 points for selected flood events to test appropiate sampling intensity 23 | 5. `data\gfd_validation_metrics.csv`: summarized validation metrics (e.g. commission error) for each validation flood 24 | 6. `data\sample_frame_CC20_D1_051618.csv`: a summary of available Landsat images (5, 7 & 8) for each flood event. Used to determine which flood events can be used to collect validation data. The field `DELTA` is the number of days following max flood extent, `CLOUD_COVER` is the maximum allowable percent cloud cover for a validation image, `X` and `Y` are the centroid of the flood event from the DFO polygon. 25 | 26 | #### Exposed Population Estimates 27 | 7. `data\SSP2010.csv`: 2010 population estimates from the SSP2 (Socioeconomic pathways scenario) 28 | 8. `data\SSP2030.csv`: 2030 population estimates from the SSP2 (Socioeconomic pathways scenario) 29 | 9. `data\aqueductcountrydata.csv`: WRI Aqueduct flood exposure estimates for various return periods for 2010 and 2030 30 | 10. `data\aqueduct_dictionary.xlsx`: data dictionary to explain columns in WRI Aqueduct flood exposure estimates 31 | 11. `data\gfd_popsummary.csv`: Global Flood Database population exposure estimates per country, in 2000 and 2015, and associated statistics. 32 | 12. `data\GFDabove_13_wBias.csv`: Global Flood Database population exposure estimates per country, in 2000 and 2015, with bias correction factor based on comparison to HRSL data. Note Montenegro and Serbia are treated as one country here (Yugoslavia), and Sudan/South Sudan are treated as one country (Sudan) as these country splits occured during the 2000-2015 period of analysis. 33 | 13. `data\popchange_Aque_GFD.csv`: selected 122 countries (represented in the Global Flood Database) of the 2030 estimates for flood exposure from WRI estimates used to report the absolute population for 2030 flood exposure, with population and climate components specifically. Note Montenegro and Serbia are reported seperately (instead of as Yugoslavia), and Sudan and South Sudan are reported seperately (instead of as Sudan). 34 | 14. `data\gfd_popdictionary.xlsx`: data dictionary to explain columns in Global Flood Database exposure estimates 35 | 15. **Population Exposed Per Event**: Population exposure estimate per event. To access click on the `INFO` button on our data portal at: http://global-flood-database.cloudtostreet.info/ 36 | 16. **Population Exposed Per Country Per Event**: Population exposure estimates per country by event. To access click on the `INFO` button on our data portal at: http://global-flood-database.cloudtostreet.info/ 37 | 38 | #### Pop Sensitivity & Uncertainty 39 | 15. `data\gfd_popsensitivity.csv`: Global Flood database population exposure estimates per country using the Global Human Settlement Layer (GHSL), High Resolution Settlement Layer (HRSL) and GridPop3. Countries are limited to those with HRSL data. 40 | 41 | #### Flood Mechanism 42 | 16. `data\gfd_floodmechanism.csv`: Global Flood database disaggregated by "flood type" (data from the Dartmouth Flood Observatory) and estimated population exposure estimate per in 2000 and 2015. 43 | 44 | 45 | ### Code 46 | Our code includes modules written in Python, Javascript and R. In the case of Javascript, this code is stored as a `.txt` file (`.js` files are prohibited as Gmail attachments) and can be run by "copy and pasting" into [Google Earth Engine's code editor](https://code.earthengine.google.com/). Python scripts are based on [Google Earth Engine's Python API](https://developers.google.com/earth-engine/guides/python_install) and require installation before running. Additional code in R require publicly available downloads of [R or RStudio](https://rstudio.com/). 47 | 48 | Below is a short description of scripts within our repository and how they relate to *Tellman et al, Satellite observations indicate increasing proportion of population exposed to floods* 49 | 50 | 51 | #### Flood Mapping 52 | 1. `main_gfd.py` - uses GEE Python API to create flood maps for each Dartmouth Flood Observatory flood event. This script relies on modules found in the `flood_detection` folder. The exports are stored in Google Cloud Storage which can be accessed as described above. 53 | 54 | 55 | #### Validation 56 | 2. `gee_sampleFrameLandsat.txt` - uses GEE Code Editor to determine what floods have available Landsat imagery coincident within 1-day of the max extent of a flood event. This code produces `data\sample_frame_CC20_D1_051618.csv`. 57 | 3. `gee_validationGUI.txt` - used GEE Code Editor to collect validation data using a custom tool designed in GEE that retrieves a flood event, coincident Landsat imagery and creates a statrified sample. An example of our validation GUI can be seen below in **Figure 1**. Analysts can then interpret sample points based on Landsat imagery and results are recorded. This code relies upon `gee_landsatTools.txt` and `gee_misc.txt` sub-modules. The outputs of assessment points by each analyst were stored in Google Cloud Storage and is compiled here `data\gfd_validation_points_2018_12_17.csv`. 58 | 4. `main_validation.pynb` - This script uses the accuracy assessment points (i.e. `data\gfd_validation_points_2018_12_17.csv`) to calculate various accuracy metrics including ommission and commission errors. The results are stored in `data\gfd_validation_metrics.csv`. This script also analyzes the validation sensitivity (Extended Data Fig 8). 59 | 60 | 61 | #### Exposed Population Estimates 62 | 5. `main_popstats.py` - uses GEE Python API to estimate exposed populations for each flood event and country. This script relies on modules found in the `flood_stats` folder. Outputs are available on our [data portal](http://global-flood-database.cloudtostreet.info/) by clicking on the `INFO` button. These population estimates do not filter out isolated pixels as described in the methods. 63 | 6. `main_popchange.txt` - uses GEE Code Editor to calculate population change in areas of observed inundation from GFD between years 2000 and 2015 for each country. This method removed isolated pixels for a conservative estimate of change. This script yields `data\gfd_popsummary.csv`. Additional fields in `data\gfd_popsummary.csv` are described in `data\gfd_popdictionary.xlsx`. 64 | 7. `ext.datafig10.R`- This script was used to make extended data figure 10, which compares the population exposed to at least one flood event between 2000-2018 from the Global Flood Database to floods in 2010 in the WRI Aqueduct flood exposure 100 year return period at the country scale. 65 | 8. `ext.datafig8.R` - This script was used to make extended data figure 8, which is a sensitivity analysis of the proportion of population exposed to floods under climate change and population growth across return periods. It shows boxplots for the distribution across countries, summarized by continent. 66 | 9. `main_gfdsummarystats.R`- This script was used to generate summary statistics from the Global Flood Database for the paper. 67 | 68 | 69 | #### Pop Sensitivity & Uncertainty 70 | 10. `main_popsensitivity.txt` - uses GEE Code Editor to calculate population exposure using the Global Human Settlement Layer (GHSL), High Resolution Settlement Layer (HRSL) and GridPop3. This method removed isolated pixels for a conservative estimate of change. This script yields per region files that are later compiled into `data\gfd_popsensitivity.csv`. 71 | 11. `main_sensitivityanalysis.R` - R script that compiles individual region files generated from `main_popsensitivity.txt` and then calculates a bias factor. This script additionally joins the bias factor to a number of datasets including `data\gfd_popsummary.csv` and `data\gfd_floodmechanism.csv` 72 | 12. `uncertaintyanalysis.R` - R script that estimates uncertainty in population trend estimates per country using the population dataset `data\GFDabove_13_wBias.csv`. It identifies countries we deem uncertainty and reproduces Figure 2 in the Supplementary discussion. This script recalcualtes the global flood exposure trend analysis removing the "uncertain" countries. 73 | 74 | 75 | 76 | #### Flood Mechanism 77 | 12. `main_floodmechanism.txt` - uses GEE Code Editor to disaggregate the Global Flood database into flood plains representing different causes/ drivers. Population exposure is calculated using the Global Human Settlement Layer (GHSL) for 2000 and 2015. This script yields per mechanism files that are later compiled into `data\gfd_floodmechanism.csv`. 78 | 79 | 80 | ![](assets/validation_gui.jpg) 81 | *Figure 1.* Example of the GFD Validaiton GUI 82 | -------------------------------------------------------------------------------- /assets/validation_gui.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudtostreet/MODIS_GlobalFloodDatabase/0d20b91d124b5a9987d40392b5e3463d78f1f894/assets/validation_gui.jpg -------------------------------------------------------------------------------- /data/SSP2010.csv: -------------------------------------------------------------------------------- 1 | system:index,country,sum,.geo 2 | 257,Russia,1.4104741925098044E8, 3 | 34,Canada,3.2227031564705867E7, 4 | 7,Antarctica,0.0, 5 | 86,Indonesia,2.0888438047450987E8, 6 | 39,China,1.317232832556863E9, 7 | 85,India,1.2023424138313725E9, 8 | 298,United States,2.901064078313727E8, 9 | 230,Mongolia,2770382.1450980357, 10 | 11,Australia,2.0932083525490217E7, 11 | 227,Mexico,1.1196975855294116E8, 12 | 26,Brazil,1.828857450156864E8, 13 | 38,Chile,1.652278916470588E7, 14 | 9,Argentina,3.855955589019619E7, 15 | 252,Portugal,9503518.262745101, 16 | 271,Spain,4.182344385490195E7, 17 | 222,Mali,1.5435102262745101E7, 18 | 225,Mauritania,3380549.1098039225, 19 | 4,Algeria,3.3795391250980444E7, 20 | 212,Libya,6033709.345098047, 21 | 276,Sudan,4.345201007843144E7, 22 | 37,Chad,1.1298291403921563E7, 23 | 58,Ethiopia,8.29549646941177E7, 24 | 100,Kenya,3.979372842352943E7, 25 | 308,Zaire,6.514214249411771E7, 26 | 6,Angola,1.891072194901961E7, 27 | 270,South Africa,4.891086812941178E7, 28 | 232,Mozambique,2.2594896145098023E7, 29 | 218,Madagascar,2.013806927450981E7, 30 | 233,Myanmar (Burma),4.665668460392159E7, 31 | 303,Vietnam,8.237749409411766E7, 32 | 220,Malaysia,2.6002192043137245E7, 33 | 269,Somalia,8914419.698039219, 34 | 261,Saudi Arabia,2.720037325882353E7, 35 | 245,Pakistan,1.75458217709804E8, 36 | 2,Afghanistan,3.1577531247058816E7, 37 | 87,Iran,7.355320250588234E7, 38 | 291,Turkey,7.016315770980385E7, 39 | 300,Uzbekistan,2.6687323137254905E7, 40 | 99,Kazakhstan,1.6319271556862753E7, 41 | 73,Greenland,13165.929411764704, 42 | 97,Japan,1.1575707480392146E8, 43 | 40,Colombia,4.5715917564705834E7, 44 | 52,Ecuador,1.3954882850980392E7, 45 | 249,Peru,2.81318705137255E7, 46 | 238,New Zealand,3498891.749019606, 47 | 59,Falkland Islands (Islas Malvinas),2309.5372549019608, 48 | 231,Morocco,3.04288334745098E7, 49 | 304,Western Sahara,356256.91372549016, 50 | 77,Guinea,9840828.72941177, 51 | 29,Burkina Faso,1.6458938337254906E7, 52 | 94,Ivory Coast,1.8864130164705876E7, 53 | 71,Ghana,2.3408069600000005E7, 54 | 241,Nigeria,1.560788831058822E8, 55 | 36,Central African Republic,4213705.623529413, 56 | 33,Cameroon,1.9403384027450968E7, 57 | 240,Niger,1.5626379200000003E7, 58 | 93,Italy,5.6188439756862774E7, 59 | 290,Tunisia,9693051.109803932, 60 | 53,Egypt,7.818728567058843E7, 61 | 98,Jordan,9006851.070588239, 62 | 282,Syria,2.0255754121568635E7, 63 | 88,Iraq,3.139511874901962E7, 64 | 56,Eritrea,5249263.168627447, 65 | 294,Uganda,3.3350328043137252E7, 66 | 285,"Tanzania, United Republic of",4.334701444705881E7, 67 | 219,Malawi,1.4733878486274509E7, 68 | 309,Zambia,1.3038198474509804E7, 69 | 42,Congo,4966491.517647059, 70 | 234,Namibia,2240774.0000000014, 71 | 25,Botswana,1955667.2666666666, 72 | 310,Zimbabwe,1.2524842717647063E7, 73 | 286,Thailand,6.72942195098039E7, 74 | 207,Laos,6322370.149019609, 75 | 250,Philippines,7.871355352156858E7, 76 | 204,"Korea, Republic of",4.472006719215685E7, 77 | 206,Kyrgyzstan,5584793.854901956, 78 | 284,Tajikistan,6990464.858823533, 79 | 235,Nepal,3.096878486274509E7, 80 | 221,Maldives,987.2156862745098, 81 | 306,Yemen,2.3379732768627446E7, 82 | 244,Oman,2690518.3764705923, 83 | 292,Turkmenistan,5218306.568627448, 84 | 295,Ukraine,4.4854925917647064E7, 85 | 243,Norway,3985414.521568628, 86 | 280,Sweden,8401374.239215687, 87 | 62,Finland,4977135.909803923, 88 | 251,Poland,3.804611425490196E7, 89 | 256,Romania,2.1253898227450978E7, 90 | 70,Germany,8.205155238431373E7, 91 | 63,France,6.039736168235293E7, 92 | 297,United Kingdom,5.673055167058826E7, 93 | 203,"Korea, Peoples Republic of",2.3184748894117635E7, 94 | 247,Papua New Guinea,6182767.815686272, 95 | 301,Vanuatu,152918.35294117648, 96 | 302,Venezuela,2.7589107968627445E7, 97 | 79,Guyana,719987.7647058829, 98 | 45,Cuba,1.017364888235294E7, 99 | 23,Bolivia,9938136.027450977, 100 | 248,Paraguay,6290375.082352941, 101 | 262,Senegal,1.072847400392158E7, 102 | 211,Liberia,3862257.7294117645, 103 | 287,Togo,5871213.27843137, 104 | 20,Benin,8242351.792156864, 105 | 55,Equatorial Guinea,620707.8470588234, 106 | 72,Greece,9337349.898039227, 107 | 92,Israel,6947771.533333331, 108 | 66,Gabon,1240931.8588235287, 109 | 32,Cambodia,1.4295398360784313E7, 110 | 283,Taiwan,2.0793124047058824E7, 111 | 16,Bangladesh,1.429885517882355E8, 112 | 22,Bhutan,1103622.262745098, 113 | 272,Sri Lanka,1.9476377768627454E7, 114 | 296,United Arab Emirates,7398094.627450982, 115 | 13,Azerbaijan,8432518.329411771, 116 | 69,Georgia,4283868.772549021, 117 | 10,Armenia,3109371.9254901963, 118 | 28,Bulgaria,7435017.941176467, 119 | 278,Svalbard,0.0, 120 | 31,Byelarus,9550061.909803916, 121 | 208,Latvia,2122734.419607843, 122 | 214,Lithuania,4144302.709803923, 123 | 307,Yugoslavia,1.038841094901961E7, 124 | 44,Croatia,3886808.3490196066, 125 | 266,Slovakia,5437932.823529411, 126 | 83,Hungary,9981073.768627454, 127 | 47,Czech Republic,1.0484030239215685E7, 128 | 12,Austria,8506216.431372544, 129 | 281,Switzerland,7406618.274509801, 130 | 48,Denmark,4606395.145098044, 131 | 18,Belgium,1.1016833290196074E7, 132 | 90,Ireland,5602034.541176469, 133 | 84,Iceland,267462.36470588244, 134 | 237,New Caledonia,168643.11764705883, 135 | 268,Solomon Islands,571742.1843137254, 136 | 14,"Bahamas, The",37645.38431372552, 137 | 64,French Guiana,198962.92941176475, 138 | 277,Suriname,471801.1882352943, 139 | 51,Dominican Republic,9293271.094117645, 140 | 76,Guatemala,1.428745283529412E7, 141 | 239,Nicaragua,5705422.125490197, 142 | 81,Honduras,7375085.035294117, 143 | 246,Panama,3360116.239215688, 144 | 299,Uruguay,3115917.5921568624, 145 | 35,Cape Verde,245614.67843137257, 146 | 78,Guinea-Bissau,1353127.6235294119, 147 | 67,"Gambia, The",1342667.8039215677, 148 | 264,Sierra Leone,5501452.058823531, 149 | 3,Albania,3105610.0078431377, 150 | 217,Macedonia,2086353.4980392167, 151 | 46,Cyprus,929899.7254901959, 152 | 209,Lebanon,3402953.94117647, 153 | 49,Djibouti,667709.1450980391, 154 | 41,Comoros,464787.25490196084, 155 | 30,Burundi,8421304.678431371, 156 | 258,Rwanda,1.0530163980392156E7, 157 | 210,Lesotho,2166344.0313725485, 158 | 89,Iraq-Saudi Arabia Neutral Zone,37465.925490196074, 159 | 205,Kuwait,2212566.7490196074, 160 | 228,Moldova,3548338.8196078427, 161 | 57,Estonia,1132830.2078431377, 162 | 24,Bosnia and Herzegovina,3752007.611764706, 163 | 267,Slovenia,2210045.211764706, 164 | 236,Netherlands,1.596875631372549E7, 165 | 61,Fiji,730864.4901960783, 166 | 288,Tonga,26631.32549019608, 167 | 80,Haiti,8665981.294117644, 168 | 95,Jamaica,2453357.094117647, 169 | 19,Belize,290244.99999999994, 170 | 54,El Salvador,6059302.615686276, 171 | 43,Costa Rica,4577585.18823529, 172 | 260,Sao Tome and Principe,115917.33725490197, 173 | 279,Swaziland,1190237.8588235294, 174 | 27,Brunei,307158.16078431363, 175 | 254,Qatar,1235899.803921569, 176 | 305,Western Samoa,108758.90980392158, 177 | 253,Puerto Rico,3227389.2588235284, 178 | 275,St. Vincent and the Grenadines,65459.78431372548, 179 | 289,Trinidad and Tobago,974034.0274509804, 180 | 201,Kerguelen,0.0, 181 | 68,Gaza Strip,703331.6470588236, 182 | 255,Reunion,687052.1137254903, 183 | 226,Mauritius,1011324.9607843136, 184 | 263,Seychelles,24143.913725490194, 185 | 82,Hong Kong,7103593.376470587, 186 | 15,Bahrain,546133.1411764706, 187 | 215,Luxembourg,479264.8941176471, 188 | 91,Isle of Man,59741.4156862745, 189 | 96,Jan Mayen,0.0, 190 | 65,French Polynesia,138792.23529411765, 191 | 8,Antigua and Barbuda,56435.19215686274, 192 | 75,Guadeloupe,248112.98823529412, 193 | 293,Turks and Caicos Islands,325.65098039215684, 194 | 5,Andorra,51289.42745098039, 195 | 223,Malta,173074.7568627451, 196 | 265,Singapore,2886406.8901960785, 197 | 60,Faroe Islands,21704.494117647057, 198 | 242,Northern Mariana Islands,98186.56470588237, 199 | 202,Kiribati,1708.9254901960783, 200 | 273,St. Christopher-Nevis,16041.403921568626, 201 | 74,Grenada,68684.35294117648, 202 | 274,St. Lucia,103814.23529411765, 203 | 17,Barbados,104437.09019607844, 204 | 224,Martinique,256908.29411764708, 205 | 50,Dominica,48495.47843137255, 206 | 259,San Marino,23345.466666666667, 207 | 216,Macau,258471.05882352943, 208 | 213,Liechtenstein,30598.14117647059, 209 | 21,Bermuda,5199.356862745098, 210 | 229,Monaco,4901.850980392157, 211 | -------------------------------------------------------------------------------- /data/SSP2030.csv: -------------------------------------------------------------------------------- 1 | system:index,country,sum,.geo 2 | 257,Russia,1.378756830705881E8, 3 | 34,Canada,3.926028603137255E7, 4 | 7,Antarctica,0.0, 5 | 86,Indonesia,2.4265966870588207E8, 6 | 39,China,1.355779679470589E9, 7 | 85,India,1.5029075288627458E9, 8 | 298,United States,3.3721787932549065E8, 9 | 230,Mongolia,3428817.6549019585, 10 | 11,Australia,2.7837833109803915E7, 11 | 227,Mexico,1.3503578076470605E8, 12 | 26,Brazil,2.0909141997647062E8, 13 | 38,Chile,1.901976080784314E7, 14 | 9,Argentina,4.405027313725492E7, 15 | 252,Portugal,9847952.886274504, 16 | 271,Spain,4.560191685098039E7, 17 | 222,Mali,2.587416370980392E7, 18 | 225,Mauritania,4938675.882352936, 19 | 4,Algeria,4.245515047058821E7, 20 | 212,Libya,7910555.537254916, 21 | 276,Sudan,6.439384762352946E7, 22 | 37,Chad,1.8328130313725498E7, 23 | 58,Ethiopia,1.2396795759607843E8, 24 | 100,Kenya,5.966222195294119E7, 25 | 308,Zaire,1.0623860289803924E8, 26 | 6,Angola,3.1573923380392145E7, 27 | 270,South Africa,5.716881342352948E7, 28 | 232,Mozambique,3.2819415701960772E7, 29 | 218,Madagascar,3.2379107356862757E7, 30 | 233,Myanmar (Burma),4.9736162588235304E7, 31 | 303,Vietnam,9.573220091764708E7, 32 | 220,Malaysia,3.4000304835294105E7, 33 | 269,Somalia,1.2657632482352937E7, 34 | 261,Saudi Arabia,4.155840791764703E7, 35 | 245,Pakistan,2.4091838756470603E8, 36 | 2,Afghanistan,5.177707990980394E7, 37 | 87,Iran,8.757621242745085E7, 38 | 291,Turkey,8.473800300000003E7, 39 | 300,Uzbekistan,3.1226522996078443E7, 40 | 99,Kazakhstan,1.9020862278431382E7, 41 | 73,Greenland,12707.400000000001, 42 | 97,Japan,1.1044092750196072E8, 43 | 40,Colombia,5.663321127843145E7, 44 | 52,Ecuador,1.734267621176472E7, 45 | 249,Peru,3.1942195909803934E7, 46 | 238,New Zealand,4242132.196078432, 47 | 59,Falkland Islands (Islas Malvinas),2309.5372549019608, 48 | 231,Morocco,3.494545064313725E7, 49 | 304,Western Sahara,410389.75686274515, 50 | 77,Guinea,1.3218406972549018E7, 51 | 29,Burkina Faso,2.724905331764707E7, 52 | 94,Ivory Coast,2.5172973529411767E7, 53 | 71,Ghana,3.454374575686276E7, 54 | 241,Nigeria,2.4935056763921583E8, 55 | 36,Central African Republic,5884154.55686275, 56 | 33,Cameroon,2.712973689019609E7, 57 | 240,Niger,2.992739287843135E7, 58 | 93,Italy,5.748649529019611E7, 59 | 290,Tunisia,1.1307584411764707E7, 60 | 53,Egypt,1.0302880082745123E8, 61 | 98,Jordan,1.3666052450980395E7, 62 | 282,Syria,2.7749663011764724E7, 63 | 88,Iraq,4.968862603529411E7, 64 | 56,Eritrea,8515127.11372549, 65 | 294,Uganda,5.9705292647058815E7, 66 | 285,"Tanzania, United Republic of",7.07195433764706E7, 67 | 219,Malawi,2.584731928235293E7, 68 | 309,Zambia,2.1284598968627438E7, 69 | 42,Congo,7345803.737254899, 70 | 234,Namibia,2907539.352941178, 71 | 25,Botswana,2360002.9529411756, 72 | 310,Zimbabwe,1.3312043949019609E7, 73 | 286,Thailand,7.31732553529412E7, 74 | 207,Laos,7870468.050980385, 75 | 250,Philippines,1.0614541260000013E8, 76 | 204,"Korea, Republic of",4.626286037254902E7, 77 | 206,Kyrgyzstan,6443686.97254902, 78 | 284,Tajikistan,8108570.113725488, 79 | 235,Nepal,4.2325707917647064E7, 80 | 221,Maldives,1439.827450980392, 81 | 306,Yemen,3.908251985882355E7, 82 | 244,Oman,3918536.2235294096, 83 | 292,Turkmenistan,6246003.701960784, 84 | 295,Ukraine,4.0530295156862795E7, 85 | 243,Norway,4912710.086274508, 86 | 280,Sweden,9839546.717647063, 87 | 62,Finland,5420934.447058826, 88 | 251,Poland,3.768659240784311E7, 89 | 256,Romania,1.9694591188235294E7, 90 | 70,Germany,8.125149898431374E7, 91 | 63,France,6.768259107058823E7, 92 | 297,United Kingdom,6.422593618039215E7, 93 | 203,"Korea, Peoples Republic of",2.4665501423529394E7, 94 | 247,Papua New Guinea,8590923.286274511, 95 | 301,Vanuatu,223440.83529411769, 96 | 302,Venezuela,3.522170131764703E7, 97 | 79,Guyana,745860.537254902, 98 | 45,Cuba,9687038.109803928, 99 | 23,Bolivia,1.2605577690196075E7, 100 | 248,Paraguay,8193091.905882354, 101 | 262,Senegal,1.6466498411764707E7, 102 | 211,Liberia,7292510.458823534, 103 | 287,Togo,8289545.211764705, 104 | 20,Benin,1.336834612156863E7, 105 | 55,Equatorial Guinea,972240.0352941178, 106 | 72,Greece,9374319.941176478, 107 | 92,Israel,1.023989887843137E7, 108 | 66,Gabon,1644249.243137255, 109 | 32,Cambodia,1.6825465207843136E7, 110 | 283,Taiwan,2.1082276031372543E7, 111 | 16,Bangladesh,1.7449792023921564E8, 112 | 22,Bhutan,1423828.733333333, 113 | 272,Sri Lanka,2.1908124654901948E7, 114 | 296,United Arab Emirates,1.3123988258823536E7, 115 | 13,Azerbaijan,9773686.796078442, 116 | 69,Georgia,3801005.647058823, 117 | 10,Armenia,2965753.1372549017, 118 | 28,Bulgaria,6709697.949019611, 119 | 278,Svalbard,0.0, 120 | 31,Byelarus,8870990.466666661, 121 | 208,Latvia,1899833.7647058824, 122 | 214,Lithuania,3863564.796078431, 123 | 307,Yugoslavia,1.029761165882353E7, 124 | 44,Croatia,3765538.3490196094, 125 | 266,Slovakia,5630542.929411767, 126 | 83,Hungary,9495682.023529414, 127 | 47,Czech Republic,1.125307587450981E7, 128 | 12,Austria,9052442.364705881, 129 | 281,Switzerland,8196137.078431373, 130 | 48,Denmark,5059346.741176468, 131 | 18,Belgium,1.2123515956862746E7, 132 | 90,Ireland,6744598.701960784, 133 | 84,Iceland,346129.14901960787, 134 | 237,New Caledonia,223846.91764705884, 135 | 268,Solomon Islands,828401.5294117648, 136 | 14,"Bahamas, The",44787.59607843136, 137 | 64,French Guiana,288301.0901960784, 138 | 277,Suriname,553889.8588235293, 139 | 51,Dominican Republic,1.1236669372549014E7, 140 | 76,Guatemala,2.020182259215686E7, 141 | 239,Nicaragua,6668935.976470588, 142 | 81,Honduras,9759306.22745098, 143 | 246,Panama,4280401.862745098, 144 | 299,Uruguay,3191838.3333333335, 145 | 35,Cape Verde,277853.662745098, 146 | 78,Guinea-Bissau,1892022.3450980394, 147 | 67,"Gambia, The",2046127.9294117645, 148 | 264,Sierra Leone,8252589.482352943, 149 | 3,Albania,3203584.0313725485, 150 | 217,Macedonia,2217177.1882352936, 151 | 46,Cyprus,1165979.0156862745, 152 | 209,Lebanon,3892899.537254904, 153 | 49,Djibouti,891919.6392156864, 154 | 41,Comoros,671408.862745098, 155 | 30,Burundi,1.319091233333333E7, 156 | 258,Rwanda,1.6657639584313728E7, 157 | 210,Lesotho,2513465.4784313724, 158 | 89,Iraq-Saudi Arabia Neutral Zone,59482.4705882353, 159 | 205,Kuwait,3555769.5215686266, 160 | 228,Moldova,2848514.0000000014, 161 | 57,Estonia,1091725.0196078436, 162 | 24,Bosnia and Herzegovina,3625311.231372549, 163 | 267,Slovenia,2309197.7098039207, 164 | 236,Netherlands,1.7184897035294123E7, 165 | 61,Fiji,820190.0431372549, 166 | 288,Tonga,29203.486274509803, 167 | 80,Haiti,1.031105461176471E7, 168 | 95,Jamaica,2582209.996078433, 169 | 19,Belize,378812.019607843, 170 | 54,El Salvador,6307482.647058821, 171 | 43,Costa Rica,5812854.501960781, 172 | 260,Sao Tome and Principe,139895.16470588237, 173 | 279,Swaziland,1425005.1803921566, 174 | 27,Brunei,406501.07058823545, 175 | 254,Qatar,2165596.733333333, 176 | 305,Western Samoa,110473.07843137255, 177 | 253,Puerto Rico,3008674.5607843134, 178 | 275,St. Vincent and the Grenadines,67554.32156862745, 179 | 289,Trinidad and Tobago,995245.7647058823, 180 | 201,Kerguelen,0.0, 181 | 68,Gaza Strip,950043.3137254902, 182 | 255,Reunion,826484.5960784314, 183 | 226,Mauritius,1118033.9098039216, 184 | 263,Seychelles,26069.733333333334, 185 | 82,Hong Kong,8297663.180392156, 186 | 15,Bahrain,1054718.6666666665, 187 | 215,Luxembourg,626004.850980392, 188 | 91,Isle of Man,67146.00392156863, 189 | 96,Jan Mayen,0.0, 190 | 65,French Polynesia,166947.75294117647, 191 | 8,Antigua and Barbuda,68411.67450980392, 192 | 75,Guadeloupe,271885.62352941174, 193 | 293,Turks and Caicos Islands,309.66274509803924, 194 | 5,Andorra,58125.290196078444, 195 | 223,Malta,188142.63921568624, 196 | 265,Singapore,3485528.42745098, 197 | 60,Faroe Islands,22642.54117647059, 198 | 242,Northern Mariana Islands,120078.46666666666, 199 | 202,Kiribati,2810.419607843137, 200 | 273,St. Christopher-Nevis,19446.450980392154, 201 | 74,Grenada,75160.32549019608, 202 | 274,St. Lucia,121122.04705882352, 203 | 17,Barbados,114215.33333333334, 204 | 224,Martinique,275169.168627451, 205 | 50,Dominica,52533.600000000006, 206 | 259,San Marino,24803.333333333332, 207 | 216,Macau,308672.0, 208 | 213,Liechtenstein,33889.01176470588, 209 | 21,Bermuda,5366.980392156863, 210 | 229,Monaco,5652.266666666666, 211 | -------------------------------------------------------------------------------- /data/aqueduct_dictionary.xlsx: -------------------------------------------------------------------------------- 1 | PK!A7��r[Content_Types].xml �(����n�0E�����Ub袪*�>�-�L<$�my 2 | �Ix�B<�M�؞{�u<�ֵMV�x��~� ��k��\|O?�g� )���r�����`� � W;�EE^�Ģ�Za�8���X+��Xʠ��*A>�zO����QJ���`�����5o�̌��v]�ʅ 3 | ��B�+�� ���M�˚�3 �� 4 | �j��h�'@��Pȓ��Aw�2�l�ae>p�3�f�|�]���h4$c�S՜]����q1�~�]��5�e�2n���]��}�ol��� 5 | _�A|�@���[he��6��i���ȕ��'ħ�����ڗ|pK���]��.�[��N A$�&9u�Dn������;E�>���6���PK!�U0#�L _rels/.rels �(����N�0 ��H�C���nH���LH�!T�$����$@����Jc�����?[���iTb/Nú(A�3b{�jx��V�b"gi��aW��l_x���b���������#b4O ��r��0Q�ahѓ�eܔ�=��P-<��j{�>�<���4Mox/�}b�N�@�;�v�Cf ��ۨ�B�I������"c�&�\O���8q"K��H��<ߊs@���.�h����<⧄�Md�a��T_��PK!�>����xl/_rels/workbook.xml.rels �(����J�0�����nӮ""��E��j}��L��m2㟾���ۅe���f���2���k�&��WP%�&��w 6 | ޚ����[=� 7 | &$���W�4�K��H"�xR��㣔d�����NҨ9��ɨ�Aw(7ey/���O�� 8 | ��ނh�����m�| 9 | �}D�g"$�4��F�Y��.2#����5�9��鳔�Y]b��d� �@��%�s�"�ݚ0�tB��)���[����ȓ�����PK!'�4Y+xl/workbook.xml���n�0 ����Q��m( -ҴM�2q`p��F�I������V�wrl'���Yo��&p^Y��dSFX��)�_���%>p#��2ځ����a�Zw���L`|F��UyQB����`�SXW���;E�v��/B�#�����Б�r�aآP^�h*0a�8�<���T����P�"����W��US��oR��aj[�RJ\S�4Jcw9��4�E�Aj�s��E�NQ"���{|��u�26��������Sr=*#m�Q����-K��R;��J�Q�"��}�:�!���Y�ӣ?��R3Db�R���:����-�¥�J��me2PnO�E�a��K�����PK!k���:xl/sharedStrings.xml�U�n1}���S*%��*�@D�DQ[ ��(O��p�kS{6�~}g!J[҈���9s�t��<��ښ^�ld ��Vi3�%w�㓳< �Da 10 | ��5�����M�{��KD�N�z��R��]�ᗙu� �u��/ 11 | ��Ti+�ާ��&i+C�$����Q�� h'����.���J\v* 12 | �*Q���� ��<��$B�u7�~7��[ 13 | �0�F���˚J�Mp5 14 | av��j�6���a�f��e(9��P*�M·x��eU���J��TNT)摛WFi)Ⱥ������H���R���Is/p�N����V���HVΡ�w����߶9���f¬��a$#� ��MC`�!p�h���%��9��RQ���+M ��#0�DvW��A ֜��� ��B��:U��[�� Jkl�%���CWB�b��-윋\�%�7Y�-�ْ,6��f�Ϥ\'��<��z����A��77������=��W�f�e�+�rY�i���Q��C/{��a���,b����g����C>,���,��0 rzZՋN\Bg6��'��G����C�G��Ai��c(�V��>>�|� Iǰ,�G��{�Z�+�7�nV�h��Q���� 15 | ����I��/G�땘�{�q�������S��p��AlEHmb�C��sBܻ!Լ���|�����PK!;m2K�B#xl/worksheets/_rels/sheet1.xml.rels�����0E��Cx{�օ CS7"�U�b��ۗ���{�e���p��6��<�f�,Ժ��ch��{�-�A�8�� -<�a�.��NNJ�ǐX ��Q$��~�ٱ� ��>��I�y0���Ь�jm�_�/N��,�}W�:=RY���}�H9�E���bA�w��k}�m���� ��PK!�b�m��xl/theme/theme1.xml�YOo�6��w tom'�u�ر��M�n�i��XS�@�I}���úa���0l+��t�&[����HJ��K��ՇD"|���#u�ڃ��C"$�q۫]�z��>�8h{w��K� 16 | �c�xL�ޜH�����]ś*$A�>�����J%����a��ACM��ʈ���J����&M�;��4B�e� t�Y�>c~4$��� 17 | &�^������ 18 | �L1�bma]���u���t���(gZ��[Wvr���2���u{���`�M�,E���F���,���2�n�Q�����%�[�N��Je�D 19 | �>֗��f}{����7����v��t�d��%|�J�Yw�2O��ڡ�~J=�L8�-�o|���(��<�4� �ժX��}.��@����'d�}��.�F�b�o\��C�\Ҽ��MT��0�� z�����S������ώ�t�����--g�.���—�~����?�~����xY����'���y92h!ы/����ɋ�>����%�m�GE��FD�[��t3�q%'#q��Sg�v �� 20 | ��9fe�q�wW@�(^��wd�b�h �a��8g.J 21 | pC�*Xx8��r�bV�`|Xƻ�cǵ�YU3 J��ݐ8b�3+��(�������Q��u���K>Q�ELKM2�#'��vi~��� �vl�wu8+�z��HH�J����:�)���� 22 | ~��L��\�E\O*�t@G�1��l�m��~C�*u��G.R(:-�ys^D��i7�QR��8,b?�SQ���*��q7C�;��+�}��ݧ�;4pDZ����_^'܉���M01UJ�S�#�]�f�����l��m��ʒg�D�^����<�� d����B����[_�W�����E)�*��k��;Z�xO(c5g��4��� 23 | h܇A��:I~KBxԙ \ �Y�WQB�@�^�4�@���.��h�Kik<��ʞ6�b+��j�����Ύ9#U`δ�uM���֯�DA��aV�B��[͈f���-WY�؜����j0�[:�X� �~��;������Q�ㅋt� ���>�z/��f���ʒ"Z ��x�� 24 | �Z��p;�����+�e�{/e��P;��,.&'��Q�k5��q��&pT��(�K�Lb�}��� 25 | �S��d�›�L17 jp�a����S!��� 26 | 27 | 3���5'+�Z�zQ 28 | �T��I�����Ivt]K&⫢� #�v�5-�|����#4b3q���:TA�1�p�a*�~��9mm3��4銗bg�1KB��[��Y&[�)H� �� �V*�Q������ U�a�?SE�'p�>���vX`�3��q�BU( ���8���W�0 29 | Aw��� ����9Kä5�$� 30 | ����P�e�D�)�j��eI�������2�b��!aC]�zo�P�n�IZ �d���i����ͩd��ks���|l2�Rn6 31 | Mf�\ļ=X��v�Y���EE�ĢͪgY� 32 | [A+M����[��XK�52�����`�%p�����������7�!?�ڊ���&aQ}�6HH;8����`Ҥ�i��I[-۬/�����0���,�>�����e���E;��ck;����ٓ) 33 | C�� cc��?f��}p�|6�1%M0��*����<����ҭ���PK!���4�p 34 | xl/styles.xml�V�n�0 }����q�� lH���@;`��-'Bu�$��7��Gَ��ڡ�����#�:$�WR�{f,�*Ɠq�S�θ�����ft��uTeTh�b\3�ϓ�"�j�n��9��x�\� Ħ{&���)�ɵ������- ����� a|"�r�[��L�"��+�Q�eA�r�]�`a$���NiC�\�&S����#x�S�������s���^�ɜR�Z9�R]*�@�wJ�P� 쬒��D�T�f�I�Zh�dk4�J�Z���[ýYN%u���Ifg'9������z�D[o�Nw� ������1�a��.���,��gP���$&;f���o������'o잰�ZO���i.�h�A���iڪ�H��A� 35 | �����~��9��$�8�iE��p� �� q����v�#Uʍt�Y���x�D�[�v���h-��\�XT�=� N#Z��5�U￰B�����<������5yE,ύ����Ԏ]���g�Q��St|@ƞV����I@��%���(G"fV�ݴ=��KC���"c9-���7c|�?�����Y]�{����jU��B��/* 36 | ������|}� Gg��l4=a��|�\�f��r��̃0X� ���f$C�M� +` �.�����.ƃŕo �h#�6��!b�� 37 | ���PK!R`��K�xl/worksheets/sheet1.xml�XM��8��4��>!��D!�Q�FӇ�Vۻ{w�IPf�����l���‡��~y�깪����^��+�m!��D�% x����O)�������U��Y)j��ޒo�O��ބ|iϜ��6%g��m�ٙW�]���🣐Sp+Oa�H�r��� �r�+V��2l�q<٥⵲$��LA���h�+[�͡��|�4�3Q5@q(�B}RT���T �%��%,�r��}UdR���@�@�9o�ML�]^@��@�cJ�G��$"�~g ���o��u��ᙗ��%P��)Y��W���2%?����Q�� ���W�f���AΏ�R�?��O^�� 38 | �W���b�<�6�5�]i�L�@�AU�b�{J���9%�E�,����Ю�|C�=�#Sl���-�j��a���m �)�$�.�� 39 | �@tXt�C�Y�d���f3�������.|��3��^VK���O��j���5�Y���A{����jpJ��:����U�=; 40 | N D��I�����`�V=�c�&��}�/>��uW=��#�=٨[h��<�q"���|^�� }�õ ݁|�!(�h�^�_���7=o'm; >�e�&Z,�F�H[��v4�2�8�L�Y��h=XLWE�Q�^ӣ���wv���,�d��rzudd��J�b��[s���%�n�H���t�P��.��w1��DVԫ9 41 | W uh��&�ȜB�-5h\Lԍ�N\3�c�ZO�՟=�s�4�s�{���}��V2u��en1Hܹ�Ž��o]$>���ĝ;X\w��6��?o����0&�zmR�VDY�,�9��d�^���q1%#K�A�Ne�5@�N�G#���'2���Ac��ee+�à�'�W ���d�q�U'��I&�W�5@ z ����Ǜ�dbz�^Ġ���eՉ�H21�b�b�q�U'n� ZsW���c��A��\��:��$v��{�y<�$39��a�ƻ�d"b8o{��A������)�a'�;���n��a��\�Ԕ�$m��h�S0� �k�wg���ñn���; 42 | ��7p�ּ�\]��a 43 | ��ſp���,�8n~ II#���P��-��ȧ����m����PK!/�>QdocProps/core.xml �(�|�QK�0���C�{��͡��@eO+�o!�ۂM�h�o�n��!�%���ݓK��^��8�S �R���Tf[��j��P�7�׍���ey}� �����k,���'�d|&l�v!،/v��O��Dq�8�C��-�\|�-�JDC��N: �#�R�H��� �4�� K��p�_l蕉S�p��MǸS��8��^�ƶm�v�Lj��X?��O��t���\�L8��qeN��������;�(���_�I�� � ➔���S�Be�CL�1[T�f���F��w���>���n1�a:�آ#�لx ��?A� ��PK!��cC�'xl/printerSettings/printerSettings1.binb�0�0�����������0�ۄ#��g�`b�L�@ґ��B{��3B9 � �A� � 44 | �)��PK!!�}B�docProps/app.xml �(���Ao�0 ��� �9]1 ���H[��a��gM�c��d���׏���Y{ڍ�{x�DI]�u���P��"K��x��_�� ��1@!z@q��~Q�[H�3�X���]I��������JSc�۴������h�$/����A(��h�Ŕ���C�h>|��-kuӶ�YC|K���1V��,x%��b�-ط��׹��Vm����`]���i�� K��P��VX�)C���v)��a�)Dg�3�k�M�X�)闘^� T� 45 | �p,��y���r4pqn&�w�<��jc}B��� ��S:;�Ҥ��xm>���ulZzޫG^����[Cp\��Pmk���W8꧁z�m&?��k�P=�������xl/_rels/workbook.xml.relsPK-!'�4Y+ xl/workbook.xmlPK-!k���:� 46 | xl/sharedStrings.xmlPK-!;m2K�B#p 47 | xl/worksheets/_rels/sheet1.xml.relsPK-!�b�m��rxl/theme/theme1.xmlPK-!���4�p 48 | 7xl/styles.xmlPK-!R`��K� 49 | xl/worksheets/sheet1.xmlPK-!/�>Q�docProps/core.xmlPK-!��cC�'xl/printerSettings/printerSettings1.binPK-!!�}B��docProps/app.xmlPK &L" 50 | -------------------------------------------------------------------------------- /data/gfd_popdictionary.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudtostreet/MODIS_GlobalFloodDatabase/0d20b91d124b5a9987d40392b5e3463d78f1f894/data/gfd_popdictionary.xlsx -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/gee_hrsl_countries.csv: -------------------------------------------------------------------------------- 1 | date,iso3 2 | 10/1/2018,abw 3 | 7/1/2019,ago 4 | 10/1/2018,aia 5 | 7/1/2019,alb 6 | 7/1/2019,are 7 | 10/1/2018,arg 8 | 10/1/2018,asm 9 | 10/1/2018,atg 10 | 10/1/2018,aus 11 | 7/1/2019,aut 12 | 7/1/2019,bdi 13 | 7/1/2019,bel 14 | 7/1/2019,ben 15 | 10/1/2018,bfa 16 | 10/1/2018,bgd 17 | 7/1/2019,bgr 18 | 7/1/2019,bhr 19 | 10/1/2018,bhs 20 | 7/1/2019,bih 21 | 7/1/2019,blr 22 | 10/1/2018,blz 23 | 10/1/2018,bol 24 | 10/1/2018,bra 25 | 10/1/2018,brb 26 | 10/1/2018,brn 27 | 10/1/2018,btn 28 | 7/1/2019,bwa 29 | 10/1/2018,caf 30 | 7/1/2019,che 31 | 10/1/2018,chl 32 | 7/1/2019,civ 33 | 7/1/2019,cmr 34 | 10/1/2018,cod 35 | 10/1/2018,cog 36 | 10/1/2018,cok 37 | 10/1/2018,col 38 | 10/1/2018,com 39 | 7/1/2019,cpv 40 | 10/1/2018,cri 41 | 10/1/2018,cym 42 | 7/1/2019,cze 43 | 7/1/2019,deu 44 | 7/1/2019,dji 45 | 10/1/2018,dma 46 | 10/1/2018,dom 47 | 10/1/2018,dza 48 | 10/1/2018,ecu 49 | 10/1/2018,egy 50 | 7/1/2019,eri 51 | 7/1/2019,esp 52 | 7/1/2019,est 53 | 10/1/2018,eth 54 | 10/1/2018,fji 55 | 7/1/2019,fra 56 | 10/1/2018,fsm 57 | 10/1/2018,gab 58 | 7/1/2019,gbr 59 | 7/1/2019,gha 60 | 10/1/2018,gin 61 | 10/1/2018,glp 62 | 7/1/2019,gmb 63 | 10/1/2018,gnb 64 | 10/1/2018,gnq 65 | 7/1/2019,grc 66 | 10/1/2018,grd 67 | 10/1/2018,gtm 68 | 10/1/2018,guf 69 | 10/1/2018,gum 70 | 10/1/2018,guy 71 | 10/1/2018,hkg 72 | 10/1/2018,hnd 73 | 7/1/2019,hrv 74 | 10/1/2018,hti 75 | 7/1/2019,hun 76 | 10/1/2018,idn 77 | 7/1/2019,irl 78 | 7/1/2019,irq 79 | 7/1/2019,isl 80 | 7/1/2019,ita 81 | 10/1/2018,jam 82 | 7/1/2019,jor 83 | 10/1/2018,jpn 84 | 10/1/2018,kaz 85 | 10/1/2018,ken 86 | 10/1/2018,kgz 87 | 10/1/2018,khm 88 | 10/1/2018,kir 89 | 10/1/2018,kna 90 | 10/1/2018,kor 91 | 7/1/2019,kwt 92 | 10/1/2018,lao 93 | 7/1/2019,lbn 94 | 10/1/2018,lbr 95 | 10/1/2018,lby 96 | 10/1/2018,lca 97 | 7/1/2019,lie 98 | 10/1/2018,lka 99 | 7/1/2019,lso 100 | 7/1/2019,ltu 101 | 7/1/2019,lva 102 | 10/1/2018,mac 103 | 7/1/2019,mco 104 | 7/1/2019,mda 105 | 10/1/2018,mdg 106 | 10/1/2018,mdv 107 | 10/1/2018,mex 108 | 10/1/2018,mhl 109 | 7/1/2019,mkd 110 | 10/1/2018,mli 111 | 7/1/2019,mlt 112 | 10/1/2018,mng 113 | 10/1/2018,mnp 114 | 7/1/2019,moz 115 | 10/1/2018,mrt 116 | 10/1/2018,msr 117 | 10/1/2018,mus 118 | 10/1/2018,mwi 119 | 10/1/2018,mys 120 | 7/1/2019,myt 121 | 7/1/2019,nam 122 | 10/1/2018,ncl 123 | 10/1/2018,ner 124 | 10/1/2018,nga 125 | 10/1/2018,nic 126 | 7/1/2019,nld 127 | 10/1/2018,npl 128 | 10/1/2018,nru 129 | 10/1/2018,nzl 130 | 7/1/2019,omn 131 | 10/1/2018,pan 132 | 10/1/2018,per 133 | 10/1/2018,phl 134 | 10/1/2018,plw 135 | 10/1/2018,png 136 | 7/1/2019,pol 137 | 10/1/2018,pri 138 | 7/1/2019,prt 139 | 10/1/2018,pry 140 | 10/1/2018,pyf 141 | 7/1/2019,qat 142 | 10/1/2018,reu 143 | 7/1/2019,rou 144 | 10/1/2018,rwa 145 | 7/1/2019,sau 146 | 10/1/2018,sen 147 | 10/1/2018,sgp 148 | 10/1/2018,slb 149 | 7/1/2019,sle 150 | 10/1/2018,slv 151 | 7/1/2019,smr 152 | 7/1/2019,srb 153 | 7/1/2019,stp 154 | 10/1/2018,sur 155 | 7/1/2019,svk 156 | 7/1/2019,svn 157 | 7/1/2019,swz 158 | 10/1/2018,syc 159 | 10/1/2018,tca 160 | 10/1/2018,tcd 161 | 7/1/2019,tgo 162 | 10/1/2018,tha 163 | 10/1/2018,tjk 164 | 10/1/2018,tkm 165 | 10/1/2018,tls 166 | 10/1/2018,ton 167 | 10/1/2018,tto 168 | 10/1/2018,tun 169 | 10/1/2018,tuv 170 | 10/1/2018,twn 171 | 10/1/2018,tza 172 | 7/1/2019,uga 173 | 10/1/2018,ury 174 | 7/1/2019,usa 175 | 10/1/2018,uzb 176 | 10/1/2018,vct 177 | 10/1/2018,vgb 178 | 10/1/2018,vir 179 | 10/1/2018,vnm 180 | 10/1/2018,vut 181 | 10/1/2018,wlf 182 | 10/1/2018,wsm 183 | 7/1/2019,zaf 184 | 7/1/2019,zmb 185 | 7/1/2019,zwe 186 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_africa_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | ,Chad,CD,131718.7893,226407.5907,122855.533,0,0,0,146376.7063,14810.54345,26769.8448,,Africa, 3 | Mal.,Malawi,MI,29272.8339,20181.94354,25105.91498,13.87614194,0,0,11040.34102,3152.798921,2422.512531,,Africa, 4 | Zam.,Zambia,ZA,95179.47317,101865.2776,8174.261369,118179.1611,2474.914388,3928.681919,103244.8476,3119.289192,8313.054034,,Africa, 5 | Zimb.,Zimbabwe,ZI,16312.7384,68046.22438,16193.26375,27.18653399,0,0,13075.1559,1218.493715,20834.76235,,Africa, 6 | Bots.,Botswana,BC,2605.908604,4427.453527,0,0,0,0,850.6839497,0,0,,Africa, 7 | Nam.,Namibia,WA,16694.05063,1603.323093,0,0,0,0,17106.13973,2475.123618,0,,Africa, 8 | Ang.,Angola,AO,31556.55438,7131.522899,5614.245573,13.47889996,0,0,16030.10353,8412.810724,10381.54681,,Africa, 9 | Buru.,Burundi,BY,1137.919735,1155.976198,92.40636587,0,0,0,4252.135698,845.8944433,0,,Africa, 10 | Rw.,Rwanda,RW,179.4021716,3618.917369,0,0,0,0,830.6606533,117.3877265,0,,Africa, 11 | S. Afr.,South Africa,SF,18328.66055,7608.664767,92473.5769,0,0,0,17560.40469,10540.06401,160069.7339,,Africa, 12 | Leso.,Lesotho,LT,531.2649689,0,0,0,0,0,44.76580005,0,0,,Africa, 13 | Swaz.,Swaziland,WZ,114.1094027,1308.122071,0,0,0,0,18.91610518,0,0,,Africa, 14 | May.,Mayotte,MF,0,0,0,0,0,0,0,0,0,,Africa, 15 | ,Niger,NG,6181.737632,7646.629462,915.7173389,0,0,0,2473.147206,483.1092805,183.3983216,,Africa, 16 | ,Sudan,SU,35662.59008,130707.7338,139080.2711,0,0,0,27.74323776,0,0,,Africa, 17 | ,Libya,LY,0,0,0,0,0,0,0,0,0,,Africa, 18 | ,Koualou Area,UU,0,0,0,0,0,0,0,0,0,,Africa, 19 | Tun.,Tunisia,TS,8374.355209,10648.47616,4997.353101,0,0,0,2541.857998,2263.227998,2001.046328,,Africa, 20 | ,Egypt,EG,25910.95345,79580.70772,133715.4057,0,0,0,112407.6264,36755.1036,96627.62416,,Africa, 21 | ,Bir Tawil,EG,0,0,0,0,0,0,0,0,0,,Africa, 22 | ,Halaib Triangle,SU,0,0,0,0,0,0,68.44027563,0,0,,Africa, 23 | Erit.,Eritrea,ER,874.3066853,374.3112427,796.8261001,0,0,0,3278.154739,1945.710997,349.826133,,Africa, 24 | Eth.,Ethiopia,ET,43806.21301,191915.5088,225143.393,0,0,0,31796.14329,2651.600147,3878.776401,,Africa, 25 | Dji.,Djibouti,DJ,454.4603203,3567.381138,16685.83101,0,0,0,2490.072201,90.36311519,5903.95056,,Africa, 26 | Som.,Somalia,SO,57131.24234,221472.3849,5547.353391,0,0,0,0,0,0,,Africa, 27 | S. Sudan,South Sudan,OD,18232.32864,54232.0724,126351.0948,42117.84544,1465.857122,4462.333126,591.2467593,0,0,,Africa, 28 | ,Abyei Area,UU,0,0,0,0,0,0,0,0,0,,Africa, 29 | ,Kenya,KE,67677.64507,67758.77517,11211.09781,155.6358376,0,0,36711.59295,9275.309887,14885.67704,,Africa, 30 | Ug.,Uganda,UG,12630.48948,41688.84452,1821.375664,0,0,0,16795.95852,4541.937574,1473.399342,,Africa, 31 | Tanz.,Tanzania,TZ,139684.8018,179275.8954,59084.25201,0,0,0,56578.29442,8919.179601,81490.27075,,Africa, 32 | Moz.,Mozambique,MZ,131889.9309,172369.6786,70432.36077,68091.37385,5964.107981,14706.9771,82176.28918,10196.18202,24253.00144,,Africa, 33 | Como.,Comoros,CN,0,0,0,0,0,0,0,0,0,,Africa, 34 | Madag.,Madagascar,MA,84114.5676,224053.6307,280901.712,0,0,0,77624.64424,10642.60841,90817.16971,,Africa, 35 | C. Ver.,Cabo Verde,CV,0,0,0,0,0,0,0,0,0,,Africa, 36 | W. Sah.,Western Sahara,WI,79.5582073,0,0,0,0,0,313.3240543,0,0,,Africa, 37 | Maur.,Mauritania,MR,2291.090027,22506.11098,17.23035812,0,0,0,2117.117549,214.9783306,0,,Africa, 38 | Mor.,Morocco,MO,21276.68466,35700.06877,13219.94633,0,0,0,0,0,0,,Africa, 39 | Sp.,Spain (Canary Is),SP,738.0095594,4400.463626,6340.859046,0,0,0,1894.120789,2745.707991,3979.776881,,Africa, 40 | Port.,Portugal (Madeira Is),PO,0.007938223,0,0,0,0,0,2.61439379,0,0,,Africa, 41 | Sp.,Spain (Africa),SP,0,639.6409165,752.1567909,0,0,0,0,347.6605313,433.9626363,,Africa, 42 | Alg.,Algeria,AG,11174.48146,73932.51796,91904.91291,0,0,0,4139.834716,10403.90386,94702.05084,,Africa, 43 | ,Mali,ML,39007.88155,72471.7734,19746.81197,0,0,0,63102.51282,7469.158715,6389.333812,,Africa, 44 | Burk.,Burkina Faso,UV,24671.14017,31965.65456,4192.6786,0,0,0,2907.952085,351.1629493,0,,Africa, 45 | ,Togo,TO,24464.85128,58769.25834,9364.88118,0,0,0,3611.666533,305.2013062,5544.63859,,Africa, 46 | ,Ghana,GH,179403.6057,396162.4414,44878.40207,37494.67787,25425.92556,20939.19683,66973.34838,18059.91823,13247.4331,,Africa, 47 | C. d Iv.,Cote d'Ivoire,IV,10911.87497,3200.176975,1885.670055,0,0,0,2578.831678,1234.869654,1640.827089,,Africa, 48 | Gui.,Guinea,GV,31182.29576,54904.18801,14848.35191,0,26.59132123,0,8784.209909,4804.623126,961.498463,,Africa, 49 | Sen.,Senegal,SG,23561.20476,75798.24746,50779.53868,0,0,0,8340.305169,5344.942881,9696.823524,,Africa, 50 | Gam.,"Gambia, The",GA,5164.685977,5127.1812,994.8286888,0,0,0,927.9232138,3333.011376,489.1927814,,Africa, 51 | Gui.-Bis.,Guinea-Bissau,PU,10807.59817,12133.39927,0,0,0,0,150.7377379,0,0,,Africa, 52 | S. Leo.,Sierra Leone,SL,30377.31936,36798.77132,5605.999208,35112.44543,7278.133962,3963.016368,31675.86882,8072.120676,12032.5915,,Africa, 53 | Liber.,Liberia,LI,2199.253802,356.0422852,8137.126509,0,0,0,1667.687146,0,3581.338572,,Africa, 54 | ,Benin,BN,21168.59617,84386.92464,45494.34378,0,0,0,13085.60797,37553.99803,9001.111482,,Africa, 55 | Nig.,Nigeria,NI,501911.4839,1837001.952,488704.5048,179698.4618,60411.02928,11690.32651,222591.2675,83834.9215,28479.75612,,Africa, 56 | Camer.,Cameroon,CM,73559.0801,80541.8805,111053.525,1.51730001,0,0,50051.87841,5110.833844,785.1715795,,Africa, 57 | Equa. Gui.,Equatorial Guinea,EK,0,0,0,0,0,0,0,0,0,,Africa, 58 | S. To. & Prin.,Sao Tome & Principe,TP,0,0,0,0,0,0,0,0,0,,Africa, 59 | ,Gabon,GB,0,0,0,0,0,0,0,0,0,,Africa, 60 | Rep. of the Congo,Rep of the Congo,CF,1610.608672,802.4855356,20579.17948,0,0,0,942.5030461,1232.503983,616.2519917,,Africa, 61 | Cen. Afr. Rep.,Central African Rep,CT,6605.081689,1336.511391,85859.5847,0,0,0,1544.722257,111.5481684,27.74323776,,Africa, 62 | Dem. Rep. of the Congo,Dem Rep of the Congo,CG,49658.18291,38920.69645,32246.49022,34268.71405,6888.634317,37.02526665,46850.59744,8596.683352,9682.609653,,Africa, 63 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_australia_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Austl.,Australia,AS,22245.30955,16249.59196,71770.87533,0,0,0,13477.93837,16408.37054,74156.07781,,Australia, 3 | Coral Sea Is.,Coral Sea Is,CR,0,0,0,0,0,0,0,0,0,,Australia, 4 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_canada_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Can.,Canada,CA,22939.21914,17937.96432,124412.5215,0,0,0,6.381439035,0,0,,North America, 3 | Can.,Canada,CA,0,0,0,0,0,0,0,0,0,,North America, 4 | Can.,Canada,CA,72847.36366,5137.072229,16474.45057,0,0,0,0.409527623,0,0,,North America, 5 | Can.,Canada,CA,0,0,0,0,0,0,0,0,0,,North America, 6 | Can.,Canada,CA,0,0,0,0,0,0,0,0,0,,North America, 7 | Can.,Canada,CA,0,0,0,0,0,0,0,0,0,,North America, 8 | Can.,Canada,CA,39.96120693,0,0,0,0,0,0,0,0,,North America, 9 | Can.,Canada,CA,92.53199109,0,0,0,0,0,0,0,0,,North America, 10 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_caribbean_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | ,Cuba,CU,24735.18439,34817.36771,2940.691725,0,0,0,0,0,0,,Caribbean, 3 | P.R.,Puerto Rico,RQ,188.3017076,2624.79111,2801.031398,0,0,0,240.335953,2115.89174,2817.876728,,Caribbean, 4 | Vir. Is.,US Virgin Is,VQ,4.62446022,0.09338389,0,0,0,0,0,84.0913037,0,,Caribbean, 5 | Br. Vir. Is.,British Virgin Is,VI,0,0,0,0,0,0,0,0,0,,Caribbean, 6 | Anti. & Barb.,Antigua & Barbuda,AC,469.549386,2.13644433,0,0,0,0,64.75038312,10.13876848,0,,Caribbean, 7 | St. Barth.,St Barthelemy,TB,0,0,0,0,0,0,0,0,0,,Caribbean, 8 | Neth.,Netherlands (Caribbean),NL,0,0,0,0,0,0,0,0,0,,Caribbean, 9 | Angu.,Anguilla,AV,0,0,0,0,0,0,0,0,0,,Caribbean, 10 | St. Mar.,St Martin,RN,0,0,0,0,0,0,0,0,0,,Caribbean, 11 | St. Maar.,Sint Maarten,NN,0,0,0,0,0,0,0,0,0,,Caribbean, 12 | St. Kitts & Nev.,St Kitts & Nevis,SC,0,0,0,0,0,0,0,0,0,,Caribbean, 13 | Monts.,Montserrat,MH,0,0,0,0,0,0,0,0,0,,Caribbean, 14 | Guad.,Guadeloupe,GP,192.4065208,1048.346772,0,0,0,0,227.3758798,962.4190571,0,,Caribbean, 15 | Dom.,Dominica,DO,0,895.661705,0,0,0,0,0,177.9548675,0,,Caribbean, 16 | Trin. & Tob.,Trinidad & Tobago,TD,0,0,0,0,0,0,0,0,0,,Caribbean, 17 | Gren.,Grenada,GJ,0,0,0,0,0,0,0,0,0,,Caribbean, 18 | Mart.,Martinique,MB,0,0,0,0,0,0,0,0,0,,Caribbean, 19 | St. Luc.,Saint Lucia,ST,0,0,0,0,0,0,0,0,0,,Caribbean, 20 | St. Vin. & Gren.,St Vincent & the Grenadines,VC,0,0,0,0,0,0,0,0,0,,Caribbean, 21 | Barb.,Barbados,BB,0,0,0,0,0,0,0,0,0,,Caribbean, 22 | Cur.,Curacao,UC,0,0,0,0,0,0,0,0,0,,Caribbean, 23 | ,Aruba,AA,0,0,0,0,0,0,0,0,0,,Caribbean, 24 | Dom. Rep.,Dominican Republic,DR,19969.36029,11901.53825,26179.57213,0,0,0,6390.388175,2028.512253,21099.8195,,Caribbean, 25 | ,Haiti,HA,10493.6478,39584.80637,50784.02412,0,0,0,1780.410733,2824.52291,39032.64583,,Caribbean, 26 | Jam.,Jamaica,JM,883.8198321,2345.594765,2548.892403,0,0,0,188.014518,315.7591464,0,,Caribbean, 27 | Nav. I.,Navassa I,BQ,0,0,0,0,0,0,0,0,0,,Caribbean, 28 | ,Cuba,CU,106.7024448,0,0,0,0,0,0,0,0,,Caribbean, 29 | Cay. Is.,Cayman Is,CJ,75.53510715,797.2664648,0,0,0,0,984.6500874,667.9684296,0,,Caribbean, 30 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_centralamerica_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | El Sal.,El Salvador,ES,3630.054713,4848.372311,0,0,0,0,1589.891685,592.1294939,0,,Central America, 3 | Guat.,Guatemala,GT,11204.81583,65071.56004,2740.391859,0,0,0,4689.922047,2664.316102,1727.624389,,Central America, 4 | Pan.,Panama,PM,5857.220527,475.3535867,0,0,0,0,2229.44828,1152.286382,2351.126765,,Central America, 5 | C.R.,Costa Rica,CS,2849.537669,0,0,0,0,0,628.9632204,0,0,,Central America, 6 | Nic.,Nicaragua,NU,26675.14152,24747.72716,0,0,0,0,4661.351109,1739.479102,0,,Central America, 7 | Hond.,Honduras,HO,9528.295462,2552.429838,13.31714153,0,0,0,5715.345403,1436.102204,0,,Central America, 8 | Belz.,Belize,BH,9444.114378,746.0607769,167.8571719,0,0,0,2532.909557,292.0406919,157.0515537,,Central America, 9 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_centralasia_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Turkm.,Turkmenistan,TX,3886.28264,2231.476378,0,0,0,0,13743.54643,990.5613698,2.218952118,,Central Asia, 3 | Kyr.,Kyrgyzstan,KG,983.1962509,10329.81803,2065.082376,0,0,0,4733.867444,5603.870364,1960.284234,,Central Asia, 4 | Kaz.,Kazakhstan,KZ,149030.7704,311071.3951,209622.033,0,0,0,205834.9302,130676.6242,77328.11887,,Central Asia, 5 | Taj.,Tajikistan,TI,2237.560964,14036.50998,2148.266703,0,0,0,4165.36418,2200.805818,1869.275266,,Central Asia, 6 | Uzb.,Uzbekistan,UZ,18094.33703,13088.20417,12425.41866,0,0,0,17296.70133,11914.67906,4647.56133,,Central Asia, 7 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_easia_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | H.K.,Hong Kong,HK,1642.095519,10845.04937,972617.0062,0,0,0,2088.239618,8380.814068,1042258.219,,E Asia, 3 | ,Macau,MC,0,0,278883.5889,0,0,0,0,0,268975.525,,E Asia, 4 | Tai.,Taiwan,TW,36585.25012,35134.59352,14016.25475,0,0,0,58028.27807,31903.92602,13790.12967,,E Asia, 5 | ,Senkakus,UU,0,0,0,0,0,0,0,0,0,,E Asia, 6 | ,Japan,JA,19772.42061,64450.01984,260115.2871,0,0,0,13114.51726,30049.01795,223007.2873,,E Asia, 7 | S. Kor.,"Korea, South",KS,8885.087796,39824.33089,227229.0891,0,0,0,8681.014096,14319.86254,200753.6264,,E Asia, 8 | N. Kor.,"Korea, North",KN,25228.62109,90538.66255,375754.5334,0,0,0,0,0,0,,E Asia, 9 | ,Korean Is. (UN Jurisdiction),UU,0,0,0,0,0,0,0,0,0,,E Asia, 10 | ,China,CH,1512443.387,2065321.453,2977173.615,0,0,0,0,0,0,,E Asia, 11 | ,China,CH,38407.1542,16301.07943,55900.99977,0,0,0,1.180200721,0,0,,E Asia, 12 | ,China,CH,259543.1112,2661327.532,8991219.031,0,0,0,13.86557403,0,0,,E Asia, 13 | ,China,CH,1988237.515,1.13E+07,2.07E+07,0,0,0,703.3357349,15.3657076,3970.937692,,E Asia, 14 | ,Liancourt Rocks,UU,0,0,0,0,0,0,0,0,0,,E Asia, 15 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_europe_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Rus.,Russia,RS,387448.7915,704828.1312,1421615.317,0,0,0,176.7863213,0,0,,Europe, 3 | Ukr.,Ukraine,UP,233042.5299,252502.2358,464275.0916,0,0,0,79.42055556,404.4002918,0,,Europe, 4 | Rom.,Romania,RO,59240.68884,61823.59261,63070.28997,0,0,0,31813.52056,43655.60059,53750.52403,,Europe, 5 | Mol.,Moldova,MD,5948.662222,3329.387317,4208.16816,0,0,0,4796.701315,2846.238351,2213.97465,,Europe, 6 | Rus.,Russia,RS,76903.7466,109235.2293,335826.5314,0,0,0,0,0,0,,Europe, 7 | Fin.,Finland,FI,15453.00757,38469.64827,9910.609309,0,0,0,0,0,0,,Europe, 8 | Nor.,Norway,NO,0,0,0,0,0,0,0,0,0,,Europe, 9 | And.,Andorra,AN,0,5975.248413,0,0,0,0,0,0,0,,Europe, 10 | ,Italy,IT,86872.54463,123037.4346,91739.88788,0,0,0,51519.97174,110444.8849,124040.6032,,Europe, 11 | Mon.,Monaco,MN,0,0,0,0,0,0,0,0,0,,Europe, 12 | ,Malta,MT,0,0,0,0,0,0,0,0,0,,Europe, 13 | S. Mar.,San Marino,SM,0,0,0,0,0,0,0.323155079,0,0,,Europe, 14 | Vat. C.,Vatican City,VT,0,0,0,0,0,0,0,0,0,,Europe, 15 | Cro.,Croatia,HR,17779.2926,7737.712378,7.040507404,0,0,0,14920.14128,6147.60112,221.9986847,,Europe, 16 | Alb.,Albania,AL,30023.87452,26497.4708,20966.63765,0,0,0,16005.85562,11503.11219,18762.69368,,Europe, 17 | Bos. & Her.,Bosnia & Herzegovina,BK,15330.86467,21564.47854,8360.894243,0,0,0,12700.62883,5189.646224,3936.724803,,Europe, 18 | Mont.,Montenegro,MJ,1981.085453,2865.478476,2012.090881,0,0,0,15.00874016,62.37933821,0,,Europe, 19 | Ser.,Serbia,RI,15192.4674,4974.038566,31869.95835,0,0,0,11077.58115,1519.918981,8105.883678,,Europe, 20 | Gr.,Greece,GR,51359.43038,38298.64264,66508.98295,0,0,0,39804.83528,33656.68488,65882.67915,,Europe, 21 | Mace.,Macedonia,MK,10083.52799,13100.48874,15166.13685,0,0,0,12463.96695,5851.218298,9207.594637,,Europe, 22 | Kos.,Kosovo,KV,1895.707958,5366.970339,3644.413183,0,0,0,0,0,0,,Europe, 23 | Bulg.,Bulgaria,BU,24884.79359,41935.42805,45706.33132,0,0,0,25364.60013,21296.22897,35874.0164,,Europe, 24 | Port.,Portugal (Azores),PO,0,0,0,0,0,0,0,0,0,,Europe, 25 | Port.,Portugal,PO,1285.636259,1997.388422,15414.56405,0,0,0,1310.469997,1884.440596,17786.12947,,Europe, 26 | Gibr.,Gibraltar,GI,0,0,1054.60498,0,0,0,0,0,0,,Europe, 27 | Sp.,Spain,SP,57064.82843,64914.43243,76471.66136,0,0,0,45271.55233,47520.94505,63548.80922,,Europe, 28 | Fr.,France,FR,138850.491,97275.57777,511533.5317,0,0,0,66676.32242,75333.87276,540397.9015,,Europe, 29 | Sval.,Svalbard,SV,0,0,0,0,0,0,0,0,0,,Europe, 30 | Swe.,Sweden,SW,0,0,0,0,0,0,0,0,0,,Europe, 31 | Den.,Denmark,DA,1928.472313,3538.172899,23150.67069,0,0,0,0,0,0,,Europe, 32 | Est.,Estonia,EN,10899.11906,5228.306011,7269.113109,0,0,0,10330.50846,3945.845151,8441.956314,,Europe, 33 | Lat.,Latvia,LG,10498.26686,8667.091746,14017.16147,0,0,0,16916.55292,4961.647092,12322.62327,,Europe, 34 | Lith.,Lithuania,LH,1456.944475,1787.104534,2953.804863,0,0,0,5198.015458,713.2685441,1819.216822,,Europe, 35 | Bela.,Belarus,BO,18686.87193,50228.15279,82966.72499,0,0,0,64977.78832,27780.64289,58275.59684,,Europe, 36 | Pol.,Poland,PL,171993.4521,243828.2912,247339.0177,0,0,0,154992.8301,175861.0586,218346.5251,,Europe, 37 | Ger.,Germany,GM,77460.00868,94710.54288,234934.6209,0,0,0,58277.27923,81681.24509,235171.3522,,Europe, 38 | Czech.,Czechia,EZ,18330.50304,34243.93114,16582.0241,0,0,0,15656.30054,22678.90652,10524.15814,,Europe, 39 | Slov.,Slovakia,LO,24906.29832,21447.09712,9845.06653,0,0,0,11696.55749,16045.46497,9639.838473,,Europe, 40 | Hung.,Hungary,HU,26524.58373,14454.31636,31867.35347,0,0,0,15626.94166,8869.740313,34662.00165,,Europe, 41 | Slo.,Slovenia,SI,3891.670734,3617.225918,274.8295593,0,0,0,3463.035847,3357.47605,197.9504635,,Europe, 42 | Aus.,Austria,AU,15881.74972,19531.02846,7031.875622,0,0,0,12303.40181,16144.93981,8987.87814,,Europe, 43 | ,Dragonja River Mouth,UU,9.897354706,0,0,0,0,0,0,0,0,,Europe, 44 | Switz.,Switzerland,SZ,16847.01019,51269.72398,18676.59531,0,0,0,15444.73912,48125.02674,18178.89237,,Europe, 45 | Liech.,Liechtenstein,LS,0,0,0,0,0,0,0,0,0,,Europe, 46 | Lux.,Luxembourg,LU,0,0,0,0,0,0,0,0,0,,Europe, 47 | Neth.,Netherlands,NL,19327.15521,47277.21065,263578.8968,0,0,0,13971.90874,41422.1885,296494.9931,,Europe, 48 | Bel.,Belgium,BE,4010.641838,17960.06096,22742.98213,0,0,0,2386.411718,15237.94566,17832.99484,,Europe, 49 | U.K.,United Kingdom,UK,1094297.885,3484884.886,1.13E+07,0,0,0,1059964.641,3459081.173,1.12E+07,,Europe, 50 | Jer.,Jersey,JE,0,0,0,0,0,0,0,0,0,,Europe, 51 | Guern.,Guernsey,GK,0,62.61338425,0,0,0,0,0,0,0,,Europe, 52 | Ire.,Ireland,EI,188991.4272,194472.3937,396814.7674,0,0,0,177548.6482,189949.5742,399145.8927,,Europe, 53 | I. of Man,Isle of Man,IM,4617.99007,22992.76316,0,0,0,0,0,0,0,,Europe, 54 | Faroe Is.,Faroe Is,FO,0,0,0,0,0,0,0,0,0,,Europe, 55 | Ice.,Iceland,IC,0,0,0,0,0,0,0,0,0,,Europe, 56 | J. May.,Jan Mayen,JN,0,0,0,0,0,0,0,0,0,,Europe, 57 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_indianocean_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Fr. S. & Ant. Lands,French S & Antarctic Lands,FS,0,0,0,0,0,0,0,0,0,,Indian Ocean, 3 | Reu.,Reunion,RE,0,0,0,0,0,0,0,0,0,,Indian Ocean, 4 | Mauris.,Mauritius,MP,0,0,0,0,0,0,0,0,0,,Indian Ocean, 5 | Sey.,Seychelles,SE,0,0,0,0,0,0,0,0,0,,Indian Ocean, 6 | Br. Ind. Oc. Terr.,British Indian Ocean Terr,IO,0,0,0,0,0,0,0,0,0,,Indian Ocean, 7 | He. I. & McD. Is.,Heard I & McDonald Is,HM,0,0,0,0,0,0,0,0,0,,Indian Ocean, 8 | Christ. I.,Christmas I,KT,0,0,0,0,0,0,0,0,0,,Indian Ocean, 9 | Cocos Is.,Cocos (Keeling) Is,CK,0,0,0,0,0,0,0,0,0,,Indian Ocean, 10 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_mexico_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Mex.,Mexico,MX,155863.2079,57934.84961,68891.40836,0,0,0,85346.03553,22733.02257,63199.30384,,North America, 3 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_mongolia_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Mong.,Mongolia,MG,1251.305765,0,0,0,0,0,664.4095646,0,0,,N Asia, 3 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_oceania_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Pit. Is.,Pitcairn Is,PC,0,0,0,0,0,0,0,0,0,,Oceania, 3 | ,Palau,PS,0,0,0,0,0,0,0,0,0,,Oceania, 4 | ,Nauru,NR,0,0,0,0,0,0,0,0,0,,Oceania, 5 | Tuv.,Tuvalu,TV,0,0,0,0,0,0,0,0,0,,Oceania, 6 | Tok.,Tokelau,TL,0,0,0,0,0,0,0,0,0,,Oceania, 7 | ,US Minor Pacific Is. Refuges,UM,0,0,0,0,0,0,0,0,0,,Oceania, 8 | Cook Is.,Cook Is,CW,0,0,0,0,0,0,0,0,0,,Oceania, 9 | Am. Sam.,American Samoa,AQ,0,0,0,0,0,0,0,0,0,,Oceania, 10 | ,Tonga,TN,0,0,0,0,0,0,0,0,0,,Oceania, 11 | ,Niue,NE,0,0,0,0,0,0,0,0,0,,Oceania, 12 | ,Samoa,WS,0,0,0,0,0,0,0,0,0,,Oceania, 13 | Wal. & Fut.,Wallis & Futuna,WF,0,0,0,0,0,0,0,0,0,,Oceania, 14 | Fr. Poly.,French Polynesia,FP,0,0,0,0,0,0,0,0,0,,Oceania, 15 | U.S.,United States,US,0,0,0,0,0,0,0,0,0,,Oceania, 16 | N. Mar. Is.,Northern Mariana Is,CQ,0,0,0,0,0,0,0,0,0,,Oceania, 17 | Marsh. Is.,Marshall Is,RM,0,0,0,0,0,0,0,0,0,,Oceania, 18 | Wake I.,Wake I,WQ,0,0,0,0,0,0,0,0,0,,Oceania, 19 | Kiri.,Kiribati,KR,0,0,0,0,0,0,0,0,0,,Oceania, 20 | Micro.,Fed States of Micronesia,FM,0,0,0,0,0,0,0,0,0,,Oceania, 21 | ,Guam,GQ,0,0,0,0,0,0,0,0,0,,Oceania, 22 | Pap. N. Gui.,Papua New Guinea,PP,6920.557661,16138.70032,0,0,0,0,6243.679029,0,0,,Oceania, 23 | Sol. Is.,Solomon Is,BP,0,0,0,0,0,0,0,0,0,,Oceania, 24 | N. Cal.,New Caledonia,NC,0,0,0,0,0,0,0,0,0,,Oceania, 25 | Norf. I.,Norfolk I,NF,0,0,0,0,0,0,0,0,0,,Oceania, 26 | N.Z.,New Zealand,NZ,4985.59044,8009.22319,18231.23984,0,0,0,4408.798942,8961.364041,20463.35875,,Oceania, 27 | ,Fiji,FJ,1728.47607,0,0,0,0,0,632.3253371,3.432310638,0,,Oceania, 28 | Vanu.,Vanuatu,NH,0,0,0,0,0,0,0,0,0,,Oceania, 29 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_sasia_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Mald.,Maldives,MV,0,0,0,0,0,0,0,0,0,,S Asia, 3 | Bhu.,Bhutan,BT,1971.619139,965.4524261,50049.68357,0,0,0,3882.295556,336.0801842,1563.016465,,S Asia, 4 | ,Aksai Chin,UU,2.676544552,0,0,0,0,0,0,0,0,,S Asia, 5 | Afg.,Afghanistan,AF,27753.99503,56526.68399,24743.61945,0,0,0,67263.49351,3208.551638,2982.171137,,S Asia, 6 | Pak.,Pakistan,PK,1598936.626,7471634.043,8367036.103,0,0,0,5792868.655,906065.2274,888804.8382,,S Asia, 7 | ,Siachen-Saltoro Area,UU,0,0,0,0,0,0,0,0,0,,S Asia, 8 | ,Demchok Area,UU,0,0,0,0,0,0,0,0,0,,S Asia, 9 | ,IN-CH Small Disputed Areas,UU,0.129146084,0,0,0,0,0,71.15167527,0,0,,S Asia, 10 | ,Nepal,NP,79138.43893,1240767.128,481824.8466,0,0,0,447984.5264,753033.8907,212341.3483,,S Asia, 11 | ,Kalapani Area,UU,0,0,0,0,0,0,0,0,0,,S Asia, 12 | ,Dramana-Shakatoe Area,UU,0,0,0,0,0,0,0,0,0,,S Asia, 13 | Sri Lan.,Sri Lanka,CE,88084.03991,53329.73687,28032.21497,0,0,0,19776.71936,22718.49446,19873.1511,,S Asia, 14 | ,India,IN,4959529.512,3.10E+07,6.29E+07,0,0,0,4.23E+07,9081168.384,1.47E+07,,S Asia, 15 | Bangl.,Bangladesh,BG,1502982.633,1.49E+07,2.45E+07,0,0,0,2.51E+07,7097476.944,9776472.654,,S Asia, 16 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_satlantic_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Bouv. I.,Bouvet Island,BV,0,0,0,0,0,0,0,0,0,,S Atlantic, 3 | S. Ga. & S. Sdwch. Is.,S Georgia & S Sandwich Is,SX,0,0,0,0,0,0,0,0,0,,S Atlantic, 4 | St. Hel.,St Helena,SH,0,0,0,0,0,0,0,0,0,,S Atlantic, 5 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_seasia_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Indo.,Indonesia,ID,624113.8354,2135126.825,3980091.898,0,0,0,1578386.863,1421321.611,1090507.362,,SE Asia, 3 | Parc. Is.,Paracel Is,PF,0,0,0,0,0,0,0,0,0,,SE Asia, 4 | Sing.,Singapore,SN,34.89937883,240.6297228,72066.52878,0,0,0,388.9140944,113.1145362,86380.69449,,SE Asia, 5 | Bru.,Brunei,BX,53.60446087,0,0,0,0,0,56.90279367,41.38384994,0,,SE Asia, 6 | Phil.,Philippines,RP,480590.0129,1949529.96,1519841.274,0,0,0,751896.7417,1256030.533,1326065.211,,SE Asia, 7 | Spr. Is.,Spratly Is,PG,0,0,0,0,0,0,0,0,0,,SE Asia, 8 | Tim.-Les.,Timor-Leste,TT,0,0,0,0,0,0,0,0,0,,SE Asia, 9 | Ash. & Cart. Is.,Ashmore & Cartier Is,AT,0,0,0,0,0,0,0,0,0,,SE Asia, 10 | Malay.,Malaysia,MY,64348.08043,96834.4108,128762.4015,0,0,0,56934.38502,53107.43525,110492.6535,,SE Asia, 11 | Thai.,Thailand,TH,2049764.851,3664364.174,2361703.773,0,0,0,3684152.46,1970919.735,2196348.976,,SE Asia, 12 | ,Burma,BM,1234316.747,2823462.83,623556.8524,0,0,0,65670.95155,10232.17695,574.9425866,,SE Asia, 13 | ,Laos,LA,195078.7391,469527.168,90526.30608,0,0,0,354677.497,103821.8473,58725.56078,,SE Asia, 14 | Camb.,Cambodia,CB,1134336.764,1602591.429,152488.5459,0,0,0,1748999.621,553717.2734,128032.4768,,SE Asia, 15 | Viet.,Vietnam,VM,1082889.857,4929722.644,3422111.65,0,0,0,6590458.427,2881158.635,1875070.692,,SE Asia, 16 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_southamerica_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | Bol.,Bolivia,BL,42388.25825,79929.89139,21157.08582,0,0,0,31243.70134,11273.2028,7135.395731,,South America, 3 | ,Chile,CI,12064.4964,538.5145144,6217.291826,0,0,0,2092.345611,530.8653439,4463.160606,,South America, 4 | Para.,Paraguay,PA,49721.1153,26258.23024,31318.88501,0,0,0,22202.23882,8320.040083,18032.42107,,South America, 5 | Arg.,Argentina,AR,74626.70096,33590.73992,29880.04901,0,0,0,57166.76559,13292.53188,20578.02122,,South America, 6 | Uru.,Uruguay,UY,3273.15092,3453.825814,25602.57363,0,0,0,3254.831425,4373.700319,19627.48332,,South America, 7 | ,Invernada Area,BR,0,0,0,0,0,0,0,0,0,,South America, 8 | ,Isla Brasilera,UU,0,0,0,0,0,0,1.749811954,0,0,,South America, 9 | Falk. Is.,Falkland Islands,FA,0,0,0,0,0,0,0,0,0,,South America, 10 | Ecua.,Ecuador,EC,19943.90496,40708.02393,13518.54515,0,0,0,70241.84127,2647.939668,13539.60244,,South America, 11 | Ven.,Venezuela,VE,126988.0831,164626.7865,141261.4387,0,0,0,234.9030157,0,0,,South America, 12 | Sur.,Suriname,NS,186.2546417,0,0,0,0,0,46.86949534,0,0,,South America, 13 | Fr. Gui.,French Guiana,FG,0,0,0,0,0,0,0,0,0,,South America, 14 | Guy.,Guyana,GY,15730.26981,5873.69759,27231.46586,0,0,0,2581.841962,5701.261443,25275.21266,,South America, 15 | Col.,Colombia,CO,193560.7378,260248.0861,362437.8533,0,0,0,142390.446,65006.78352,304519.1449,,South America, 16 | ,Peru,PE,44557.39357,27601.73184,10196.612,0,0,0,19523.19305,2316.238844,5559.595278,,South America, 17 | Braz.,Brazil,BR,195641.6038,43637.82252,102977.4238,0,0,0,117491.0081,33019.29205,93235.72345,,South America, 18 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_swasia_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | ,Oman,MU,66.90890214,16448.41761,734.6763548,0,0,0,2221.677442,1700.155468,38.86788255,,SW Asia, 3 | U.A.E.,United Arab Emirates,AE,193.9264885,3205.129642,1164.89412,0,0,0,3812.033625,1058.526706,382.2155885,,SW Asia, 4 | ,Qatar,QA,17.95110841,91.29204374,539.405407,0,0,0,504.64577,731.2622782,143.3765507,,SW Asia, 5 | Bahr.,Bahrain,BA,160.2285228,576.8591652,18875.69146,0,0,0,389.069842,1196.165147,9641.51168,,SW Asia, 6 | ,Iran,IR,57726.92941,44084.23883,63941.79004,0,0,0,515.3178883,45.36775319,0,,SW Asia, 7 | Kuw.,Kuwait,KU,782.0406021,1239.812033,2732.532285,0,0,0,191.607308,897.1184104,2793.292364,,SW Asia, 8 | Azer.,Azerbaijan,AJ,15953.83318,13922.40837,11438.64852,0,0,0,0,0,0,,SW Asia, 9 | Arm.,Armenia,AM,1062.911205,723.9260098,465.8573599,0,0,0,0,0,0,,SW Asia, 10 | Geo.,Georgia,GG,1917.312714,1775.709633,645.8540438,0,0,0,0,0,0,,SW Asia, 11 | ,Sinafir & Tiran Is.,UU,0,0,0,0,0,0,0,0,0,,SW Asia, 12 | Turk.,Turkey,TU,184584.0611,290232.7943,548924.846,0,0,0,34.3713569,0,0,,SW Asia, 13 | Cyp.,Cyprus,CY,959.8238662,2905.762471,3724.745509,0,0,0,0,0,0,,SW Asia, 14 | ,Dhekelia,DX,0,0,0,0,0,0,0,0,0,,SW Asia, 15 | ,Akrotiri,AX,123.8058745,1.290249638,0,0,0,0,0,0,0,,SW Asia, 16 | Gaz. Str.,Gaza Strip,GZ,0,0,0,0,0,0,0,0,0,,SW Asia, 17 | Is.,Israel,IS,1123.599157,5429.309873,35500.94711,0,0,0,0,0,0,,SW Asia, 18 | Jor.,Jordan,JO,281.3508816,0,0,0,0,0,97.13438265,0,0,,SW Asia, 19 | Sau. Ar.,Saudi Arabia,SA,906.568506,8537.240442,2169.790229,0,0,0,2858.362166,1986.948605,1371.632593,,SW Asia, 20 | W. Bank,West Bank,WE,89.50471592,151.8568869,376.5490952,0,0,0,0,0,0,,SW Asia, 21 | ,No Man's Land,NM,0,0,0,0,0,0,0,0,0,,SW Asia, 22 | W. Bank,West Bank,WE,0,0,0,0,0,0,0,0,0,,SW Asia, 23 | ,Iraq,IZ,125415.6077,273322.6878,14184.69067,0,0,0,127610.3343,19754.17537,10677.16928,,SW Asia, 24 | Syr.,Syria,SY,48413.61238,114339.9303,23957.6829,0,0,0,4.010704633,0,0,,SW Asia, 25 | Leb.,Lebanon,LE,1468.025483,5567.494294,56923.00067,0,0,0,3326.982953,7221.892137,42204.42557,,SW Asia, 26 | Syr.,Syria,SY,0,0,0,0,0,0,0,0,0,,SW Asia, 27 | Syr.,Syria,SY,0,0,0,0,0,0,0,0,0,,SW Asia, 28 | Is.,Israel,IS,0,0,0,0,0,0,0,0,0,,SW Asia, 29 | Syr.,Syria,SY,0,0,0,0,0,0,0,0,0,,SW Asia, 30 | Syr.,Syria,SY,0,0,0,0,0,0,0,0,0,,SW Asia, 31 | Yem.,Yemen,YM,279.0002138,0,2735.717416,0,0,0,0,0,0,,SW Asia, 32 | -------------------------------------------------------------------------------- /data/pop_sensitivity_analysis/sensitivity_analysis_usa_20210105.csv: -------------------------------------------------------------------------------- 1 | country_abbrev,country_name,countrycode,floodpop_ghsl_1,floodpop_ghsl_2,floodpop_ghsl_3,floodpop_gridpop3_1,floodpop_gridpop3_2,floodpop_gridpop3_3,floodpop_hrsl_1,floodpop_hrsl_2,floodpop_hrsl_3,id,world_region,.geo 2 | U.S.,United States,US,417292.2888,407381.3204,680281.8576,0,0,0,354598.0079,379191.8846,660915.8125,,North America, 3 | U.S.,United States,US,183500.1618,138806.6585,393359.9057,0,0,0,148982.2263,129854.905,392016.7873,,North America, 4 | U.S.,United States,US,9477.35577,10190.85437,4736.766987,0,0,0,8287.176054,9651.826864,5568.107435,,North America, 5 | U.S.,United States,US,21612.42398,54181.69385,298183.4197,0,0,0,19597.59428,54343.3263,296946.887,,North America, 6 | -------------------------------------------------------------------------------- /data/shp_files/dfo_polys_20191203.dbf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudtostreet/MODIS_GlobalFloodDatabase/0d20b91d124b5a9987d40392b5e3463d78f1f894/data/shp_files/dfo_polys_20191203.dbf -------------------------------------------------------------------------------- /data/shp_files/dfo_polys_20191203.prj: -------------------------------------------------------------------------------- 1 | GEOGCS["Unknown",DATUM["D_MIF 0",SPHEROID["WGS_84_MAPINFO_Datum_0",6378137.01,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] -------------------------------------------------------------------------------- /data/shp_files/dfo_polys_20191203.shp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudtostreet/MODIS_GlobalFloodDatabase/0d20b91d124b5a9987d40392b5e3463d78f1f894/data/shp_files/dfo_polys_20191203.shp -------------------------------------------------------------------------------- /data/shp_files/dfo_polys_20191203.shx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudtostreet/MODIS_GlobalFloodDatabase/0d20b91d124b5a9987d40392b5e3463d78f1f894/data/shp_files/dfo_polys_20191203.shx -------------------------------------------------------------------------------- /ext.datafig10.R: -------------------------------------------------------------------------------- 1 | #set working directory where the csv lives 2 | setwd("/Users/bethtellman/Desktop/papers/GFD/figures/") 3 | 4 | #this is the dataset of population exposed to floods in the WRI data and in the GFD 5 | #for countries that passed the quality control threshold for inclusion 6 | popcountrwri<-read.csv('data/gfd_popsummary.csv') 7 | summary(popcountrwri) 8 | 9 | #this summs the population exposed across rural, urban, and semi urban land use classes from GHSL 10 | #2000 is the population exposed in 2000 and "delta" is the additional populatione exposed using 2015 population data 11 | popcountrwri$floodpopGFD<-(popcountrwri$pop_2000_flood_rural+ 12 | popcountrwri$pop_2000_flood_urban+ popcountrwri$pop_2000_flood_semiurban + 13 | popcountrwri$pop_delta_flood_urban + popcountrwri$pop_delta_flood_semiurban + 14 | popcountrwri$pop_delta_flood_rural) 15 | 16 | #this code creates extended data figure #10 17 | library(ggplot2) 18 | ggplot (popcountrwri , 19 | aes(log(P10_bh_100), log(floodpopGFD), colour= continent)) + 20 | labs(title="", x="Population (log) at risk of floods 100-year return period, GLOFRIS", y= "Population (log) exposed to floods, observed 2000-2018", colour= "")+ 21 | geom_point(size=1)+ 22 | geom_point(size=1)+ 23 | #xlim(8,21)+ 24 | #ylim(8,21)+ 25 | theme(axis.text.x = element_text(size=12, vjust=0.6), 26 | axis.text.y = element_text(size=12, vjust=0.6), 27 | axis.title.x = element_text(size=18, vjust=0.6), 28 | axis.title.y = element_text(size=18, vjust=0.6), 29 | legend.text = element_text(size=12, vjust=0.6) 30 | )+ 31 | geom_text(aes(label=country))+ 32 | geom_abline(slope=1, intercept=0, colour="blue")+ 33 | geom_smooth(method=lm, se=FALSE, fullrange=TRUE, color='#2C3E50') 34 | 35 | ggplot (popcountrwri , 36 | aes(log(P10_bh_100), log(sum), colour= continent)) + 37 | labs(title="", x="Population (log) at risk of floods, GLOFRIS", y= "Population (log) exposed to floods, observed 2000-2018", colour= "")+ 38 | geom_point(size=1)+ 39 | geom_point(size=1)+ 40 | #xlim(8,21)+ 41 | #ylim(8,21)+ 42 | theme(axis.text.x = element_text(size=12, vjust=0.6), 43 | axis.text.y = element_text(size=12, vjust=0.6), 44 | axis.title.x = element_text(size=12, vjust=0.6), 45 | axis.title.y = element_text(size=12, vjust=0.6), 46 | legend.text = element_text(size=12, vjust=0.6) 47 | )+ 48 | geom_text(aes(label=country))+ 49 | abline()+ 50 | geom_smooth(method=lm, se=FALSE, fullrange=TRUE, color='#2C3E50') 51 | 52 | #pearson correlation between the two datasets 53 | cor.test(popcountrwri$P10_bh_100, popcountrwri$floodpopGFD, method="pearson") 54 | -------------------------------------------------------------------------------- /ext.datafig8.R: -------------------------------------------------------------------------------- 1 | # This code makes extended data figure 8, a sensitivty analysis of 2 | # changes in predicted population exposured to floods form the WRI Aqueduct model 3 | # at different return periods 4 | 5 | #add working directory for .csv files 6 | setwd("/Users/bethtellman/Desktop/papers/GFD/gfd_nature-master/data") 7 | 8 | library(ggplot2) 9 | library(countrycode) 10 | library(plyr) 11 | 12 | #ssp2 population data 13 | #add total pop data from SSP2 14 | #2010 15 | SSP22010<-read.csv("data/SSP2010.csv") 16 | SSP22010$pop2010<-SSP22010$sum 17 | #2030 18 | SSP22030<-read.csv("data/SSP2030.csv") 19 | SSP22010$pop2030<-SSP22030$sum 20 | #join 2010 ands 2030 data 21 | SSP2<-join(SSP22010,SSP22030, by= "system.index") 22 | #assign country codes 23 | SSP2$cc<- countrycode(SSP2$country, "country.name", "iso2c" , origin_regex=TRUE) 24 | 25 | #aqueduct flood data, see Aqueduct dictionary for explanation of each column name 26 | Aquecountry0<-read.csv('data/aqueductcountrydata.csv') 27 | #assign it country codes and names 28 | Aquecountry0$cc<- countrycode(Aquecountry0$unit_name, "country.name", "iso2c" , origin_regex=TRUE) 29 | Aquecountry0$continent<- countrycode(Aquecountry0$cc, "iso2c", "continent" , origin_regex=TRUE) 30 | 31 | #join SSP and Aqueduct data 32 | Aquecountry<- join(Aquecountry0,SSP2, by="cc") 33 | 34 | #change ratio, porportional changes in flood population exposed vs. population growth from SSP 35 | changeccp500<-(Aquecountry$P30_28_500/Aquecountry$pop2030)/(Aquecountry$P10_bh_500/Aquecountry$pop2010) 36 | changeccp100<-(Aquecountry$P30_28_100/Aquecountry$pop2030)/(Aquecountry$P10_bh_100/Aquecountry$pop2010) 37 | changeccp250<-(Aquecountry$P30_28_250/Aquecountry$pop2030)/(Aquecountry$P10_bh_250/Aquecountry$pop2010) 38 | changeccp50<-(Aquecountry$P30_28_50/Aquecountry$pop2030)/(Aquecountry$P10_bh_50/Aquecountry$pop2010) 39 | changeccp25<-(Aquecountry$P30_28_25/Aquecountry$pop2030)/(Aquecountry$P10_bh_25/Aquecountry$pop2010) 40 | changeccp10<-(Aquecountry$P30_28_10/Aquecountry$pop2030)/(Aquecountry$P10_bh_10/Aquecountry$pop2010) 41 | #store in the data frame 42 | Aquecountry$changeccp500<-changeccp500 43 | Aquecountry$changeccp100<-changeccp100 44 | Aquecountry$changeccp250<-changeccp250 45 | Aquecountry$changeccp50<-changeccp50 46 | Aquecountry$changeccp25<-changeccp25 47 | Aquecountry$changeccp10<-changeccp10 48 | 49 | #abschange 50 | Aquecountry$changeccabs500<-Aquecountry$P30_28_500-Aquecountry$P10_bh_500 51 | Aquecountry$changeccabs100<-Aquecountry$P30_28_100-Aquecountry$P10_bh_100 52 | Aquecountry$changeccabs250<-Aquecountry$P30_28_250-Aquecountry$P10_bh_250 53 | Aquecountry$changeccabs50<-Aquecountry$P30_28_50-Aquecountry$P10_bh_50 54 | Aquecountry$changeccabs25<-Aquecountry$P30_28_25-Aquecountry$P10_bh_25 55 | Aquecountry$changeccabs10<-Aquecountry$P30_28_10-Aquecountry$P10_bh_10 56 | 57 | #percentchange 58 | Aquecountry$changeccper500<-(Aquecountry$P30_28_500-Aquecountry$P10_bh_500)/Aquecountry$P10_bh_500*100 59 | Aquecountry$changeccper100<-(Aquecountry$P30_28_100-Aquecountry$P10_bh_100)/Aquecountry$P10_bh_250*100 60 | Aquecountry$changeccper250<-(Aquecountry$P30_28_250-Aquecountry$P10_bh_250)/Aquecountry$P10_bh_100*100 61 | Aquecountry$changeccper50<-(Aquecountry$P30_28_50-Aquecountry$P10_bh_50)/Aquecountry$P10_bh_50*100 62 | Aquecountry$changeccper25<-(Aquecountry$P30_28_25-Aquecountry$P10_bh_25)/Aquecountry$P10_bh_25*100 63 | Aquecountry$changeccper10<-(Aquecountry$P30_28_10-Aquecountry$P10_bh_10)/Aquecountry$P10_bh_10*100 64 | library(reshape2) 65 | 66 | #melt data frame, aqueduct flood population exposure 67 | AQmeltp<-melt(Aquecountry, id.vars = c("continent", "unit_name"), measure.vars= c('changeccp500','changeccp250','changeccp100', 68 | 'changeccp25', 69 | 'changeccp10')) 70 | library(dplyr) 71 | AQmeltp <- AQmeltp %>% 72 | mutate(variable_rec = factor(recode(variable, 73 | "changeccp500"="500", 74 | "changeccp250"="250", 75 | "changeccp100"="100", 76 | "changeccp25"="25", 77 | "changeccp10"="10"))) 78 | 79 | #melt data frame, aqueduct flood population exposure in 2030 80 | AQmelt2030<-melt(Aquecountry, id.vars = c("continent", "unit_name"), measure.vars= c('P30_28_500', 'P30_28_250','P30_28_100', 81 | 'P30_28_50','P30_28_25', 'P30_28_10')) 82 | #absolute change 83 | AQmeltabschange<-melt(Aquecountry, id.vars = c("continent", "unit_name"), measure.vars= c('changeccabs500','changeccabs250','changeccabs100', 84 | 'changeccabs25', 85 | 'changeccabs10')) 86 | #recode for plotting 87 | AQmeltabschange<- AQmeltabschange%>% 88 | mutate(variable_rec = factor(recode(variable, 89 | "changeccabs500"="500", 90 | "changeccabs250"="250", 91 | "changeccabs100"="100", 92 | "changeccabs25"="25", 93 | "changeccabs10"="10"))) 94 | 95 | #percentchange 96 | AQmeltperchange<-melt(Aquecountry, id.vars = c("continent", "unit_name"), measure.vars= c('changeccper500','changeccper250','changeccper100', 97 | 'changeccper25', 98 | 'changeccper10')) 99 | #recode for plotting 100 | AQmeltperchange<- AQmeltperchange%>% 101 | mutate(variable_rec = factor(recode(variable, 102 | "changeccper500"="500", 103 | "changeccper250"="250", 104 | "changeccper100"="100", 105 | "changeccper25"="25", 106 | "changeccper10"="10"))) 107 | 108 | #remove obs with NA in column 109 | AQmeltabschangenoNA<-AQmeltabschange[!is.na(AQmeltabschange$continent),] 110 | AQmeltpNA<-AQmeltp[!is.na(AQmeltp$continent),] 111 | AQmeltperchangeNA<-AQmeltperchange[!is.na(AQmeltperchange$continent),] 112 | 113 | #this is to make extended data figure 7 114 | pcp<-ggplot(AQmeltpNA, aes(x=variable_rec, y=value, fill=continent)) 115 | 116 | library(scales) 117 | library(Hmisc) 118 | prop<-pcp+ 119 | geom_boxplot()+ 120 | ggtitle("d")+ 121 | labs(y= "change in proportion \n pop. exposed to floods 2030-2010", x="return period ")+ 122 | #stat_summary(fun.data = mean_cl_boot, na.rm=TRUE, geom = "pointrange", position=position_dodge(.5),width = 0.2)+ 123 | theme(plot.title = element_text(size=8 * ggplot2:::.pt, face = "bold"), 124 | text = element_text(size=5 * ggplot2:::.pt), 125 | axis.text.x=element_text(size=5 * ggplot2:::.pt), 126 | axis.title.y=element_text(size=5 * ggplot2:::.pt), 127 | axis.text.y=element_text(size=5 * ggplot2:::.pt)) 128 | prop 129 | 130 | Aquecountry$popgrowth<-(Aquecountry$pop2030-Aquecountry$pop2010)/Aquecountry$pop2010*100 131 | AquecountryNA<-Aquecountry[!is.na(Aquecountry$continent),] 132 | 133 | pop<-ggplot(AquecountryNA, aes(y=popgrowth, x=continent, fill=continent)) + 134 | geom_boxplot()+ 135 | ggtitle("c")+ 136 | labs(y= "percent increase \n total population 2030-2010")+ 137 | #stat_summary(fun.data = mean_cl_boot, na.rm=TRUE, geom = "pointrange", position=position_dodge(.5),width = 0.2)+ 138 | theme(plot.title = element_text(size=8 * ggplot2:::.pt, face = "bold"), 139 | axis.text.x=element_blank(), 140 | axis.title.x=element_blank(), 141 | text = element_text(size=5 * ggplot2:::.pt), 142 | axis.title.y=element_text(size=5 * ggplot2:::.pt), 143 | axis.text.y=element_text(size=5 * ggplot2:::.pt)) 144 | pop 145 | 146 | 147 | pcabschange<-ggplot(AQmeltabschangenoNA, aes(x=variable_rec, y=(value), fill=continent)) 148 | abs<-pcabschange+ ggtitle("a")+ 149 | geom_boxplot()+ 150 | #ylim(0,20)+ 151 | labs(y= "change in total \n pop. exposed to floods 2030-2010", x="return period ")+ 152 | #stat_summary(fun.data = mean_cl_boot, na.rm=TRUE, geom = "pointrange", position=position_dodge(.5), width = 0.2) + 153 | #scale_y_continuous(labels=unit_format(units="M", scale= 1e-6))+ 154 | #scale_y_continuous( trans="log10")+ 155 | scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x), 156 | labels = trans_format("log10", math_format(10^.x))) + 157 | annotation_logticks(sides="l") + 158 | #coord_trans(y = "log10")+ 159 | theme(plot.title = element_text(size=8 * ggplot2:::.pt, face = "bold"), 160 | text = element_text(size=5 * ggplot2:::.pt), 161 | axis.text.x=element_text(size=5 * ggplot2:::.pt), 162 | axis.title.y=element_text(size=5 * ggplot2:::.pt), 163 | axis.text.y=element_text(size=5 * ggplot2:::.pt)) 164 | abs 165 | pperchange<-ggplot(AQmeltperchangeNA, aes(x=variable_rec, y=value, fill=continent)) 166 | 167 | per<-pperchange+ ggtitle("b")+ 168 | geom_boxplot()+ 169 | labs(y= "percent increase \n pop. exposed to floods 2030-2010", x="return period ")+ 170 | #stat_summary(fun.data = mean_cl_boot, na.rm=TRUE, geom = "pointrange", position=position_dodge(.5), width = 0.2) + 171 | theme(plot.title = element_text(size=8 * ggplot2:::.pt, face = "bold"), 172 | text = element_text(size=5 * ggplot2:::.pt), 173 | axis.text.x=element_text(size=5 * ggplot2:::.pt), 174 | axis.title.y=element_text(size=5 * ggplot2:::.pt), 175 | axis.text.y=element_text(size=5 * ggplot2:::.pt)) 176 | per 177 | library(ggpubr) 178 | boxes<-ggarrange(abs,per, pop,prop, ncol=2, nrow=2 ,common.legend= TRUE) 179 | boxes 180 | -------------------------------------------------------------------------------- /flood_detection/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudtostreet/MODIS_GlobalFloodDatabase/0d20b91d124b5a9987d40392b5e3463d78f1f894/flood_detection/__init__.py -------------------------------------------------------------------------------- /flood_detection/modis.py: -------------------------------------------------------------------------------- 1 | # Input Parameters: 2 | # - 'roi' - this needs to be an ee.Geometry(). Can get from ee.FeatureCollection('yourTableAsset').geometry() 3 | # - 'began' - the start date of the event as a String 4 | # - 'ended' - the end date of the event as a String 5 | # - 'threshold' - "standard" or "otsu" 6 | # - 'my_comp' - "2Day" or "3Day". The DFO algorithm uses multiple days of images to remove false detections from cloud shadows. 7 | # - 'get_max' - option to add the maximum amount image as a band to the output default 'False' 8 | 9 | # The output is a multi-band image that has 4 bands: 10 | # 0: 'flooded': Flood Extent (1 = flood, 0 = not flood) 11 | # 1: 'duration': number of days in event that each pixel was flooded 12 | # 2: 'clear_views': Number of clear views (number of times a pixel had a clear view (ie not flagged as cloud) during the event) 13 | # 3: 'clear_perc': Percent clear views (clear views normalized by number of images) 14 | 15 | import ee 16 | import modis_toolbox 17 | from utils import misc, otsu 18 | 19 | def dfo(roi, began, ended, threshold, my_comp='3Day', get_max=False): 20 | 21 | # Get rectangular bounds because it works faster than complex geometries. 22 | # Clip to actual geometry at the end. 23 | roi_bounds = roi.bounds() 24 | 25 | # Get dates as ee.Date() 26 | # The "Began" and "End" dates are taken in this case and buffered at the 27 | # start and end by 2 days. This is so the first day of the flood, defined 28 | # by the "Began" date is included in a 3-day composite with the images from 29 | # two days prior. Then we move step-wise through the each day building 30 | # composites for 2 or 3-day windows. 31 | date_range = ee.DateRange(ee.Date(began).advance(-2,"day"), 32 | ee.Date(ended).advance(3,"day")) 33 | 34 | def region_clip(img): 35 | return img.clip(roi_bounds) 36 | 37 | # STEP 2 - LOAD IMPORTANT MODIS DATA BASED ON DATES 38 | # Collect Terra and Aqua satellites 39 | terra = modis_toolbox.get_terra(roi_bounds, date_range).map(region_clip) 40 | aqua = modis_toolbox.get_aqua(roi_bounds, date_range).map(region_clip) 41 | 42 | # Apply Pan-sharpen function to aqua and terra images 43 | terra_sharp = terra.map(modis_toolbox.pan_sharpen) 44 | aqua_sharp = aqua.map(modis_toolbox.pan_sharpen) 45 | 46 | # add NIR/RED ratio to all images 47 | terra_ratio = terra_sharp.map(modis_toolbox.b1b2_ratio) 48 | aqua_ratio = aqua_sharp.map(modis_toolbox.b1b2_ratio) 49 | 50 | # Apply QA Band Extract to Terra & Aqua 51 | terra_final = terra_ratio.map(modis_toolbox.add_qa_bands) 52 | aqua_final = aqua_ratio.map(modis_toolbox.add_qa_bands) 53 | 54 | # Finally, the Terra and Aqua products are combined into one image 55 | # collection so they can be accessed in together in the DFO algorithm. 56 | modis = ee.ImageCollection(terra_final.merge(aqua_final)\ 57 | .sort("system:time_start", True)) 58 | print "Collected and pre-processed MODIS Images" 59 | 60 | # STEP 3 - APPLY THE DFO WATER DETECTION & COMPOSITING ALGORITHMS 61 | # Okay - this is where it starts to get exciting. The portion of the code 62 | # applies the DFO algorithm by first optimizing the thresholds applied to 63 | # water detection, then applying those thresholds, and finally compositing 64 | # images based on 2 or 3-day windows. The "otsu" mode uses bimodal histogram 65 | # splitting on the bands to select thresholds, or the "standard" mode uses 66 | # the static thresholds from DFO 67 | 68 | # STEP 3.1 - SELECT thresholds 69 | if threshold == "standard": 70 | thresh_dict = {"b1b2": 0.70, "b7": 675.00, 'base_res': None} 71 | elif threshold == "otsu": 72 | 73 | # Apply the qa_mask to each modis image. We then make a composite across 74 | # all the flood images to one image. This is done so to increase the 75 | # sampling space as well as represent variation within the flood event 76 | # itself. Clip to the roi to exclude ocean area in the sample. 77 | modis_masked = modis.map(modis_toolbox.qa_mask) 78 | sample_frame = modis_masked.median().clip(roi) 79 | 80 | # Get a watermask that can be used to define strata for sampling 81 | began_img = ee.Image().set({"Began": began}) 82 | strata = misc.get_jrc_yearly_perm(began, roi_bounds)\ 83 | .updateMask(sample_frame.select("red_250m").mask()).int8()\ 84 | .clip(roi) 85 | 86 | # Otsu histrograms require a "bi-modal histogram". We need to constrain 87 | # the reflectance range that can be used in the histogram as it may 88 | # include high-reflectance features (e.g. missed clouds) that will make 89 | # the histogram "multi-modal". Below are the steps to constrain the 90 | # histograms into a reasonable range that one might expect water/ land 91 | swir_mask = sample_frame.select("swir").gt(-500)\ 92 | .And(sample_frame.select("swir").lt(3000)) 93 | cleaned_swir = sample_frame.select("swir").updateMask(swir_mask) 94 | 95 | # Put it all together in a final sample image 96 | sample_img = sample_frame.addBands(strata)\ 97 | .addBands(cleaned_swir, overwrite=True) 98 | 99 | # Collect Sample using stratifiedSample() function 100 | sample_bands = ["b1b2_ratio", "swir", "jrc_perm_yearly"] 101 | base_res = ee.Image(modis.first()).select("red_250m")\ 102 | .projection().nominalScale().multiply(1).getInfo() 103 | base_res = round(base_res,2) 104 | sample = sample_img.select(sample_bands)\ 105 | .stratifiedSample(numPoints=2500, 106 | classBand="jrc_perm_yearly", 107 | region=roi, scale=base_res, 108 | dropNulls=True) 109 | 110 | # Convert the sample to a histogram 111 | b1b2_hist = sample.reduceColumns(ee.Reducer.histogram(), 112 | ["b1b2_ratio"]).get("histogram") 113 | swir_hist = sample.reduceColumns(ee.Reducer.histogram(), 114 | ["swir"]).get("histogram") 115 | 116 | # Calculate histogram, run otsu, and collect into a dictionary 117 | b1b2_thresh = otsu.get_threshold(b1b2_hist) 118 | swir_thresh = otsu.get_threshold(swir_hist) 119 | thresh_dict = {'b1b2': b1b2_thresh.getInfo(), 120 | 'b7': swir_thresh.getInfo(), 121 | 'base_res':base_res} 122 | 123 | print "Calculated thresholds for Otsu: {0}".format(thresh_dict) 124 | 125 | else: 126 | raise ValueError("'threshold' options are 'standard' or 'otsu'") 127 | 128 | # STEP 3.2 - APPLY THRESHOLDS TO MODIS IMAGES 129 | # The following function cycles through each MODIS image prepared above 130 | # and applies the thresholds to distinguish land from water. To do this 131 | # Bands 1, 2, and 7 (Red, NIR, and SWIR) are used. Within the function a 132 | # Band 2/ Band 1 ratio is defined. The thresholds are combined and where a 133 | # pixel passes all three thresholds it is flagged as water. 134 | def dfo_water_detection(modis_collection, thresh_b1b2, thresh_b7): 135 | def water_flag(img): 136 | 137 | # Apply thresholds to each ratio/ band 138 | b1b2_ratio = ee.Image(img.select('b1b2_ratio')) 139 | b1b2_sliced = b1b2_ratio.lt(ee.Image.constant(thresh_b1b2)) # Band 1/Band 2 140 | b1_sliced = img.select(["red_250m"],["b1_thresh"])\ 141 | .lt(ee.Image.constant(2027)) # Band 1 Threshold 142 | b7_sliced = img.select(["swir"],["b7_thresh"])\ 143 | .lt(ee.Image.constant(thresh_b7)) # Band 7 Threshold 144 | 145 | # Add all the thresholds to one image and then sum() 146 | thresholds = b1b2_sliced.addBands(b1_sliced).addBands(b7_sliced) 147 | thresholds_count = thresholds.reduce(ee.Reducer.sum()) 148 | 149 | # Apply water_flage threshold to final image 150 | water_flag = thresholds_count.gte(ee.Image.constant(3)) 151 | return water_flag.copyProperties(img).set("system:time_start", 152 | img.get("system:time_start")) 153 | 154 | # Apply the 'water_flag' function over the modis collection 155 | dfo_water_collection = modis_collection.map(water_flag) 156 | return dfo_water_collection.set({'threshold_b1b2': round(thresh_b1b2,3), 157 | 'threshold_b7': round(thresh_b7,2), 158 | 'otsu_sample_res': thresh_dict['base_res']}) 159 | 160 | # The dfoWaterDetection() function is mapped over the MODIS collection 161 | modis_dfo_water_detection = dfo_water_detection(modis, thresh_dict["b1b2"], 162 | thresh_dict["b7"]) 163 | 164 | # STEP 3.2 - DFO COMPOSITES 165 | # The following functions create 2 or 3-day composites. IMPORTANT: 166 | # This is based on the variable defined above as "my_comp". This is 167 | # done by using a join where a lag period is defined (in milliseconds) 168 | # where images 2 or 3 days prior are joined to the current image as a 169 | # property. This is later extracted in a function to access the images 170 | # and create a composite. 171 | def join_previous_days(left_collection, right_collection, lag_days): 172 | filt = ee.Filter.And(ee.Filter.maxDifference( 173 | 1000 * 60 * 60 * 24 * lag_days, 174 | leftField = "system:time_start", 175 | rightField = "system:time_start"), 176 | ee.Filter.greaterThanOrEquals( 177 | leftField = "system:time_start", 178 | rightField = "system:time_start")) 179 | 180 | return ee.Join.saveAll(matchesKey = 'dfo_images', 181 | measureKey = 'delta_t', 182 | ordering = "system:time_start", 183 | ascending = True).apply(left_collection, 184 | right_collection, 185 | filt) 186 | 187 | # The join_previous_days() function is then used to calculate "2Day" or 188 | # "3Day" composites. The separate image collections can be accessed by 189 | # defining the variable my_comp above. 190 | lag_days = {"3Day": 2, "2Day": 1} 191 | modis_join_previous = join_previous_days(modis_dfo_water_detection, 192 | modis_dfo_water_detection, lag_days[my_comp]) 193 | 194 | # The next function takes the join_previous_days results and combines the 195 | # images in order to create the actual composite. This is done by 196 | # accessing the images stored in the properties of each image (i.e. the 197 | # images 1 or 2 days prior). Each composite has 2x the number of 198 | # images as it does days since we use both Terra and Aqua. Where at 199 | # least half of those days are flagged as water (i.e. 3 days for 3-day 200 | # composites and 2-days for 2-day composites) a pixel is marked as 201 | # water. This step help avoid marking cloud shadows, that move between 202 | # images, as water. A common misclassificatin in these types of 203 | # algorithms. 204 | 205 | def dfo_flood_water(composite_collection, comp_days): 206 | def apply_comp_day(image): 207 | dfo_composite = ee.ImageCollection.fromImages(image.get("dfo_images")).sum() 208 | stable_water_thresh = dfo_composite.gte(comp_days) 209 | return stable_water_thresh.select(["sum"], ["flood_water"]).copyProperties(image).set({"system:time_start": image.get("system:time_start")}) 210 | stable_water_thresh = composite_collection.map(apply_comp_day) 211 | return stable_water_thresh.set({"composite_type": ee.String(str(comp_days)).cat("Day")}) 212 | 213 | # If the began date is before Aqua started, change the critera for flooded pixels 214 | # Since there will be half the images available 215 | # 216 | # Terra & Aqua (post 2002-07-04) 217 | # DFO Threshold for flood water is 3 for 3-day composites and 2 for 218 | # 2-day composites 219 | # 220 | # Terra Only (pre 2002-07-04) 221 | # DFO Threshold for flood water is 2 for 3-day composites and 1 for 222 | # 2-day composites. 223 | 224 | if (ee.Date(began).difference(ee.Date("2002-07-04"), "day")).gte(0): 225 | dfo_comp = {"3Day": 3, "2Day": 2} 226 | elif (ee.Date(began).difference(ee.Date("2002-07-04"), "day")).lt(0): 227 | dfo_comp = {"3Day": 2, "2Day": 1} 228 | 229 | dfo_flood_coll = dfo_flood_water(modis_join_previous, dfo_comp[my_comp]) 230 | 231 | # STEP 3.3 COLLAPSE COMPOSITES INTO A FINAL FLOOD MAP 232 | # The following function is the last step in the DFO algorithm. Here we 233 | # take the resulting image collection of composites and collapse it into a 234 | # final flood extent and flood frequency image. Flood extent is defined by 235 | # all pixels that were identified as flood in any composite. Flood 236 | # frequency is the number of times a pixel was flagged as a flood pixel. 237 | def flood_extent_freq(img_coll): 238 | freq = ee.ImageCollection(img_coll).sum().divide(ee.Image.constant(2)).toUint16() 239 | flooded = freq.gte(ee.Image.constant(1)) 240 | return ee.Image(flooded.select(["flood_water"],["flooded"]) 241 | .addBands(freq.select(["flood_water"],["duration"])) 242 | .copyProperties(img_coll)) 243 | 244 | dfo_flood_img = flood_extent_freq(dfo_flood_coll) 245 | 246 | # STEP 3.4 CALCULATE CLEAR DAYS 247 | # The following function takes an imageCollection that was previously run 248 | # through qaBandExtract (i.e. the input band names match with those output 249 | # by qaBandExtract) and returns an image that calculates the number of clear 250 | # days for each pixel during the flood period. 251 | def get_clear_views(img_coll): 252 | def get_cloud_mask(img): 253 | clouds = img.select("cloud_state").eq(0) 254 | shadows = img.select("cloud_shadow").eq(0) 255 | return clouds.add(shadows).gt(0) 256 | clear_views = img_coll.map(get_cloud_mask) 257 | number_clear_views = ee.Image(clear_views.sum()).select(["cloud_state"], 258 | ["clear_views"]).toUint16() 259 | def add_obs(img): 260 | obs = img.select(["cloud_state"],["observation"]).gte(0) 261 | return img.addBands(obs); 262 | observations = img_coll.map(add_obs) 263 | total_obs = observations.select('observation').sum() 264 | clear_perc = number_clear_views.divide(ee.Image(total_obs))\ 265 | .select(["clear_views"], ["clear_perc"]) 266 | return number_clear_views.addBands(clear_perc) 267 | 268 | dfo_clear_days = get_clear_views(modis) 269 | 270 | # STEP 3.4a ADD MAX IMG 271 | # For the validation we want to use the image with the maximum flood extent. 272 | # Calculate the maxImg with the function below that runs a reduceRegion() and 273 | # then selects the image with the max value. 274 | if get_max == True: 275 | def get_max_img(img_coll): 276 | # Function to calculate the flood extent of each image 277 | def calc_extent(img): 278 | img_extent = ee.Image(img).reduceRegion(reducer=ee.Reducer.sum(), 279 | geometry=roi, scale=1000, 280 | maxPixels=10e9) 281 | return img.set({'extent': img_extent.get('flood_water')}) 282 | 283 | # Apply calcExtent() function to each image 284 | extent = img_coll.map(calc_extent) 285 | max_val = extent.aggregate_max('extent') 286 | max_img = ee.Image(extent.filterMetadata('extent', 'equals', max_val).first()) 287 | date = ee.Date(max_img.get('system:time_start')) 288 | return max_img.select(['flood_water'],['max_img']).set({'max_img_date':date}) 289 | 290 | max_img = get_max_img(dfo_flood_coll) 291 | max_img_date = ee.Date(max_img.get("max_img_date")).format('yyyy-MM-dd') 292 | 293 | # STEP 3.5_TRUE: PREP FINAL IMAGES 294 | # Add all the prepared bands together 295 | dfo_final = ee.Image(dfo_flood_img).addBands([dfo_clear_days, max_img])\ 296 | .clip(roi)\ 297 | .set({"began": ee.Date(began).format("yyyy-MM-dd"), 298 | "ended": ee.Date(ended).format("yyyy-MM-dd"), 299 | "threshold_type": threshold, 300 | "max_img_date": max_img_date}) 301 | elif get_max == False: 302 | # STEP 3.5_FALSE: PREP FINAL IMAGES 303 | # Add all the prepared bands together 304 | dfo_final = ee.Image(dfo_flood_img).addBands(dfo_clear_days).clip(roi)\ 305 | .set({"began": ee.Date(began).format("yyyy-MM-dd"), 306 | "ended": ee.Date(ended).format("yyyy-MM-dd"), 307 | "threshold_type": threshold}) 308 | 309 | else: 310 | raise ValueError("'max_img' options are 'True' or 'False'") 311 | 312 | print "DFO Flood Dectection Complete" 313 | return dfo_final 314 | -------------------------------------------------------------------------------- /flood_detection/modis_toolbox.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # C2S MODIS FUNCTIONS 5 | 6 | # COLIN DOYLE - based off of Jon Sullivan's javascript functions 7 | # MARCH 12, 2017 8 | # THESE ARE FUNCTIONS WE MAY COMMONLY USE FOR MODIS 9 | # NEED TO LOAD THESE TO RUN DFO AND OTSU SCRIPTS 10 | # NOTE: SOME OF THESE ARE SET UP SPECIFICALLY FOR THE DFO AND OTSU SCRIPTS 11 | 12 | import ee 13 | ee.Initialize() 14 | import math 15 | 16 | # Function that renames the bands in MODIS GQ (250-m) collections to 17 | # readable band names 18 | def dfo_bands_gq(collection): 19 | return collection.select(["sur_refl_b01", "sur_refl_b02"], 20 | ["red_250m", "nir_250m"]); 21 | 22 | # Function that renames the bands in MODIS GA (500-m) collections to 23 | # readable band names 24 | def dfo_bands_ga(collection): 25 | return collection.select(["sur_refl_b01", "sur_refl_b03", 26 | "sur_refl_b04", "sur_refl_b07", 27 | "state_1km"], 28 | ["red_500m", "blue", "green", "swir", 29 | "state_1km"]); 30 | 31 | # join_collections joins the GQ & GA products base on similar timefields. The bands 32 | # of the each image are concatenated together. The results is several bands with 33 | # different resolutions! 34 | def join_collections(img_coll1, img_coll2): 35 | filter_time_eq = ee.Filter.equals(leftField="system:time_start", rightField="system:time_start") 36 | joined = ee.Join.inner().apply(img_coll1, img_coll2, filter_time_eq) 37 | def image_cat(image): return ee.Image.cat(image.get("primary"), image.get("secondary")) 38 | return joined.map(image_cat) 39 | 40 | # Function the collects both the GA/GQ data products of MODIS Aqua, renames 41 | # the bands to readable versions, and joins the two collections into one. 42 | def get_aqua(roi, date_range): 43 | aqua_gq = ee.ImageCollection("MODIS/006/MYD09GQ").filterDate(date_range)\ 44 | .filterBounds(roi) 45 | aqua_ga = ee.ImageCollection("MODIS/006/MYD09GA").filterDate(date_range)\ 46 | .filterBounds(roi) 47 | return ee.ImageCollection(join_collections(dfo_bands_gq(aqua_gq), 48 | dfo_bands_ga(aqua_ga))) 49 | 50 | # Function the collects both the GA/GQ data products of MODIS Terra, renames 51 | # the bands to readable versions, and joins the two collections into one. 52 | def get_terra(roi, date_range): 53 | terra_gq = ee.ImageCollection("MODIS/006/MOD09GQ").filterDate(date_range)\ 54 | .filterBounds(roi) 55 | terra_ga = ee.ImageCollection("MODIS/006/MOD09GA").filterDate(date_range)\ 56 | .filterBounds(roi) 57 | return ee.ImageCollection(join_collections(dfo_bands_gq(terra_gq), 58 | dfo_bands_ga(terra_ga))) 59 | 60 | # The panSharpen fucntion pan-sharpens the SWIR band 500-m bands using a Corrected Reflectance technique 61 | # Pay careful attention to the band names in the function. These need to be present in the 62 | # image passed to the function 63 | def pan_sharpen(image): 64 | ratio = image.select("red_500m").divide(image.select("red_250m")) 65 | blue_ps = image.select("blue").divide(ratio) 66 | swir_ps = image.select("swir").divide(ratio) 67 | green_ps = image.select("green").divide(ratio) 68 | return image.select("red_250m", "nir_250m", "state_1km")\ 69 | .addBands([blue_ps, green_ps, swir_ps])\ 70 | .set({"ratio_scale": ratio.projection().nominalScale()}) 71 | 72 | # Function that calculates a ratio between b1 and b2. Used principally for 73 | # with the Otsu functions to optimize the thresholds used later in the DFO 74 | # algorithm 75 | def b1b2_ratio (img): 76 | exp = "float(b('nir_250m') + 13.5) / float(b('red_250m') + 1081.1)" 77 | dfo_ratio = img.expression(exp) # Band 1/Band 2 Ratio Threshold 78 | return img.addBands(dfo_ratio.select([0], ["b1b2_ratio"]))\ 79 | .copyProperties(img) 80 | 81 | 82 | # The get_qa_bits function extracts unpacks the QA band that is in bit format 83 | # Extract QA Bits Returns an image containing just the specified QA bits. 84 | # Args: 85 | # image - The QA Image to get bits from. 86 | # start - The first bit position, 0-based. 87 | # end - The last bit position, inclusive. 88 | # name - A name for the output image.u 89 | def get_qa_bits (image, start, end, new_name): 90 | # Compute the bits we need to extract. 91 | pattern = 0 92 | for i in range(start, end+1): 93 | pattern += pow(2, i) 94 | return image.select([0], [new_name]).bitwiseAnd(pattern).rightShift(start) 95 | 96 | # add_qa_bands creates an image based on MODIS QA information 97 | # from the "state_1km" QA band. This function has several bands 98 | # including cloudy areas, cloud shadow, and snow/ice. 99 | 100 | # QA Band information is available at: 101 | # http://modis-sr.ltdri.org/guide/MOD09_UserGuide_v1_3.pdf 102 | # Table 16: 1-kilometer State QA Descriptions (16-bit) 103 | 104 | # cloud_state ==> 0: "clear", 1: "cloudy", 2: "mixed", 3: "not set" 105 | # cloud_shadow ==> 0: "no", 1: "yes" 106 | # ice_flag ==> 0: "no", 1: "yes" 107 | # snow_flag ==> 0: "no snow", 1: "snow" 108 | def add_qa_bands(img): 109 | cloud_state = get_qa_bits(img.select("state_1km"), 0, 1, "cloud_state") 110 | cloud_shadow = get_qa_bits(img.select("state_1km"), 2, 2, "cloud_shadow") 111 | ice_flag = get_qa_bits(img.select("state_1km"), 12, 12, "ice_flag") 112 | snow_flag = get_qa_bits(img.select("state_1km"), 15, 15, "snow_flag") 113 | return img.addBands([cloud_state, cloud_shadow, ice_flag, snow_flag]) 114 | 115 | # The qaMask function takes an image as an input with bands defined from the 116 | # add_qa_bands function. This then creates a mask from these bands to mask out 117 | # cloudy areas, shadow, and ice/snow. This mask is then applied to an image which 118 | # is returned. 119 | def qa_mask(image): 120 | cloud_mask = image.expression("b('cloud_state') == 1 || b('cloud_state') == 2") 121 | shadow_mask = image.expression("b('cloud_shadow') == 1") 122 | ice_mask = image.expression("b('ice_flag') == 1") 123 | snow_mask = image.expression("b('snow_flag') == 1") 124 | mask = cloud_mask.add(shadow_mask).add(ice_mask).add(snow_mask) 125 | return image.updateMask(mask.eq(0)) 126 | 127 | # cloud_calc calculates the cloud cover over the ROI in each image 128 | def cloud_calc(img): 129 | roi_pixels = ee.Number(img.select("state_1km").reduceRegion(reducer = ee.Reducer.count(), maxPixels = 1e9)\ 130 | .get("state_1km")) 131 | cloud_pixels = ee.Number(img.select('cloud_state') 132 | .expression("b('cloud_state') == 1 || b('cloud_state') == 2") 133 | .reduceRegion(reducer = ee.Reducer.sum(), maxPixels = 1e9) 134 | .get("cloud_state")) 135 | return img.set({'cloud_cover_perc': cloud_pixels.divide(roi_pixels).multiply(100)}) 136 | 137 | # The least_cloudy fucntion takes an image collection that has already been 138 | # passed to cloud_calc and has a "cloud_cover_perc" property added. The image 139 | # with the minimum cloud cover is returned 140 | def least_cloudy(img_coll): 141 | non_null_images = img_coll.filterMetadata("cloud_cover_perc", "greater_than", 0) 142 | min_cloud = non_null_images.aggregate_min("cloud_cover_perc") 143 | return ee.Image(non_null_images.filterMetadata("cloud_cover_perc", "equals", min_cloud).first()) 144 | -------------------------------------------------------------------------------- /flood_detection/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudtostreet/MODIS_GlobalFloodDatabase/0d20b91d124b5a9987d40392b5e3463d78f1f894/flood_detection/utils/__init__.py -------------------------------------------------------------------------------- /flood_detection/utils/export.py: -------------------------------------------------------------------------------- 1 | # Original script Colin Doyle; material was edited and added by Devin Routh 2 | # Export functions 3 | # These are different functions to export the maps to assets or cloud buckets 4 | 5 | import ee 6 | ee.Initialize() 7 | 8 | # -------------------------------------------------------- 9 | # This function is used to export maps that were created from DFO events with an 10 | # index number 11 | # Args: 12 | # flood_img : the standard Earth Engine Image object 13 | # bounds: the ROI 14 | # save_path: the asset path into which you'd like to save the image 15 | # res: the resolution (in meters) per pixel of the image 16 | # Returns: 17 | # - Saves the image into the GEE Code Editor Asset path 18 | # -------------------------------------------------------- 19 | def to_asset(flood_img, bounds, save_path, res=250): 20 | 21 | # This Fusion Table is the QC database from 11/12/18 22 | # dfo_props = ee.FeatureCollection('ft:1P_wUQQJqghdnN3UMAcXDlrbQFpJWN-md2eH1WprS') 23 | 24 | # This Fustino Table is the DFO Database from July 16th, 2019 25 | dfo_props = ee.FeatureCollection('ft:1lxrZ7wqJZkxVgP3L_yQOFqY3rXHH_5oSscO3IPOZ') 26 | dfo_id = flood_img.get('id').getInfo() 27 | props = ee.Feature(dfo_props.filterMetadata('ID', 'equals', dfo_id).first())\ 28 | .getInfo()['properties'] 29 | 30 | # Clean up some of the DFO database 31 | if props.get('GlideNumber')=='0': 32 | glide_number = 'NA' 33 | else: 34 | glide_number = props.get('GlideNumber') 35 | 36 | if props.get('OtherCountry')=='0': 37 | dfo_other_country = 'NA' 38 | else: 39 | dfo_other_country = props.get('OtherCountry') 40 | 41 | # ------------------------ EXPORT RESULTS-------------------------- # 42 | start_formatted = ee.Date(props.get('Began')).format('yyyyMMdd').getInfo() 43 | end_formatted = ee.Date(props.get('Ended')).format('yyyyMMdd').getInfo() 44 | save_name = "DFO_" + str(dfo_id) + "_From_" + str(start_formatted) + "_to_" + str(end_formatted) 45 | save_asset = str(save_path + "/" + save_name) 46 | 47 | task = ee.batch.Export.image.toAsset( 48 | image=flood_img.set({'glide_index': ee.String(glide_number), 49 | 'dfo_country': ee.String(props.get('Country')), 50 | 'dfo_other_country': ee.String(dfo_other_country), 51 | 'dfo_centroid_x': ee.Number(props.get('long')), 52 | 'dfo_centroid_y': ee.Number(props.get('lat')), 53 | 'dfo_validation_type': ee.String(props.get("Validation")), 54 | 'dfo_main_cause': ee.String(props.get("MainCause")), 55 | 'dfo_severity': ee.Number(props.get("Severity")), 56 | 'dfo_dead': ee.Number(props.get("Dead")), 57 | 'dfo_displaced': ee.Number(props.get("Displaced"))}), 58 | description="ExportToAsset DFO" + str(dfo_id), 59 | assetId=save_asset, 60 | region=bounds.getInfo()['coordinates'], 61 | scale=res, 62 | maxPixels=1e12 63 | ) 64 | task.start() 65 | return 66 | 67 | # -------------------------------------------------------- 68 | # This function is an exact copy of the script above except 69 | # it is used to export maps that were created from the 70 | # map_Event_ByROIDateRange function to a CSB 71 | # 72 | # Args: 73 | # flood_img : the standard Earth Engine Image object 74 | # bounds: the ROI 75 | # cloud_path: the name of the Cloud Bucket to upload the file (as a string) 76 | # res: the resolution (in meters) per pixel of the image 77 | # 78 | # Returns: 79 | # - Saves the image into the GEE Code Editor Asset path 80 | 81 | # -------------------------------------------------------- 82 | def to_gcs(flood_img, bounds, cloud_path, name_prefix='DFO', res=250): 83 | 84 | start_formatted = ee.Date(flood_img.get('began')).format('yyyyMMdd').getInfo() 85 | end_formatted = ee.Date(flood_img.get('ended')).format('yyyyMMdd').getInfo() 86 | index = flood_img.get('id').getInfo() 87 | save_name = name_prefix + "_" + str(index) + "_From_" + str(start_formatted) + "_to_" + str(end_formatted) 88 | save_csb = str(save_name) 89 | 90 | # ------------ EXPORT RESULTS! ------------ # 91 | task = ee.batch.Export.image.toCloudStorage( 92 | image=flood_img.toFloat(), 93 | description="ExportToCSB DFO" + str(index), 94 | bucket=cloud_path, 95 | fileNamePrefix=save_csb, 96 | region=bounds.getInfo()['coordinates'], 97 | scale=res, 98 | maxPixels=1e12 99 | ) 100 | task.start() 101 | return 102 | -------------------------------------------------------------------------------- /flood_detection/utils/misc.py: -------------------------------------------------------------------------------- 1 | # Import packages 2 | import ee 3 | 4 | ee.Initialize() 5 | 6 | # Series of functions to extract overlapping watersheds from roi region. We use 7 | # HydroSheds database provided a different levels. Also - functions for islands 8 | # shapefiles are provided as HydroSheds does not cover some small islands. 9 | def get_watersheds_level5(dfo_feature): 10 | basins = ee.FeatureCollection('ft:1IHRHUiWkgPXOzwNweeM89CzPYSfokjLlz7_0OTQl') 11 | return basins.filterBounds(dfo_feature) 12 | 13 | def get_watersheds_level4(dfo_feature): 14 | basins = ee.FeatureCollection('ft:1JRW4YKfVTZKLAH4x4JRsggsHZoXRRUQKTIOYgJOW') 15 | return basins.filterBounds(dfo_feature) 16 | 17 | def get_watersheds_level3(dfo_feature): 18 | basins = ee.FeatureCollection('ft:1asIZ7d9NqNIubAp2dNMvnAfRMd-9ih7kjcLnIzv6') 19 | return basins.filterBounds(dfo_feature) 20 | 21 | def get_islands(dfo_feature): 22 | islands = ee.FeatureCollection('ft:14BijFeJ0MiV1CeP7FBst8P4Kf1Se0HK5Sfh78hJB') 23 | return islands.filterBounds(dfo_feature) 24 | 25 | def get_american_somoa(dfo_feature): 26 | asm = ee.FeatureCollection('ft:1C79v82bd1QfIsdGfDFOo2sz2XIHJCiVnXWXBeX0_') 27 | return asm.filterBounds(dfo_feature) 28 | 29 | # applySlopeMask() applies a mask to remove pixels that are greater than a 30 | # certain slope based on SRTM 90-m DEM V4 the only parameter is the slope 31 | # threshold, which is default to 5% 32 | def apply_slope_mask(img, thresh=5): 33 | srtm = ee.Image("USGS/GMTED2010") 34 | slope = ee.Terrain.slope(srtm) 35 | masked = img.updateMask(slope.lte(thresh)) 36 | return masked.set({'slope_threshold': thresh}) 37 | 38 | # this returns the permanent water mask from the JRC Global Surface Water 39 | # dataset. It gets the permanent water from the transistions layer 40 | def get_jrc_perm(roi_bounds): 41 | jrc_perm_water = ee.Image("JRC/GSW1_0/GlobalSurfaceWater")\ 42 | .select("transition").eq(1).unmask() 43 | return jrc_perm_water.select(['transition'],['jrc_perm_water']).clip(roi_bounds) 44 | 45 | def get_jrc_yearly_perm(began, roi): 46 | ee_began = ee.Date(began) 47 | jrc_year = ee.Algorithms.If(ee_began.get('year')\ 48 | .gt(2018), 2018, ee_began.get('year')) 49 | jrc_perm = ee.Image(ee.ImageCollection('JRC/GSW1_1/YearlyHistory')\ 50 | .filterBounds(roi) 51 | .filterMetadata('year', "equals", jrc_year).first())\ 52 | .remap([0, 1, 2, 3], [0, 0, 0, 1]).unmask()\ 53 | .select(['remapped'],['jrc_perm_yearly']) 54 | return jrc_perm.updateMask(jrc_perm) 55 | 56 | def get_countries (roi): 57 | countries = ee.FeatureCollection("USDOS/LSIB/2013"); 58 | img_country = countries.filterBounds(roi) 59 | 60 | cc_list = img_country.distinct('cc').aggregate_array('cc').getInfo() 61 | cc_list = [str(c) for c in cc_list] 62 | 63 | country_list = img_country.distinct('name').aggregate_array('name').getInfo() 64 | country_list = [str(c) for c in country_list] 65 | 66 | return cc_list, country_list 67 | -------------------------------------------------------------------------------- /flood_detection/utils/otsu.py: -------------------------------------------------------------------------------- 1 | 2 | # coding: utf-8 3 | 4 | # Otsu thresholding functions for choosing thresholds for DFO flood detection 5 | import ee 6 | ee.Initialize() 7 | 8 | # Compute between sum of squares, where each mean partitions the data. 9 | def get_threshold(histogram): 10 | counts = ee.Array(ee.Dictionary(histogram).get('histogram')) 11 | means = ee.Array(ee.Dictionary(histogram).get('bucketMeans')) 12 | size = means.length().get([0]) 13 | total = counts.reduce(ee.Reducer.sum(), [0]).get([0]) 14 | summed = means.multiply(counts).reduce(ee.Reducer.sum(), [0]).get([0]) 15 | mean = summed.divide(total) 16 | 17 | indices = ee.List.sequence(1, size) 18 | 19 | def calc_bss(i): 20 | aCounts = counts.slice(0, 0, i) 21 | aCount = aCounts.reduce(ee.Reducer.sum(), [0]).get([0]) 22 | aMeans = means.slice(0, 0, i) 23 | aMean = aMeans.multiply(aCounts).reduce(ee.Reducer.sum(), [0]).get([0]).divide(aCount) 24 | bCount = total.subtract(aCount) 25 | bMean = summed.subtract(aCount.multiply(aMean)).divide(bCount) 26 | return aCount.multiply(aMean.subtract(mean).pow(2)).add(bCount.multiply(bMean.subtract(mean).pow(2))) 27 | 28 | bss = indices.map(calc_bss) 29 | 30 | # Return the mean value corresponding to the maximum BSS. 31 | return means.sort(bss).get([-1]) 32 | -------------------------------------------------------------------------------- /flood_stats/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cloudtostreet/MODIS_GlobalFloodDatabase/0d20b91d124b5a9987d40392b5e3463d78f1f894/flood_stats/__init__.py -------------------------------------------------------------------------------- /gee_landsatTools.txt: -------------------------------------------------------------------------------- 1 | // Functions used to collect a mosaic of all Landsat images over a specified area 2 | // and within a certain number of days from the maximum flood extent image. 3 | exports.getLandsat = function(id, gfd, cloudCover, deltaDays){ 4 | 5 | // Prep the Landsat data by filtering flood dates 6 | // LANDSAT 8 - Filter Landsat 8 OLI Products by Flood Events Boundaries and Dates 7 | function filterFloodEventsL8 (roi, filterDate){ 8 | var imageCollection = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR").filterBounds(roi) 9 | .filterDate(filterDate, filterDate.advance(deltaDays, "day")) 10 | .filterMetadata("CLOUD_COVER", "less_than", cloudCover) 11 | return imageCollection 12 | } 13 | 14 | // LANDSAT 7 - Filter Landsat 7 ETM Products by Flood Events Boundaries and Dates 15 | function filterFloodEventsL7 (roi, filterDate){ 16 | var imageCollection = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR").filterBounds(roi) 17 | .filterDate(filterDate, filterDate.advance(deltaDays, "day")) 18 | .filterMetadata("CLOUD_COVER", "less_than", cloudCover) 19 | return imageCollection 20 | } 21 | 22 | // LANDSAT 5 - Filter Landsat 5 TM Products by Flood Events Boundaries and Dates 23 | function filterFloodEventsL5 (roi, filterDate){ 24 | var imageCollection = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR").filterBounds(roi) 25 | .filterDate(filterDate, filterDate.advance(deltaDays, "day")) 26 | .filterMetadata("CLOUD_COVER", "less_than", cloudCover) 27 | return imageCollection 28 | } 29 | 30 | // DFO Fusion Table and extract important variables 31 | var dfoEvents = ee.FeatureCollection("projects/global-flood-db/dfo-polygons/dec-03-2019"); 32 | var dfoPoly = ee.Feature(dfoEvents.filterMetadata('ID','equals',id).first()).geometry() 33 | var img = ee.Image(gfd.filterMetadata("Index", "equals", id).first()).select("flooded").clip(dfoPoly) 34 | var ft = img.updateMask(img).reduceToVectors({scale: 1000, maxPixels: 10e13}) 35 | .map(function(f){return f.simplify(10000)}) 36 | 37 | // Variables for filter landsat series of functions 38 | var maxDate = ee.Date(img.get('maxImgDate')) 39 | 40 | // Filter for Landsat 8 images 41 | var l8 = filterFloodEventsL8(ft, maxDate).select(["B2", "B3", "B4", "B5", "B6", "B7", "pixel_qa"], 42 | ["B1", "B2", "B3", "B4", "B5", "B7", "pixel_qa"]); 43 | // print("Landsat 8 OLI Collection", l8); 44 | 45 | // Filter for Landsat 7 Images 46 | var l7 = filterFloodEventsL7(ft, maxDate).select(["B1", "B2", "B3", "B4", "B5", "B7", "pixel_qa"]); 47 | //print("Landsat 7 ETM Collection", l7); 48 | 49 | // Filter for Landsat 5 images 50 | var l5 = filterFloodEventsL5(ft, maxDate).select(["B1", "B2", "B3", "B4", "B5", "B7", "pixel_qa"]); 51 | //print("Landsat 5 TM Collection", l5); 52 | 53 | // print("getLandsat() retrieved the following number of images:", 54 | // ee.String("Landsat 8: ").cat(ee.String(l8.size())), 55 | // ee.String("Landsat 7: ").cat(ee.String(l7.size())), 56 | // ee.String("Landsat 5: ").cat(ee.String(l5.size()))); 57 | 58 | return ee.ImageCollection(l8.merge(l7).merge(l5)); 59 | }; 60 | 61 | // Mask clouds based on FMask band where clouds = 4; cloud shadows = 2 62 | exports.maskClouds = function(imgColl) { 63 | var output = imgColl.map(function(img){ 64 | var cloud_pixel_qa = img.select('pixel_qa').bitwiseAnd(32).eq(0) 65 | var cloud_shadow_pixel_qa = img.select('pixel_qa').bitwiseAnd(8).eq(0) 66 | var imageSansCloudandShadow = img.updateMask(cloud_pixel_qa.and(cloud_shadow_pixel_qa)) 67 | var clear = ee.Image.constant(1).updateMask(cloud_pixel_qa.and(cloud_shadow_pixel_qa)).rename(['clear']) 68 | var obs = ee.Image.constant(1).rename(['observation']) 69 | return ee.Image(imageSansCloudandShadow.addBands(clear).addBands(obs)) 70 | }); 71 | return output; 72 | }; 73 | -------------------------------------------------------------------------------- /gee_mainFig3.txt: -------------------------------------------------------------------------------- 1 | // Load important datasets 2 | var gfd = ee.ImageCollection("projects/global-flood-db/gfd_v3"), 3 | ghsl = ee.ImageCollection("JRC/GHSL/P2016/POP_GPW_GLOBE_V1"), 4 | landscan = ee.ImageCollection("projects/global-flood-db/landscan"), 5 | jrc = ee.Image("JRC/GSW1_2/GlobalSurfaceWater"), 6 | mod44w = ee.Image("MODIS/MOD44W/MOD44W_005_2000_02_24"), 7 | 8 | // Create polygons for areas of interest 9 | new_orleans = 10 | /* color: #d63000 */ 11 | /* shown: false */ 12 | /* displayProperties: [ 13 | { 14 | "type": "rectangle" 15 | } 16 | ] */ 17 | ee.Geometry.Polygon( 18 | [[[-91.67984539909732, 30.812343730092298], 19 | [-91.67984539909732, 28.598700363414835], 20 | [-88.60367352409732, 28.598700363414835], 21 | [-88.60367352409732, 30.812343730092298]]], null, false), 22 | brazil = 23 | /* color: #98ff00 */ 24 | /* displayProperties: [ 25 | { 26 | "type": "rectangle" 27 | } 28 | ] */ 29 | ee.Geometry.Polygon( 30 | [[[-61.414139451742386, 1.3949828843040144], 31 | [-61.414139451742386, -6.370036011014096], 32 | [-49.197342576742386, -6.370036011014096], 33 | [-49.197342576742386, 1.3949828843040144]]], null, false), 34 | dhaka = 35 | /* color: #0b4a8b */ 36 | /* displayProperties: [ 37 | { 38 | "type": "rectangle" 39 | } 40 | ] */ 41 | ee.Geometry.Polygon( 42 | [[[88.35934418124666, 24.769040797318755], 43 | [88.35934418124666, 22.199878123949954], 44 | [92.66598480624666, 22.199878123949954], 45 | [92.66598480624666, 24.769040797318755]]], null, false), 46 | india = 47 | /* color: #ffc82d */ 48 | /* locked: true */ 49 | /* displayProperties: [ 50 | { 51 | "type": "rectangle" 52 | } 53 | ] */ 54 | ee.Geometry.Polygon( 55 | [[[91.13983358359377, 26.49880559147334], 56 | [91.13983358359377, 25.57089816628388], 57 | [92.36206258750002, 25.57089816628388], 58 | [92.36206258750002, 26.49880559147334]]], null, false); 59 | 60 | // STEP 1 - Prep permanent water layers & masks 61 | var gfd_first = ee.Image(gfd.first()) 62 | var scale_gfd = gfd_first.projection().nominalScale() 63 | var crs_gfd = gfd_first.projection().crs() 64 | 65 | // JRC Mask 66 | var jrc_250m = jrc.select('transition').eq(1).unmask() 67 | .reproject({crs:crs_gfd, 68 | scale:scale_gfd}) 69 | var jrc_250m_mask = jrc_250m.neq(1) 70 | 71 | // MOD44W Mask 72 | var mod44w_mask = ee.Image(mod44w.select('water_mask')).eq(0) 73 | Map.addLayer(jrc_250m_mask, {}, 'JRC', false) 74 | Map.addLayer(mod44w_mask, {}, 'MOD44W', false) 75 | 76 | // STEP 2 - Clean up GFD 77 | function maskPermWater(img){ 78 | var all_water = img.select("flooded") 79 | var water_mask = jrc_250m_mask 80 | return img.updateMask(water_mask) 81 | } 82 | 83 | function filterIsoPix (img){ 84 | 85 | // Calculate the number of connected pixels 86 | var size = img.select("flooded") 87 | .selfMask() 88 | .int() 89 | .connectedPixelCount(2, false) 90 | 91 | return size.updateMask(size.gte(2)) 92 | .multiply(0) 93 | .add(1) 94 | .reproject('EPSG:4326', null, img.projection().nominalScale())} 95 | 96 | var gfd_flood = gfd.map(maskPermWater) 97 | var gfd_cleaned = gfd_flood.map(filterIsoPix) 98 | 99 | // STEP 3 - Sum entire GFD collection images 100 | var gfd_dirty_sum = gfd_flood.select('flooded').sum().selfMask() 101 | var gfd_cleaned_sum = gfd_cleaned.select('flooded').sum().selfMask() 102 | 103 | var flood_palette = ['#fff7fb','#ece7f2','#d0d1e6','#a6bddb','#74a9cf', 104 | '#3690c0','#0570b0','#045a8d','#023858'] 105 | Map.addLayer(gfd_dirty_sum, {min:1,max:9,palette:flood_palette}, 'GFD Dirty') 106 | Map.addLayer(gfd_cleaned_sum, {min:1,max:9,palette:flood_palette}, 'GFD Clean') 107 | 108 | // STEP 4 - Calculate population change from 2000 to 2015 using GHSL 109 | var ghsl_2000 = ee.Image(ghsl.filterMetadata('system:index','equals','2000').first()) 110 | var ghsl_2015 = ee.Image(ghsl.filterMetadata('system:index','equals','2015').first()) 111 | var ghsl_pop_diff = ghsl_2015.subtract(ghsl_2000) 112 | 113 | // Reproject GHSL dataset & mask 114 | var ghsl_2000_reproj = ghsl_2000.resample('bilinear').reproject(crs_gfd, null, scale_gfd) 115 | var ghsl_pdiff_reproj = ghsl_pop_diff.resample('bilinear').reproject(crs_gfd, null, scale_gfd) 116 | 117 | var ghsl_pdiff_mask = ghsl_pdiff_reproj.neq(0) 118 | var ghsl_pdiff_masked = ghsl_pdiff_reproj.updateMask(ghsl_pdiff_mask) 119 | 120 | var ghsl_2000_masked = ghsl_2000_reproj.selfMask() 121 | 122 | var pop_palette = ['#053061','#2166ac','#4393c3','#92c5de','#d1e5f0', 123 | '#f7f7f7','#fddbc7','#f4a582','#d6604d','#b2182b','#67001f'] 124 | Map.addLayer(ghsl_2000, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop 2000 - ESPG 54009', false) 125 | Map.addLayer(ghsl_2000_reproj, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop 2000 - ESPG 4326', false) 126 | Map.addLayer(ghsl_2000_masked, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop 2000 Masked - ESPG 4326', false) 127 | Map.addLayer(ghsl_pop_diff, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop Change - EPSG:54009', false) 128 | Map.addLayer(ghsl_pdiff_reproj, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop Change - ESPG 4326', false) 129 | Map.addLayer(ghsl_pdiff_masked, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop Change Masked - ESPG 4326', false) 130 | 131 | // STEP 5 - Create Raster of pop change in flood plain areas 132 | var gfd_dirty_floodplain = gfd_dirty_sum.gte(1) 133 | var gfd_dirty_popchange = gfd_dirty_floodplain.multiply(ghsl_pdiff_reproj) 134 | 135 | var gfd_clean_floodplain = gfd_cleaned_sum.gte(1) 136 | var gfd_clean_popchange = gfd_clean_floodplain.multiply(ghsl_pdiff_reproj) 137 | 138 | Map.addLayer(gfd_dirty_popchange, {min:-100,max:100,palette:pop_palette}, 'GFD Dirty Pop Change') 139 | Map.addLayer(gfd_clean_popchange.selfMask(), {min:-100,max:100,palette:pop_palette}, 'GFD Clean Pop Change') 140 | 141 | Export.image.toDrive({ 142 | image: gfd_clean_popchange, 143 | description:'hotspot_jrc_brazil', 144 | folder: 'hotspot', 145 | fileNamePrefix: 'hotspot_jrc_brazil', 146 | region: brazil, 147 | scale:250, 148 | crs: "EPSG:4326", 149 | maxPixels:1e10, 150 | fileFormat: 'GEOTIFF' 151 | }) 152 | -------------------------------------------------------------------------------- /gee_misc.txt: -------------------------------------------------------------------------------- 1 | // Function to get todays date in the form for an export 2 | exports.todaysDate = function(sep){ 3 | var today = new Date() 4 | var dd = today.getDate() 5 | var mm = today.getMonth()+1; //January is 0! 6 | var yyyy = today.getFullYear() 7 | 8 | if(dd<10) { 9 | dd = '0'+dd; 10 | } 11 | 12 | if(mm<10) { 13 | mm = '0'+mm; 14 | } 15 | 16 | today = mm + sep + dd + sep + yyyy; 17 | return today 18 | } 19 | 20 | // Function to get current time in the form for an export 21 | exports.time = function(sep){ 22 | var today = new Date() 23 | var hh = today.getHours() 24 | var mm = today.getMinutes() 25 | 26 | if(hh<10) { 27 | dd = '0'+dd} 28 | 29 | if(mm<10) { 30 | mm = '0'+mm} 31 | 32 | return hh + sep + mm 33 | } 34 | 35 | // Series of functions to get overlapping watersheds of a geometry 36 | exports.get_watersheds_level5 = function (dfoFeature) { 37 | var basins = ee.FeatureCollection('ft:1IHRHUiWkgPXOzwNweeM89CzPYSfokjLlz7_0OTQl') 38 | return basins.filterBounds(dfoFeature) 39 | } 40 | 41 | exports.get_watersheds_level4 = function (dfoFeature) { 42 | var basins = ee.FeatureCollection('ft:1JRW4YKfVTZKLAH4x4JRsggsHZoXRRUQKTIOYgJOW') 43 | return basins.filterBounds(dfoFeature) 44 | } 45 | 46 | exports.get_watersheds_level3 = function (dfoFeature) { 47 | var basins = ee.FeatureCollection('ft:1asIZ7d9NqNIubAp2dNMvnAfRMd-9ih7kjcLnIzv6') 48 | return basins.filterBounds(dfoFeature) 49 | } 50 | 51 | // Functions to get geographic areas that are not represented in the HydroSheds 52 | // dataset but present in DFO database. 53 | exports.get_islands = function(dfo_feature) { 54 | var islands = ee.FeatureCollection('ft:14BijFeJ0MiV1CeP7FBst8P4Kf1Se0HK5Sfh78hJB') 55 | return islands.filterBounds(dfo_feature) 56 | } 57 | 58 | exports.get_american_somoa = function(dfo_feature) { 59 | var asm = ee.FeatureCollection('ft:1C79v82bd1QfIsdGfDFOo2sz2XIHJCiVnXWXBeX0_') 60 | return asm.filterBounds(dfo_feature) 61 | } 62 | 63 | 64 | // Create a list of days of year (1 day steps) 65 | exports.getDateList = function(year_start, year_end, step){ 66 | var doy = ee.List.sequence(1, 365, step) 67 | var years = ee.List.sequence(year_start, year_end) 68 | 69 | // Convert the years and doys to a list of dates to map over 70 | var dates = years.map(function(y) { 71 | return doy.map(function(d) { 72 | var date = ee.String(y).slice(0, 4).cat('-').cat(ee.String(d).slice(0, -2)) 73 | return ee.Date.parse('y-D', date) 74 | }) 75 | }).flatten() 76 | return dates 77 | } 78 | -------------------------------------------------------------------------------- /gee_sampleFrameLandsat.txt: -------------------------------------------------------------------------------- 1 | // QC Database 2 | var gfd_qc = ee.ImageCollection("projects/global-flood-db/3day_std_qc"); 3 | 4 | // Functions used to collect a mosaic of all Landsat images over a specified area 5 | // and within a certain number of days from the maximum flood extent image. 6 | var getLandsat = function(id, gfd, cloudCover, deltaDays){ 7 | 8 | // Prep the Landsat data by filtering flood dates 9 | // LANDSAT 8 - Filter Landsat 8 OLI Products by Flood Events Boundaries and Dates 10 | function filterFloodEventsL8 (roi, filterDate){ 11 | var imageCollection = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR").filterBounds(roi) 12 | .filterDate(filterDate, filterDate.advance(deltaDays, "day")) 13 | .filterMetadata("CLOUD_COVER", "less_than", cloudCover) 14 | return imageCollection 15 | } 16 | 17 | // LANDSAT 7 - Filter Landsat 7 ETM Products by Flood Events Boundaries and Dates 18 | function filterFloodEventsL7 (roi, filterDate){ 19 | var imageCollection = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR").filterBounds(roi) 20 | .filterDate(filterDate, filterDate.advance(deltaDays, "day")) 21 | .filterMetadata("CLOUD_COVER", "less_than", cloudCover) 22 | return imageCollection 23 | } 24 | 25 | // LANDSAT 5 - Filter Landsat 5 TM Products by Flood Events Boundaries and Dates 26 | function filterFloodEventsL5 (roi, filterDate){ 27 | var imageCollection = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR").filterBounds(roi) 28 | .filterDate(filterDate, filterDate.advance(deltaDays, "day")) 29 | .filterMetadata("CLOUD_COVER", "less_than", cloudCover) 30 | return imageCollection 31 | } 32 | 33 | // Load in DFO Fusion Table and filter for the floods bounds 34 | var dfoEvents = ee.FeatureCollection("projects/global-flood-db/dfo-polygons/dec-03-2019"); 35 | var dfoGeom = dfoEvents.filterMetadata('ID', 'equals', id).first().geometry() 36 | 37 | // Load in JRC product and prep waterMask 38 | var jrc = ee.Image("JRC/GSW1_0/GlobalSurfaceWater").clip(dfoGeom) 39 | var waterMask = jrc.select('transition').eq(1).unmask().neq(1) 40 | 41 | // Prep flood img 42 | var img = ee.Image(gfd.filterMetadata("Index", "equals", id).first()).select("flooded").clip(dfoGeom) 43 | var imgMasked = img.updateMask(waterMask) 44 | var ft = imgMasked.updateMask(img).reduceToVectors({geometry:dfoGeom,scale:10000,maxPixels:10e13}) 45 | .map(function(f){return f.simplify(10000)}) 46 | 47 | // Variables for filter landsat series of functions 48 | var maxDate = ee.Date(img.get('maxImgDate')) 49 | 50 | // Filter for Landsat 8 images 51 | var l8 = ee.ImageCollection(filterFloodEventsL8(ft, maxDate).select(["B1", "B2", "B3", "B4", "B5", "B7", "pixel_qa"])); 52 | 53 | // Filter for Landsat 7 Images 54 | var l7 = filterFloodEventsL7(ft, maxDate).select(["B1", "B2", "B3", "B4", "B5", "B7", "pixel_qa"]); 55 | 56 | // Filter for Landsat 5 images 57 | var l5 = filterFloodEventsL5(ft, maxDate).select(["B1", "B2", "B3", "B4", "B5", "B7", "pixel_qa"]); 58 | 59 | return ee.ImageCollection(l8).merge(l7).merge(l5); 60 | }; 61 | 62 | 63 | // Dials for the landsat collection. cc= cloud cover; delta = number of days after max extent 64 | // to collect landsat 65 | var cc =20 66 | var delta =1 67 | 68 | function getSampleFrame(img){ 69 | 70 | // Retrieve Landsat Images 71 | var id = img.get('Index') 72 | var landsat = getLandsat(id, gfd_qc, cc, delta); 73 | 74 | // Get sizes of land 75 | var l_size = landsat.size() 76 | var l5_size = landsat.filterMetadata('SATELLITE', 'equals', 'LANDSAT_5').size() 77 | var l7_size = landsat.filterMetadata('SATELLITE', 'equals', 'LANDSAT_7').size() 78 | var l8_size = landsat.filterMetadata('SATELLITE', 'equals', 'LANDSAT_8').size() 79 | 80 | // Get centroid of flood 81 | var center = img.geometry().centroid() 82 | var centerCoords = center.coordinates() 83 | var x = centerCoords.get(0) 84 | var y = centerCoords.get(1) 85 | 86 | // Put it all in a dictionary 87 | var lndst_dict = {'DFO_ID': id, 'CLOUD_COVER':cc, 'DELTA':delta, 'LANDSAT_5':l5_size, 88 | 'LANDSAT_7':l7_size, 'LANDSAT_8':l8_size, 'LANDSAT_ALL':l_size, 89 | 'X':x, 'Y':y 90 | } 91 | return ee.Feature(null, lndst_dict) 92 | } 93 | 94 | var sampleFrame = ee.FeatureCollection(gfd_qc.map(getSampleFrame)) 95 | 96 | Export.table.toDrive({ 97 | collection: sampleFrame, 98 | description: 'sampleFrame_CC'+cc+'_D'+delta, 99 | fileNamePrefix: 'sampleFrame_CC'+cc+'_D'+delta+'_051618', 100 | fileFormat: 'CSV' 101 | }) 102 | -------------------------------------------------------------------------------- /gee_validationGUI.txt: -------------------------------------------------------------------------------- 1 | /*The purpose of this script is to create an easy to use interface for an analyst to create and assess random points 2 | through aerial interpretation for determining the accuracy of flood maps. Run the script, and select the first point from 3 | the dropdown menu. It will zoom you in to a yellow point; the first point in the assessment. Use the available layers (RGB, CIR, 4 | NDVI, MNDWI) to determine if the point is dry or flooded. There are two feature collections in the "Geometry Imports" section; one for 5 | dry and one for flood. Select the point that corresponds to the state of the point (dry or flooded) and draw a point on the yellow 6 | dot. There is a layer called "GCP Layer Circle" that is a 50-meter buffer on each point. In order for the final assessment to work, 7 | each drawn point much fall within that circle to retain important ID and geographic information. Go through all of the points and 8 | draw a dry of flooded point. When you're done you can rerun the script and a confusion matrix and overall accuracy will be printed 9 | in the Console tab. If you are doing this with three people, uncomment lines 210-219 and export your table. Collect your table 10 | and the table of the others doing the assessment and use the random number to match up the points. If for example three people 11 | total are doing the assessment, make a new column that represents majority of the three values (i.e. 0, 0, 1 becomes 0). 12 | Upload this new table to EE using a fusion table and substitute it in line 244 */ 13 | 14 | //--------------------------------------------------------------------------------- 15 | // Load required scripts 16 | var landsatTools = require("users/jonathanasullivan/gee-dfo-research-award:utils/landsat_v3"); 17 | var misc = require("users/jonathanasullivan/gee-dfo-research-award:utils/misc"); 18 | 19 | // Empty feature collections for validation points to be stored 20 | var water = /* color: #10a8d6 */ee.FeatureCollection([]), 21 | dry = /* color: #ff8246 */ee.FeatureCollection([]), 22 | na = /* color: #000000 */ee.FeatureCollection([]); 23 | 24 | var app = {}; 25 | 26 | // Create UI Panels // 27 | app.createPanels = function() { 28 | /* Introduces the tool. */ 29 | app.intro = { 30 | panel: ui.Panel([ 31 | ui.Label({ 32 | value: 'GFD Validation GUI', 33 | style: {fontWeight: 'bold', fontSize: '24px', margin: '10px 5px'} 34 | }), 35 | ui.Label('This app allows you to select flood events from the Global'+ 36 | ' Flood Database and provides Landsat-8, 7, & 5 imagery to'+ 37 | ' assess accuracy across a stratified random sample') 38 | ]) 39 | }; 40 | 41 | // Textbox for analyst to enter initials 42 | app.analyst = { 43 | initials: ui.Textbox(), 44 | applyButton: ui.Button('Enter', app.setInitials) 45 | }; 46 | 47 | app.analyst.panel = ui.Panel({ 48 | widgets: [ 49 | ui.Label('1) Enter initials', {fontWeight: 'bold'}), 50 | ui.Label('Analyst initials', app.HELPER_TEXT_STYLE), app.analyst.initials, 51 | ui.Panel([ 52 | app.analyst.applyButton 53 | ], ui.Panel.Layout.flow('vertical')) 54 | ], 55 | style: app.SECTION_STYLE 56 | }); 57 | 58 | /* Flood Filter - Returns DFO Flood */ 59 | app.floodFilter = { 60 | dfoID: ui.Textbox('4-digit dfo id'), 61 | applyButton: ui.Button('Get flood event', app.loadFlood), 62 | loadingLabel: ui.Label({ 63 | value: 'Loading...', 64 | style: {stretch: 'vertical', color: 'gray', shown: false} 65 | }), 66 | }; 67 | 68 | /* The panel for the flood widget. */ 69 | app.floodFilter.panel = ui.Panel({ 70 | widgets: [ 71 | ui.Label('2) Enter DFO Index', {fontWeight: 'bold'}), 72 | ui.Label('DFO Index', app.HELPER_TEXT_STYLE), app.floodFilter.dfoID, 73 | ui.Panel([ 74 | app.floodFilter.applyButton, 75 | app.floodFilter.loadingLabel 76 | ], ui.Panel.Layout.flow('horizontal')) 77 | ], 78 | style: app.SECTION_STYLE 79 | }); 80 | 81 | /* Widget to pick points from sample */ 82 | app.pointPicker = { 83 | select: ui.Select({ 84 | items: ['0','1','2','3','4','5','6','7','8','9', 85 | '10','11','12','13','14','15','16','17','18','19', 86 | '20','21','22','23','24','25','26','27','28','29', 87 | '30','31','32','33','34','35','36','37','38','39', 88 | '40','41','42','43','44','45','46','47','48','49', 89 | '50','51','52','53','54','55','56','57','58','59', 90 | '60','61','62','63','64','65','66','67','68','69', 91 | '70','71','72','73','74','75','76','77','78','79', 92 | '80','81','82','83','84','85','86','87','88','89', 93 | '90','91','92','93','94','95','96','97','98','99', 94 | '100','101','102','103','104','105','106','107','108','109', 95 | '110','111','112','113','114','115','116','117','118','119', 96 | '120','121','122','123','124','125','126','127','128','129', 97 | '130','131','132','133','134','135','136','137','138','139', 98 | '140','141','142','143','144','145','146','147','148','149', 99 | '150','151','152','153','154','155','156','157','158','159', 100 | '160','161','162','163','164','165','166','167','168','169', 101 | '170','171','172','173','174','175','176','177','178','179', 102 | '180','181','182','183','184','185','186','187','188','189', 103 | '190','191','192','193','194','195','196','197','198','199', 104 | '200','201','202','203','204','205','206','207','208','209', 105 | '210','211','212','213','214','215','216','217','218','219', 106 | '220','221','222','223','224','225','226','227','228','229', 107 | '230','231','232','233','234','235','236','237','238','239', 108 | '240','241','242','243','244','245','246','247','248','249'], 109 | placeholder: 'Select a sample point', 110 | onChange: app.zoomToPoint 111 | }) 112 | } 113 | 114 | app.pointPicker.panel = ui.Panel({ 115 | widgets:[ 116 | ui.Label('3) Select a sample point', {fontWeight: 'bold'}), 117 | ui.Panel([app.pointPicker.select 118 | ], ui.Panel.Layout.flow('vertical')) 119 | ], 120 | style: app.SECTION_STYLE 121 | }); 122 | 123 | /* The export section. */ 124 | app.export = { 125 | button: ui.Button({ 126 | label: 'Export Validation Points', 127 | onClick: app.exportPoints}), 128 | error: ui.Label({style: app.ERROR_TEXT_STYLE}) 129 | }; 130 | 131 | /* The panel for the export section with corresponding widgets. */ 132 | app.export.panel = ui.Panel({ 133 | widgets: [ 134 | ui.Label('4) Start an export', {fontWeight: 'bold'}), 135 | app.export.button, 136 | app.export.error 137 | ], 138 | style: app.SECTION_STYLE 139 | }); 140 | }; 141 | 142 | 143 | /** Creates the app helper functions. */ 144 | app.createHelpers = function() { 145 | 146 | app.setInitials = function() { 147 | print("Analyst initial recorded") 148 | }; 149 | 150 | // function to collect images over flood area and create sample 151 | app.loadFlood = function() { 152 | Map.clear(); 153 | 154 | // Set Filter Variables 155 | var dfoID = app.floodFilter.dfoID.getValue() 156 | if (dfoID) dfoID = ee.Number.parse(dfoID) 157 | 158 | // Add DFO Polygon to Map 159 | var dfoEvents = ee.FeatureCollection("ft:1HBs5-y8tXhYMQd5rtdjCqejpJW2p0FLBEamM9vaW"); 160 | var ft = ee.Feature(dfoEvents.filterMetadata('ID','equals',dfoID).first()).geometry() 161 | 162 | // Paint the edges with different colors, display. 163 | var empty = ee.Image().byte(); 164 | var outline = empty.paint({ 165 | featureCollection: ft, 166 | color: "#993404", 167 | width: 2 168 | }); 169 | Map.addLayer(outline, {}, 'dfo polygon') 170 | 171 | // Select flood image and geometry 172 | var gfdFloodImg = ee.Image(app.GFD.filterMetadata("Index", "equals", dfoID).first()) 173 | var dfoFeature = ee.Feature(app.DFO_DB.filterMetadata("ID", "equals", dfoID).first()) 174 | 175 | // Load the Landsat images for a given flood and mosaic them together 176 | var landsat = landsatTools.getLandsat(dfoID, app.GFD, 20, 1) 177 | var landsatMasked = landsatTools.maskClouds(landsat) 178 | var validationImg = landsatMasked.mosaic() 179 | 180 | //Create a NDVI and MNDWI layer from the mosaic 181 | var ndvi = validationImg.normalizedDifference(['B4','B3']).select(['nd'],['NDVI']) 182 | var mndwi = validationImg.normalizedDifference(['B2', 'B4']).select(['nd'],['MNDWI']) 183 | var image = validationImg.addBands(ndvi).addBands(mndwi) 184 | 185 | // Define region for sampling 186 | var landsatGeo = landsat.union().geometry() 187 | var geo = landsatGeo.intersection(ft) 188 | 189 | // Create strata for sampling and sample sizes (0=dry; perm water =1; flood =2) 190 | var waterImg = ee.Image(app.MOD44W.select('water_mask').first()).clip(gfdFloodImg.geometry()) 191 | var strata = gfdFloodImg.add(waterImg.multiply(10)).remap([0,1,10,11],[0,2,1,1]).select(['remapped'],['flooded']) 192 | var mask = image.select('NDVI').mask() 193 | var strataMasked = strata.updateMask(mask).clip(geo.bounds()) 194 | 195 | // Add stuff to the Map 196 | var visOption = app.VIS_OPTIONS 197 | Map.centerObject(geo, 6) 198 | Map.addLayer(image, visOption.natural, 'natural', false) 199 | Map.addLayer(image, visOption.nir, 'nir') 200 | Map.addLayer(image, visOption.ndvi, 'ndvi', false) 201 | Map.addLayer(image, visOption.mndwi, 'ndwi', false) 202 | // Map.addLayer(mask, {min:0, max:1}, 'mask') 203 | // Map.addLayer(strataMasked, {min:0,max:2,palette:['#fdb462','#023858','#a6bddb']}, 'strata') 204 | 205 | /* Create stratified sample */ 206 | var sampleSize = 250 207 | var strata01 = ee.Number(sampleSize*0.25).int() 208 | var strata2 = ee.Number(sampleSize*0.50).int() 209 | var gcps = (strataMasked.select('flooded').addBands(ee.Image.pixelLonLat()) 210 | .stratifiedSample(sampleSize, 'flooded', geo, 250, null, 10, [0,1,2], [strata01,strata01,strata2], true)) // strata sample procedure 211 | .map(function(s) { 212 | var lat = s.get('latitude') 213 | var lon = s.get('longitude') 214 | var strata = s.get('flooded') 215 | return ee.Feature(ee.Geometry.Point([lon, lat]), 216 | {'strata': strata, 217 | id: s.id()}); 218 | }).randomColumn().sort('id'); 219 | print('Sample Size',gcps.aggregate_histogram('strata')) 220 | 221 | // Convert the GCPS to a bounding box that can be used to assess percentage water within each pixels. 222 | // This region will also be used later to ensure points match up when multiple people are doing the 223 | // same assessment 224 | var scale = gfdFloodImg.projection().nominalScale() 225 | function getBoundingBox (f){ 226 | var buff = f.geometry().buffer(scale.divide(2)) 227 | var box = buff.bounds() 228 | return ee.Feature(box).copyProperties(f) 229 | } 230 | var boxes = gcps.map(getBoundingBox) 231 | 232 | // Add Landsat data to the tarets 233 | var targets = image.select('B1','B2','B3','B4','B5','B7','NDVI','MNDWI').reduceRegions({ 234 | collection: boxes, 235 | reducer: ee.Reducer.mean(), 236 | scale: 30 237 | }) 238 | 239 | // Save important data to active dictionary 240 | app.DATA.set('gcps', gcps) 241 | app.DATA.set('targets', targets) 242 | 243 | // Paint the edges with different colors, display. 244 | var empty = ee.Image().byte(); 245 | var boxOutlines = empty.paint({ 246 | featureCollection: boxes, 247 | color: "#993404", 248 | width: 2 249 | }); 250 | Map.addLayer(gcps, {color: 'black'}, 'sample points') 251 | Map.addLayer(boxOutlines, {palette: "#f0f0f0"}, 'target') 252 | }; 253 | 254 | // Function to zoom to selected point 255 | app.zoomToPoint = function() { 256 | var pointId = app.pointPicker.select.getValue(); 257 | if (pointId && app.DATA.get('gcps')){ 258 | // if an point id is found, zoom to point 259 | var gcps = app.DATA.get('gcps'); 260 | var point = gcps.filterMetadata('id', 'equals', pointId).first(); 261 | Map.centerObject(point, 14); 262 | } else { 263 | print("Load a flood event first") 264 | } 265 | }; 266 | 267 | // Function to export data 268 | app.exportPoints = function() { 269 | 270 | // Prep the collection to be exported 271 | var targets = app.DATA.get('targets') 272 | var valPoints = dry.merge(water.merge(na)) 273 | 274 | // Define a spatial filter as geometries that intersect. 275 | var spatialFilter = ee.Filter.intersects({ 276 | leftField: '.geo', 277 | rightField: '.geo', 278 | maxError: 1 279 | }); 280 | 281 | // Define a save all join. 282 | var saveAllJoin = ee.Join.saveAll({ 283 | matchesKey: 'validation' 284 | }); 285 | 286 | // Apply the join. 287 | var intersect = saveAllJoin.apply(targets, valPoints, spatialFilter) 288 | 289 | // Determine if all points were sampled 290 | var sizeDry = dry.size() 291 | var sizeWater = water.size() 292 | var sizeNA = na.size() 293 | var n = sizeDry.add(sizeWater).add(sizeNA) 294 | 295 | if (n.getInfo() >= 250) { 296 | 297 | // Prep variables for file name 298 | var dateProp = misc.todaysDate('/') 299 | var dateFile = misc.todaysDate('_') 300 | var timeFile = misc.time(':') 301 | var dfoID = app.floodFilter.dfoID.getValue() 302 | var analyst = app.analyst.initials.getValue() 303 | var fileName = "DFO_" + dfoID + "_" + analyst + "_" + dateFile + "_" + timeFile 304 | 305 | // Prep export table 306 | var validation = intersect.map(function(p){ 307 | // Get class data from validation point 308 | var valPoint = ee.Feature(ee.List(p.get('validation')).get(0)) 309 | var valClass = valPoint.get('class') 310 | 311 | //Get X,Y data from point 312 | var coords = valPoint.geometry().coordinates() 313 | var x = coords.get(0) 314 | var y = coords.get(1) 315 | return p.setMulti({'dfoID':dfoID, 'analyst':analyst, 'date':dateProp, 316 | 'validation': valClass, 'lat':y, 'lon':x}) 317 | }); 318 | print(validation) 319 | 320 | 321 | // Export the image to Drive. 322 | Export.table.toCloudStorage({ 323 | collection: validation, 324 | description: 'Validation_Export_DFO_' + dfoID, 325 | bucket: 'gfd_accuracy', 326 | fileNamePrefix: fileName, 327 | fileFormat: 'CSV' 328 | }); 329 | } 330 | else { 331 | var validatedList = ee.List(intersect.reduceColumns(ee.Reducer.toList(), ['id']) 332 | .get('list')) 333 | .map(function(n){ 334 | return ee.Number.parse(n); 335 | }); 336 | var missing = ee.List.sequence(0,250,1).removeAll(validatedList); 337 | missing.evaluate(function(m){ 338 | var l = ee.List(m) 339 | var s = ee.String(l.length()); 340 | app.export.error.setValue('ERROR: Cannot export. Missing '+s.getInfo()+' points: '+ l.getInfo()) 341 | }) 342 | } 343 | }; 344 | }; 345 | 346 | /** Creates the app constants. */ 347 | app.createConstants = function() { 348 | app.GFD = ee.ImageCollection("projects/global-flood-db/3day_std_qc") 349 | app.DFO_DB = ee.FeatureCollection("ft:1HBs5-y8tXhYMQd5rtdjCqejpJW2p0FLBEamM9vaW") 350 | app.MOD44W = ee.ImageCollection('MODIS/006/MOD44W') 351 | app.SECTION_STYLE = {margin: '20px 0 0 0'}; 352 | app.HELPER_TEXT_STYLE = { 353 | margin: '8px 0 -3px 8px', 354 | fontSize: '12px', 355 | color: 'gray' 356 | }; 357 | app.ERROR_TEXT_STYLE = { 358 | margin: '5px 0 20px 0', 359 | fontSize: '14px', 360 | color: 'red' 361 | } 362 | app.VIS_OPTIONS = { 363 | natural: {bands: ['B3', 'B2', 'B1'], min:100, max:3500}, 364 | nir: {bands: ['B4', 'B3', 'B2'], min:100, max:3500}, 365 | ndvi: {min: 0.1, max: 0.2, palette: ['#a50026','#d73027','#f46d43', 366 | '#fdae61','#fee090','#ffffbf', 367 | '#e0f3f8','#abd9e9','#74add1', 368 | '#4575b4','#313695'], bands: ['NDVI']}, 369 | mndwi: {min: -0.5, max: -0.2, palette: ['#a50026','#d73027','#f46d43', 370 | '#fdae61','#fee08b','#ffffbf', 371 | '#d9ef8b','#a6d96a','#66bd63', 372 | '#1a9850','#006837'], bands: ['MNDWI']} 373 | 374 | }; 375 | }; 376 | 377 | /** Create a live dictionary to store important results. */ 378 | app.liveData = function() { 379 | app.DATA = ui.data.ActiveDictionary(); 380 | }; 381 | 382 | /** Creates the application interface. */ 383 | app.boot = function() { 384 | app.liveData(); 385 | app.createConstants(); 386 | app.createHelpers(); 387 | app.createPanels(); 388 | var main = ui.Panel({ 389 | widgets: [ 390 | app.intro.panel, 391 | app.analyst.panel, 392 | app.floodFilter.panel, 393 | app.pointPicker.panel, 394 | app.export.panel 395 | ], 396 | style: {width: '320px', padding: '8px'} 397 | }); 398 | ui.root.insert(0, main); 399 | }; 400 | 401 | app.boot(); 402 | -------------------------------------------------------------------------------- /main_floodmechanism.txt: -------------------------------------------------------------------------------- 1 | // Imports 2 | var gfd = ee.ImageCollection("projects/global-flood-db/gfd_v3"), 3 | ghsl_pop = ee.ImageCollection("JRC/GHSL/P2016/POP_GPW_GLOBE_V1"), 4 | ghsl_settle = ee.ImageCollection("JRC/GHSL/P2016/SMOD_POP_GLOBE_V1"), 5 | jrc = ee.Image("JRC/GSW1_1/GlobalSurfaceWater"), 6 | mod44w = ee.Image("MODIS/MOD44W/MOD44W_005_2000_02_24") 7 | cause_table = ee.FeatureCollection("projects/global-flood-db/NEWsupplementarytable6_cd2"); 8 | 9 | 10 | // Table to add DFO event cause (ie. heacy rain, dam break, etc.) 11 | // Select which types of floods to aggregate (Dam; Heavy rain; Snowmelt, Ice, Rain; Tropical Storm, Surge) 12 | var cause_filter = "Tropical Storm, Surge" 13 | 14 | // STEP 1 - Prep permanent water layers & masks 15 | var gfd_first = ee.Image(gfd.first()) 16 | var scale_gfd = gfd_first.projection().nominalScale() 17 | var crs_gfd = gfd_first.projection().crs() 18 | 19 | // JRC Mask 20 | var jrc_250m = jrc.select('transition').eq(1).unmask() 21 | .reproject({crs:crs_gfd, 22 | scale:scale_gfd}) 23 | var jrc_250m_mask = jrc_250m.neq(1) 24 | 25 | // MOD44W Mask 26 | var mod44w_mask = ee.Image(mod44w.select('water_mask')).eq(0) 27 | Map.addLayer(jrc_250m_mask, {}, 'JRC', false) 28 | Map.addLayer(mod44w_mask, {}, 'MOD44W', false) 29 | 30 | // STEP 2 - Clean up GFD 31 | function maskPermWater(img){ 32 | var all_water = img.select("flooded") 33 | var water_mask = jrc_250m_mask 34 | return img.updateMask(water_mask) 35 | } 36 | 37 | function filterIsoPix (img){ 38 | 39 | // Calculate the number of connected pixels 40 | var size = img.select("flooded") 41 | .selfMask() 42 | .int() 43 | .connectedPixelCount(2, false) 44 | 45 | return size.updateMask(size.gte(2)) 46 | .multiply(0) 47 | .add(1) 48 | .reproject('EPSG:4326', null, img.projection().nominalScale()).copyProperties(img)} 49 | 50 | 51 | function add_cause(img){ 52 | var dfo_id = img.get("id"); 53 | var event_feature = cause_table.filterMetadata("dfo_event_id", "equals", dfo_id).first(); 54 | var dfo_cause = event_feature.get("dfo_cause"); 55 | return img.set({"dfo_cause": dfo_cause}) 56 | } 57 | 58 | var gfd_flood = gfd.map(maskPermWater) 59 | gfd_flood = gfd_flood.map(add_cause) 60 | var gfd_cleaned = gfd_flood.map(filterIsoPix) 61 | gfd_cleaned = gfd_cleaned.filterMetadata("dfo_cause", "equals", cause_filter); 62 | print("gfd_cleaned", gfd_cleaned) 63 | 64 | // STEP 3 - Sum entire GFD collection images 65 | var gfd_dirty_sum = gfd_flood.select('flooded').sum().selfMask() 66 | var gfd_cleaned_sum = gfd_cleaned.select('flooded').sum().selfMask() 67 | 68 | var flood_palette = ['#fff7fb','#ece7f2','#d0d1e6','#a6bddb','#74a9cf', 69 | '#3690c0','#0570b0','#045a8d','#023858'] 70 | Map.addLayer(gfd_dirty_sum, {min:1,max:9,palette:flood_palette}, 'GFD Dirty') 71 | Map.addLayer(gfd_cleaned_sum, {min:1,max:9,palette:flood_palette}, 'GFD Clean') 72 | 73 | // STEP 4 - Calculate population change from 2000 to 2015 using GHSL 74 | var ghsl_2000 = ee.Image(ghsl_pop.filterMetadata('system:index','equals','2000').first()) 75 | var ghsl_2015 = ee.Image(ghsl_pop.filterMetadata('system:index','equals','2015').first()) 76 | var ghsl_pop_diff = ghsl_2015.subtract(ghsl_2000) 77 | 78 | // Reproject GHSL dataset & mask 79 | var ghsl_2000_reproj = ghsl_2000.resample('bilinear').reproject(crs_gfd, null, scale_gfd) 80 | var ghsl_pdiff_reproj = ghsl_pop_diff.resample('bilinear').reproject(crs_gfd, null, scale_gfd) 81 | 82 | var ghsl_pdiff_mask = ghsl_pdiff_reproj.neq(0) 83 | var ghsl_pdiff_masked = ghsl_pdiff_reproj.updateMask(ghsl_pdiff_mask) 84 | 85 | var ghsl_2000_masked = ghsl_2000_reproj.selfMask() 86 | 87 | var pop_palette = ['#053061','#2166ac','#4393c3','#92c5de','#d1e5f0', 88 | '#f7f7f7','#fddbc7','#f4a582','#d6604d','#b2182b','#67001f'] 89 | Map.addLayer(ghsl_2000, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop 2000 - ESPG 54009', false) 90 | Map.addLayer(ghsl_2000_reproj, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop 2000 - ESPG 4326', false) 91 | Map.addLayer(ghsl_2000_masked, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop 2000 Masked - ESPG 4326', false) 92 | Map.addLayer(ghsl_pop_diff, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop Change - EPSG:54009', false) 93 | Map.addLayer(ghsl_pdiff_reproj, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop Change - ESPG 4326', false) 94 | Map.addLayer(ghsl_pdiff_masked, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop Change Masked - ESPG 4326', false) 95 | 96 | // STEP 5 - Create Raster of pop change in flood plain areas 97 | var gfd_dirty_floodplain = gfd_dirty_sum.gte(1) 98 | var gfd_dirty_popchange = gfd_dirty_floodplain.multiply(ghsl_pdiff_reproj) 99 | 100 | var gfd_clean_floodplain = gfd_cleaned_sum.gte(1) 101 | var gfd_clean_popchange = gfd_clean_floodplain.multiply(ghsl_pdiff_reproj) 102 | var lossmask= (gfd_clean_popchange.lte(1).multiply(gfd_clean_popchange).neq(0)) 103 | Map.addLayer(gfd_dirty_popchange, {min:-100,max:100,palette:pop_palette}, 'GFD Dirty Pop Change') 104 | Map.addLayer(gfd_clean_popchange, {min:-100,max:100,palette:pop_palette}, 'GFD Clean Pop Change') 105 | Map.addLayer(gfd_clean_popchange.lte(1).multiply(gfd_clean_popchange).updateMask(lossmask), {min:-400,max:0,palette:pop_palette}, 'GFD Dirty Pop Loss') 106 | 107 | // Export.image.toDrive({ 108 | // image: gfd_clean_popchange, 109 | // description:'hotspot_jrc_20190802', 110 | // folder: 'hotspot', 111 | // fileNamePrefix: 'hotspot_jrc_20190802', 112 | // scale: scale_gfd, 113 | // crs: crs_gfd, 114 | // fileFormat: 'GEOTIFF' 115 | // }) 116 | 117 | // STEP 6 - Summarize populatoin change in flood plains for countries & watersheds 118 | // var countries = ee.FeatureCollection('ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw') 119 | var countries = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017") 120 | var basins_l4 = ee.FeatureCollection('ft:1JRW4YKfVTZKLAH4x4JRsggsHZoXRRUQKTIOYgJOW') 121 | var basins_l5 = ee.FeatureCollection('ft:1IHRHUiWkgPXOzwNweeM89CzPYSfokjLlz7_0OTQl') 122 | print(countries) 123 | 124 | // STEP 7 - Prep GHSL Settlement Layer 125 | var ghsl_settle_2015 = ee.Image(ghsl_settle.filterMetadata('system:index','equals','2015').first()) 126 | var rural = ghsl_settle_2015.select('smod_code').lte(1) 127 | var semiurban = ghsl_settle_2015.select('smod_code').eq(2) 128 | var urban = ghsl_settle_2015.select('smod_code').eq(3) 129 | 130 | 131 | // STEP 8 132 | function hotspotByPoly(ft){ 133 | var gfd_ft = gfd_cleaned_sum.clip(ft.bounds()) 134 | var map_scale = gfd_ft.projection().nominalScale() 135 | 136 | var pop_2000_ft = ghsl_2000_masked.clip(ft.bounds()) 137 | var pop_diff_ft = ghsl_pdiff_masked.clip(ft.bounds()) 138 | var pop_scale = pop_diff_ft.projection().nominalScale() 139 | 140 | var pop_change_all_rural = pop_diff_ft.updateMask(rural).reduceRegion({ 141 | reducer: ee.Reducer.sum(), 142 | geometry: ft.geometry(), 143 | scale: pop_scale, 144 | maxPixels: 1e10}) 145 | 146 | var pop_change_all_semiurban = pop_diff_ft.updateMask(semiurban).reduceRegion({ 147 | reducer: ee.Reducer.sum(), 148 | geometry: ft.geometry(), 149 | scale: pop_scale, 150 | maxPixels: 1e10}) 151 | 152 | var pop_change_all_urban = pop_diff_ft.updateMask(urban).reduceRegion({ 153 | reducer: ee.Reducer.sum(), 154 | geometry: ft.geometry(), 155 | scale: pop_scale, 156 | maxPixels: 1e10}) 157 | 158 | var pop_diff_flood = pop_diff_ft.updateMask(gfd_ft.gte(1)) 159 | var pop_change_flood_rural = pop_diff_flood.updateMask(rural).reduceRegion({ 160 | reducer: ee.Reducer.sum(), 161 | geometry: ft.geometry(), 162 | scale: pop_scale, 163 | maxPixels: 1e10}) 164 | 165 | var pop_change_flood_semiurban = pop_diff_flood.updateMask(semiurban).reduceRegion({ 166 | reducer: ee.Reducer.sum(), 167 | geometry: ft.geometry(), 168 | scale: pop_scale, 169 | maxPixels: 1e10}) 170 | 171 | var pop_change_flood_urban = pop_diff_flood.updateMask(urban).reduceRegion({ 172 | reducer: ee.Reducer.sum(), 173 | geometry: ft.geometry(), 174 | scale: pop_scale, 175 | maxPixels: 1e10}) 176 | 177 | var pop_change_nonflood_rural = pop_change_all_rural.getNumber('population_count') 178 | .subtract(pop_change_flood_rural.getNumber('population_count')) 179 | 180 | var pop_change_nonflood_semiurban = pop_change_all_semiurban.getNumber('population_count') 181 | .subtract(pop_change_flood_semiurban.getNumber('population_count')) 182 | 183 | var pop_change_nonflood_urban = pop_change_all_urban.getNumber('population_count') 184 | .subtract(pop_change_flood_urban.getNumber('population_count')) 185 | 186 | var pop_2000_all_rural = pop_2000_ft.updateMask(rural).reduceRegion({ 187 | reducer: ee.Reducer.sum(), 188 | geometry: ft.geometry(), 189 | scale: pop_scale, 190 | maxPixels: 1e10}) 191 | 192 | var pop_2000_all_semiurban = pop_2000_ft.updateMask(semiurban).reduceRegion({ 193 | reducer: ee.Reducer.sum(), 194 | geometry: ft.geometry(), 195 | scale: pop_scale, 196 | maxPixels: 1e10}) 197 | 198 | var pop_2000_all_urban = pop_2000_ft.updateMask(urban).reduceRegion({ 199 | reducer: ee.Reducer.sum(), 200 | geometry: ft.geometry(), 201 | scale: pop_scale, 202 | maxPixels: 1e10}) 203 | 204 | var pop_2000_flood_img = pop_2000_ft.updateMask(gfd_ft.gte(1)) 205 | var pop_2000_flood_rural = pop_2000_flood_img.updateMask(rural).reduceRegion({ 206 | reducer: ee.Reducer.sum(), 207 | geometry: ft.geometry(), 208 | scale: pop_scale, 209 | maxPixels: 1e10}) 210 | 211 | var pop_2000_flood_semiurban = pop_2000_flood_img.updateMask(semiurban).reduceRegion({ 212 | reducer: ee.Reducer.sum(), 213 | geometry: ft.geometry(), 214 | scale: pop_scale, 215 | maxPixels: 1e10}) 216 | 217 | var pop_2000_flood_urban = pop_2000_flood_img.updateMask(urban).reduceRegion({ 218 | reducer: ee.Reducer.sum(), 219 | geometry: ft.geometry(), 220 | scale: pop_scale, 221 | maxPixels: 1e10}) 222 | 223 | var pop_2000_nonflood_rural = pop_2000_all_rural.getNumber('population_count') 224 | .subtract(pop_2000_flood_rural.getNumber('population_count')) 225 | 226 | var pop_2000_nonflood_semiurban = pop_2000_all_semiurban.getNumber('population_count') 227 | .subtract(pop_2000_flood_semiurban.getNumber('population_count')) 228 | 229 | var pop_2000_nonflood_urban = pop_2000_all_urban.getNumber('population_count') 230 | .subtract(pop_2000_flood_urban.getNumber('population_count')) 231 | 232 | var pdelta_flood = pop_change_flood_rural.getNumber('population_count') 233 | .add(pop_change_flood_semiurban.getNumber('population_count') 234 | .add(pop_change_flood_urban.getNumber('population_count'))) 235 | var p2000_flood = pop_2000_flood_rural.getNumber('population_count') 236 | .add(pop_2000_flood_semiurban.getNumber('population_count') 237 | .add(pop_2000_flood_urban.getNumber('population_count'))) 238 | 239 | var pdelta_all = pop_change_all_rural.getNumber('population_count') 240 | .add(pop_change_all_semiurban.getNumber('population_count') 241 | .add(pop_change_all_urban.getNumber('population_count'))) 242 | var p2000_all = pop_2000_all_rural.getNumber('population_count') 243 | .add(pop_2000_all_semiurban.getNumber('population_count') 244 | .add(pop_2000_all_urban.getNumber('population_count'))) 245 | 246 | var rate_numerator = pdelta_flood.divide(p2000_flood) 247 | var rate_denominator = pdelta_all.divide(p2000_all) 248 | var rate = rate_numerator.divide(rate_denominator) 249 | 250 | // 1=rural; 2=semiurban; 3=urban 251 | // a = all; f = flood; nf = nonflood 252 | return ee.Feature(null, {// FPU Properties 253 | // "id":ft.get('id'), 254 | // "agric_val":ft.get('Agric_val'), 255 | // "assets_urb":ft.get('Assets_urb'), 256 | // "damage_urb":ft.get('Damage_urb'), 257 | // "gdp":ft.get('GDP'), 258 | // "fpu_pop":ft.get("Population"), 259 | 260 | // LSIB Properties 261 | 'region':ft.get('wld_rgn'), 262 | 'cc':ft.get('country_co'), 263 | 'country':ft.get('country_na'), 264 | 265 | "pdelt_a_1":pop_change_all_rural.getNumber('population_count'), 266 | "pdelt_f_1": pop_change_flood_rural.getNumber('population_count'), 267 | "pdelt_nf_1":pop_change_nonflood_rural, 268 | "p2000_a_1":pop_2000_all_rural.getNumber('population_count'), 269 | "p2000_f_1":pop_2000_flood_rural.getNumber('population_count'), 270 | "p2000_nf_1":pop_2000_nonflood_rural, 271 | 272 | "pdelt_a_2":pop_change_all_semiurban.getNumber('population_count'), 273 | "pdelt_f_2": pop_change_flood_semiurban.getNumber('population_count'), 274 | "pdelt_nf_2":pop_change_nonflood_semiurban, 275 | "p2000_a_2":pop_2000_all_semiurban.getNumber('population_count'), 276 | "p2000_f_2":pop_2000_flood_semiurban.getNumber('population_count'), 277 | "p2000_nf_2":pop_2000_nonflood_semiurban, 278 | 279 | "pdelt_a_3":pop_change_all_urban.getNumber('population_count'), 280 | "pdelt_f_3": pop_change_flood_urban.getNumber('population_count'), 281 | "pdelt_nf_3":pop_change_nonflood_urban, 282 | "p2000_a_3":pop_2000_all_urban.getNumber('population_count'), 283 | "p2000_f_3":pop_2000_flood_urban.getNumber('population_count'), 284 | "p2000_nf_3":pop_2000_nonflood_urban, 285 | 286 | "pdelt_f": pdelta_flood, 287 | "p2000_f": p2000_flood, 288 | "pdelt": pdelta_all, 289 | "p2000": p2000_all, 290 | 291 | "fpop_rate": rate 292 | }) 293 | } 294 | 295 | var hotspot_countries = countries.map(hotspotByPoly) 296 | 297 | Export.table.toDrive({ 298 | collection:hotspot_countries, 299 | description: "hotspot_countries_jrc_20210112_Surge", 300 | fileNamePrefix: "hotspot_countries_jrc_20210112_Surge", 301 | fileFormat: "CSV" 302 | }) 303 | -------------------------------------------------------------------------------- /main_gfd.py: -------------------------------------------------------------------------------- 1 | # Wrapper function for running modis_dfo algorithm over DFO database. 2 | 3 | import ee 4 | ee.Initialize() 5 | 6 | from flood_detection import modis 7 | from flood_detection.utils import export, misc 8 | 9 | import time, os, csv 10 | 11 | # INPUTS 12 | # Enter the ID of the GEE Asset that contains the list of events to be mapped 13 | # and cast as ee.FeatureCollection(). GEE Asset must have at least 3 columns 14 | # titled: "ID", "Began", "Ended". In this version of the script, the GEE 15 | # Asset also needs to have polygons associated with each event that will be used 16 | # to select watersheds from global HydroSheds data to use as the area to map the 17 | # event over. 18 | 19 | # This GEE Asset is the QC database from August 1, 2019 20 | event_db = ee.FeatureCollection("projects/global-flood-db/dfo-polygons/qc-aug-01-2019").sort("ID") 21 | 22 | # This GEE Asset is the DFO Polygon database from Dec 3rd, 2019 23 | # event_db = ee.FeatureCollection("projects/global-flood-db/dfo-polygons/dec-03-2019") 24 | 25 | # GEE Asset folder and Google Cloud Storage for image collection 26 | gcs_folder = "gfd_v3" 27 | asset_path = "projects/global-flood-db/gfd_v3" 28 | 29 | #------------------------------------------------------------------------------- 30 | # PROCESSING STARTS HERE 31 | 32 | # Create Error Log file 33 | log_file = "error_logs/gfd_v3/error_log_{0}.csv".format(time.strftime("%d_%m_%Y")) 34 | 35 | with open(log_file,"ab") as out_file: 36 | wr = csv.writer(out_file) 37 | wr.writerow(["error_type", "dfo_id", "error_message"]) 38 | 39 | # Create list of events from input gee asset 40 | event_ids = ee.List(event_db.filterMetadata("ID", "greater_than", 4603).aggregate_array('ID')).sort() 41 | id_list = event_ids.getInfo() 42 | id_list = [int(i) for i in id_list] 43 | 44 | # NOTE: Code snippet for when you are re-running floods in error log 45 | # errors = "error_logs\\gfd_v3\\3Day_otsu_error_log_23_07_2019_1.csv" 46 | # with open(errors) as f: 47 | # id_list = sorted([int(float(row["dfo_id"])) for row in csv.DictReader(f)]) 48 | 49 | # NOTE: ID List for Validation Floods 50 | # id_list = [1641,1810,1818,1910,1925,1931,1971,2024,2035,2045,2075,2076,2099, 51 | # 2104,2119,2143,2167,2177,2180,2183,2191,2206,2214,2216,2261,2269, 52 | # 2296,2303,2332,2345,2366,2395,2443,2444,2458,2461,2463,2473,2507, 53 | # 2543,2570,2584,2586,2597,2599,2629,2640,2650,2688,2711,2780,2821, 54 | # 2829,2832,2940,2947,2948,3070,3075,3076,3094,3123,3132,3162,3166, 55 | # 3179,3198,3205,3218,3267,3274,3282,3285,3306,3345,3365,3366,3464, 56 | # 3476,3544,3567,3572,3625,3657,3658,3667,3673,3678,3692,3696,3754, 57 | # 3786,3801,3846,3850,3856,3871,3894,3916,3931,3977,4019,4022,4024, 58 | # 4083,4098,4115,4159,4163,4171,4179,4188,4211,4218,4226,4241,4258, 59 | # 4272,4314,4315,4325,4339,4340,4346,4357,4364,4427,4428,4435,4444, 60 | # 4464,4507,4516] 61 | 62 | snooze_button = 1 63 | for event in id_list: 64 | 65 | # Check if we have worn out GEE 66 | if snooze_button%50==0: #if true - hit the snooze button 67 | print "---------------------Giving GEE a breather for 15 mins--------------------" 68 | time.sleep(900) 69 | 70 | # Get event date range 71 | flood_event = ee.Feature(event_db.filterMetadata('ID', 'equals', event).first()) 72 | began = str(ee.Date(flood_event.get('Began')).format('yyyy-MM-dd').getInfo()) 73 | ended = str(ee.Date(flood_event.get('Ended')).format('yyyy-MM-dd').getInfo()) 74 | thresh_type = str(flood_event.get('ThreshType').getInfo()) 75 | 76 | if thresh_type == 'std': 77 | thresh_type = 'standard' 78 | else: 79 | pass 80 | 81 | # Use polygon from event GEE Asset to select watersheds from global 82 | # HydroSheds data choose level3, level4, or level5 83 | watershed = misc.get_watersheds_level4(flood_event.geometry()).union().geometry() 84 | # watershed = misc.get_islands(flood_event.geometry()).union().geometry() 85 | 86 | try: 87 | # Map the event. Returns 4 band image: 'flooded', 'duration', 88 | # 'clearViews', 'clearPerc' 89 | print "Mapping Event {0} - {1} threshold".format(event, thresh_type) 90 | flood_map = modis.dfo(watershed, began, ended, thresh_type, "3Day") 91 | 92 | # Apply slope mask to remove false detections from terrain 93 | # shadow. Input your image and choose a slope (in degrees) as a threshold 94 | flood_map_slope_mask = misc.apply_slope_mask(flood_map, thresh=5) 95 | 96 | # Get permanent water from JRC dataset at MODIS resolution 97 | perm_water = misc.get_jrc_perm(watershed) 98 | 99 | # Get countries within the watershed boundary 100 | country_info = misc.get_countries(watershed) 101 | 102 | # Add permanent and seasonal water as bands to image 103 | # Format the final DFO algorithm image for export 104 | dfo_final = ee.Image(flood_map_slope_mask).addBands(perm_water)\ 105 | .set({'id': event, 106 | 'gfd_country_code': str(country_info[0]), 107 | 'gfd_country_name': str(country_info[1])}) 108 | 109 | except Exception as e: 110 | s = str(e) 111 | with open(log_file,"ab") as out_file: 112 | wr = csv.writer(out_file) 113 | wr.writerow(["DFO Algorithm Error", event, s]) 114 | print "DFO Algorithm Error {0} - Cataloguing and moving onto next event".format(event) 115 | print "-------------------------------------------------" 116 | snooze_button+=1 117 | continue 118 | 119 | try: 120 | # Export to an asset. This function needs the ee.Image of the flood map 121 | # from map_DFO_event, the roi that is returned from the 122 | # map_floodEvent_MODIS, the path to where the asset will be saved, and 123 | # the resolution (in meters) to save it (default = 250m) 124 | 125 | export.to_asset(dfo_final, watershed.bounds(), asset_path, 250) 126 | export.to_gcs(dfo_final, watershed.bounds(), gcs_folder, 'DFO', 250) 127 | 128 | print "Uploading DFO {0} to GEE Assets & GCS".format(event) 129 | print "-------------------------------------------------" 130 | 131 | except Exception as e: 132 | s = str(e) 133 | with open(log_file,"ab") as out_file: 134 | wr = csv.writer(out_file) 135 | wr.writerow(["Export Error", event, s]) 136 | print "Export Error DFO {0} - Cataloguing and moving onto next event".format(event) 137 | print "-------------------------------------------------" 138 | 139 | # Add to the snooze_button so we don't make Noel angry. 140 | snooze_button+=1 141 | -------------------------------------------------------------------------------- /main_gfdsummarystats.R: -------------------------------------------------------------------------------- 1 | #main GFD numbers 2 | GFDmainstats<-read.csv('data/GFDabove_13_wBias.csv') 3 | 4 | colnames(GFDmainstats) 5 | 6 | #to make graphs of bias factor for GHSL/HRSL data 7 | mean(GFDmainstats$bias_factor, na.rm=TRUE) 8 | sd(GFDmainstats$bias_factor, na.rm=TRUE) 9 | hist(GFDmainstats$bias_factor, na.rm=TRUE) 10 | boxplot(GFDmainstats$bias_factor~GFDmainstats$continent, ylab="HRSL/GHSL population exposed estimates") 11 | 12 | 13 | #mean proportion of population exposed to floods 2000-2015 in GFD with GHSL 14 | mean(GFDmainstats$relexp, na.rm=TRUE) 15 | sd(GFDmainstats$relexp, na.rm=TRUE) 16 | hist(GFDmainstats$relexp) 17 | 18 | #total new number of people exposed to floods with population growth with GHSL 19 | sum(GFDmainstats$absolutechangef, na.rm=TRUE) 20 | 21 | #total new number of people exposed to floods with population growth with HRSL 22 | sum(GFDmainstats$absolutechangef*GFDmainstats$bias_factor, na.rm=TRUE) 23 | 24 | -------------------------------------------------------------------------------- /main_popchange.txt: -------------------------------------------------------------------------------- 1 | // Imports 2 | var gfd = ee.ImageCollection("projects/global-flood-db/gfd_v3"), 3 | ghsl_pop = ee.ImageCollection("JRC/GHSL/P2016/POP_GPW_GLOBE_V1"), 4 | ghsl_settle = ee.ImageCollection("JRC/GHSL/P2016/SMOD_POP_GLOBE_V1"), 5 | jrc = ee.Image("JRC/GSW1_1/GlobalSurfaceWater"), 6 | mod44w = ee.Image("MODIS/MOD44W/MOD44W_005_2000_02_24"); 7 | 8 | 9 | 10 | 11 | // STEP 1 - Prep permanent water layers & masks 12 | var gfd_first = ee.Image(gfd.first()) 13 | var scale_gfd = gfd_first.projection().nominalScale() 14 | var crs_gfd = gfd_first.projection().crs() 15 | 16 | // JRC Mask 17 | var jrc_250m = jrc.select('transition').eq(1).unmask() 18 | .reproject({crs:crs_gfd, 19 | scale:scale_gfd}) 20 | var jrc_250m_mask = jrc_250m.neq(1) 21 | 22 | // MOD44W Mask 23 | var mod44w_mask = ee.Image(mod44w.select('water_mask')).eq(0) 24 | Map.addLayer(jrc_250m_mask, {}, 'JRC', false) 25 | Map.addLayer(mod44w_mask, {}, 'MOD44W', false) 26 | 27 | // STEP 2 - Clean up GFD 28 | function maskPermWater(img){ 29 | var all_water = img.select("flooded") 30 | var water_mask = jrc_250m_mask 31 | return img.updateMask(water_mask) 32 | } 33 | 34 | function filterIsoPix (img){ 35 | 36 | // Calculate the number of connected pixels 37 | var size = img.select("flooded") 38 | .selfMask() 39 | .int() 40 | .connectedPixelCount(2, false) 41 | 42 | return size.updateMask(size.gte(2)) 43 | .multiply(0) 44 | .add(1) 45 | .reproject('EPSG:4326', null, img.projection().nominalScale())} 46 | 47 | var gfd_flood = gfd.map(maskPermWater) 48 | var gfd_cleaned = gfd_flood.map(filterIsoPix) 49 | 50 | // STEP 3 - Sum entire GFD collection images 51 | var gfd_dirty_sum = gfd_flood.select('flooded').sum().selfMask() 52 | var gfd_cleaned_sum = gfd_cleaned.select('flooded').sum().selfMask() 53 | 54 | var flood_palette = ['#fff7fb','#ece7f2','#d0d1e6','#a6bddb','#74a9cf', 55 | '#3690c0','#0570b0','#045a8d','#023858'] 56 | Map.addLayer(gfd_dirty_sum, {min:1,max:9,palette:flood_palette}, 'GFD Dirty') 57 | Map.addLayer(gfd_cleaned_sum, {min:1,max:9,palette:flood_palette}, 'GFD Clean') 58 | 59 | // STEP 4 - Calculate population change from 2000 to 2015 using GHSL 60 | var ghsl_2000 = ee.Image(ghsl_pop.filterMetadata('system:index','equals','2000').first()) 61 | var ghsl_2015 = ee.Image(ghsl_pop.filterMetadata('system:index','equals','2015').first()) 62 | var ghsl_pop_diff = ghsl_2015.subtract(ghsl_2000) 63 | 64 | // Reproject GHSL dataset & mask 65 | var ghsl_2000_reproj = ghsl_2000.resample('bilinear').reproject(crs_gfd, null, scale_gfd) 66 | var ghsl_pdiff_reproj = ghsl_pop_diff.resample('bilinear').reproject(crs_gfd, null, scale_gfd) 67 | 68 | var ghsl_pdiff_mask = ghsl_pdiff_reproj.neq(0) 69 | var ghsl_pdiff_masked = ghsl_pdiff_reproj.updateMask(ghsl_pdiff_mask) 70 | 71 | var ghsl_2000_masked = ghsl_2000_reproj.selfMask() 72 | 73 | var pop_palette = ['#053061','#2166ac','#4393c3','#92c5de','#d1e5f0', 74 | '#f7f7f7','#fddbc7','#f4a582','#d6604d','#b2182b','#67001f'] 75 | Map.addLayer(ghsl_2000, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop 2000 - ESPG 54009', false) 76 | Map.addLayer(ghsl_2000_reproj, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop 2000 - ESPG 4326', false) 77 | Map.addLayer(ghsl_2000_masked, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop 2000 Masked - ESPG 4326', false) 78 | Map.addLayer(ghsl_pop_diff, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop Change - EPSG:54009', false) 79 | Map.addLayer(ghsl_pdiff_reproj, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop Change - ESPG 4326', false) 80 | Map.addLayer(ghsl_pdiff_masked, {min:-100,max:100,palette:pop_palette}, 'GHSL Pop Change Masked - ESPG 4326', false) 81 | 82 | // STEP 5 - Create Raster of pop change in flood plain areas 83 | var gfd_dirty_floodplain = gfd_dirty_sum.gte(1) 84 | var gfd_dirty_popchange = gfd_dirty_floodplain.multiply(ghsl_pdiff_reproj) 85 | 86 | var gfd_clean_floodplain = gfd_cleaned_sum.gte(1) 87 | var gfd_clean_popchange = gfd_clean_floodplain.multiply(ghsl_pdiff_reproj) 88 | var lossmask= (gfd_clean_popchange.lte(1).multiply(gfd_clean_popchange).neq(0)) 89 | Map.addLayer(gfd_dirty_popchange, {min:-100,max:100,palette:pop_palette}, 'GFD Dirty Pop Change') 90 | Map.addLayer(gfd_clean_popchange, {min:-100,max:100,palette:pop_palette}, 'GFD Clean Pop Change') 91 | Map.addLayer(gfd_clean_popchange.lte(1).multiply(gfd_clean_popchange).updateMask(lossmask), {min:-400,max:0,palette:pop_palette}, 'GFD Dirty Pop Loss') 92 | 93 | // Export.image.toDrive({ 94 | // image: gfd_clean_popchange, 95 | // description:'hotspot_jrc_20190802', 96 | // folder: 'hotspot', 97 | // fileNamePrefix: 'hotspot_jrc_20190802', 98 | // scale: scale_gfd, 99 | // crs: crs_gfd, 100 | // fileFormat: 'GEOTIFF' 101 | // }) 102 | 103 | // STEP 6 - Summarize populatoin change in flood plains for countries & watersheds 104 | var countries = ee.FeatureCollection('ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw') 105 | var basins_l4 = ee.FeatureCollection('ft:1JRW4YKfVTZKLAH4x4JRsggsHZoXRRUQKTIOYgJOW') 106 | var basins_l5 = ee.FeatureCollection('ft:1IHRHUiWkgPXOzwNweeM89CzPYSfokjLlz7_0OTQl') 107 | 108 | 109 | // STEP 7 - Prep GHSL Settlement Layer 110 | var ghsl_settle_2015 = ee.Image(ghsl_settle.filterMetadata('system:index','equals','2015').first()) 111 | var rural = ghsl_settle_2015.select('smod_code').lte(1) 112 | var semiurban = ghsl_settle_2015.select('smod_code').eq(2) 113 | var urban = ghsl_settle_2015.select('smod_code').eq(3) 114 | 115 | 116 | // STEP 8 117 | function hotspotByPoly(ft){ 118 | var gfd_ft = gfd_cleaned_sum.clip(ft.bounds()) 119 | var map_scale = gfd_ft.projection().nominalScale() 120 | 121 | var pop_2000_ft = ghsl_2000_masked.clip(ft.bounds()) 122 | var pop_diff_ft = ghsl_pdiff_masked.clip(ft.bounds()) 123 | var pop_scale = pop_diff_ft.projection().nominalScale() 124 | 125 | var pop_change_all_rural = pop_diff_ft.updateMask(rural).reduceRegion({ 126 | reducer: ee.Reducer.sum(), 127 | geometry: ft.geometry(), 128 | scale: pop_scale, 129 | maxPixels: 1e10}) 130 | 131 | var pop_change_all_semiurban = pop_diff_ft.updateMask(semiurban).reduceRegion({ 132 | reducer: ee.Reducer.sum(), 133 | geometry: ft.geometry(), 134 | scale: pop_scale, 135 | maxPixels: 1e10}) 136 | 137 | var pop_change_all_urban = pop_diff_ft.updateMask(urban).reduceRegion({ 138 | reducer: ee.Reducer.sum(), 139 | geometry: ft.geometry(), 140 | scale: pop_scale, 141 | maxPixels: 1e10}) 142 | 143 | var pop_diff_flood = pop_diff_ft.updateMask(gfd_ft.gte(1)) 144 | var pop_change_flood_rural = pop_diff_flood.updateMask(rural).reduceRegion({ 145 | reducer: ee.Reducer.sum(), 146 | geometry: ft.geometry(), 147 | scale: pop_scale, 148 | maxPixels: 1e10}) 149 | 150 | var pop_change_flood_semiurban = pop_diff_flood.updateMask(semiurban).reduceRegion({ 151 | reducer: ee.Reducer.sum(), 152 | geometry: ft.geometry(), 153 | scale: pop_scale, 154 | maxPixels: 1e10}) 155 | 156 | var pop_change_flood_urban = pop_diff_flood.updateMask(urban).reduceRegion({ 157 | reducer: ee.Reducer.sum(), 158 | geometry: ft.geometry(), 159 | scale: pop_scale, 160 | maxPixels: 1e10}) 161 | 162 | var pop_change_nonflood_rural = pop_change_all_rural.getNumber('population_count') 163 | .subtract(pop_change_flood_rural.getNumber('population_count')) 164 | 165 | var pop_change_nonflood_semiurban = pop_change_all_semiurban.getNumber('population_count') 166 | .subtract(pop_change_flood_semiurban.getNumber('population_count')) 167 | 168 | var pop_change_nonflood_urban = pop_change_all_urban.getNumber('population_count') 169 | .subtract(pop_change_flood_urban.getNumber('population_count')) 170 | 171 | var pop_2000_all_rural = pop_2000_ft.updateMask(rural).reduceRegion({ 172 | reducer: ee.Reducer.sum(), 173 | geometry: ft.geometry(), 174 | scale: pop_scale, 175 | maxPixels: 1e10}) 176 | 177 | var pop_2000_all_semiurban = pop_2000_ft.updateMask(semiurban).reduceRegion({ 178 | reducer: ee.Reducer.sum(), 179 | geometry: ft.geometry(), 180 | scale: pop_scale, 181 | maxPixels: 1e10}) 182 | 183 | var pop_2000_all_urban = pop_2000_ft.updateMask(urban).reduceRegion({ 184 | reducer: ee.Reducer.sum(), 185 | geometry: ft.geometry(), 186 | scale: pop_scale, 187 | maxPixels: 1e10}) 188 | 189 | var pop_2000_flood_img = pop_2000_ft.updateMask(gfd_ft.gte(1)) 190 | var pop_2000_flood_rural = pop_2000_flood_img.updateMask(rural).reduceRegion({ 191 | reducer: ee.Reducer.sum(), 192 | geometry: ft.geometry(), 193 | scale: pop_scale, 194 | maxPixels: 1e10}) 195 | 196 | var pop_2000_flood_semiurban = pop_2000_flood_img.updateMask(semiurban).reduceRegion({ 197 | reducer: ee.Reducer.sum(), 198 | geometry: ft.geometry(), 199 | scale: pop_scale, 200 | maxPixels: 1e10}) 201 | 202 | var pop_2000_flood_urban = pop_2000_flood_img.updateMask(urban).reduceRegion({ 203 | reducer: ee.Reducer.sum(), 204 | geometry: ft.geometry(), 205 | scale: pop_scale, 206 | maxPixels: 1e10}) 207 | 208 | var pop_2000_nonflood_rural = pop_2000_all_rural.getNumber('population_count') 209 | .subtract(pop_2000_flood_rural.getNumber('population_count')) 210 | 211 | var pop_2000_nonflood_semiurban = pop_2000_all_semiurban.getNumber('population_count') 212 | .subtract(pop_2000_flood_semiurban.getNumber('population_count')) 213 | 214 | var pop_2000_nonflood_urban = pop_2000_all_urban.getNumber('population_count') 215 | .subtract(pop_2000_flood_urban.getNumber('population_count')) 216 | 217 | var pdelta_flood = pop_change_flood_rural.getNumber('population_count') 218 | .add(pop_change_flood_semiurban.getNumber('population_count') 219 | .add(pop_change_flood_urban.getNumber('population_count'))) 220 | var p2000_flood = pop_2000_flood_rural.getNumber('population_count') 221 | .add(pop_2000_flood_semiurban.getNumber('population_count') 222 | .add(pop_2000_flood_urban.getNumber('population_count'))) 223 | 224 | var pdelta_all = pop_change_all_rural.getNumber('population_count') 225 | .add(pop_change_all_semiurban.getNumber('population_count') 226 | .add(pop_change_all_urban.getNumber('population_count'))) 227 | var p2000_all = pop_2000_all_rural.getNumber('population_count') 228 | .add(pop_2000_all_semiurban.getNumber('population_count') 229 | .add(pop_2000_all_urban.getNumber('population_count'))) 230 | 231 | var rate_numerator = pdelta_flood.divide(p2000_flood) 232 | var rate_denominator = pdelta_all.divide(p2000_all) 233 | var rate = rate_numerator.divide(rate_denominator) 234 | 235 | // 1=rural; 2=semiurban; 3=urban 236 | // a = all; f = flood; nf = nonflood 237 | return ee.Feature(null, {"ccc":ft.get('country_code'), 238 | 239 | "pop_delta_all_rural":pop_change_all_rural.getNumber('population_count'), 240 | "pop_delta_flood_rural": pop_change_flood_rural.getNumber('population_count'), 241 | "pop_delta_nonflood_rural":pop_change_nonflood_rural, 242 | "pop_2000_all_rural":pop_2000_all_rural.getNumber('population_count'), 243 | "pop_2000_flood_rural":pop_2000_flood_rural.getNumber('population_count'), 244 | "pop_2000_nonflood_rural":pop_2000_nonflood_rural, 245 | 246 | "pop_delta_all_semiurban":pop_change_all_semiurban.getNumber('population_count'), 247 | "pop_delta_flood_semiurban": pop_change_flood_semiurban.getNumber('population_count'), 248 | "pop_delta_nonflood_semiurban":pop_change_nonflood_semiurban, 249 | "pop_2000_all_semiurban":pop_2000_all_semiurban.getNumber('population_count'), 250 | "pop_2000_flood_semiurban":pop_2000_flood_semiurban.getNumber('population_count'), 251 | "pop_2000_nonflood_semiurban":pop_2000_nonflood_semiurban, 252 | 253 | "pop_delta_all_urban":pop_change_all_urban.getNumber('population_count'), 254 | "pop_delta_flood_urban": pop_change_flood_urban.getNumber('population_count'), 255 | "pop_delta_nonflood_urban":pop_change_nonflood_urban, 256 | "pop_2000_all_urban":pop_2000_all_urban.getNumber('population_count'), 257 | "pop_2000_flood_urban":pop_2000_flood_urban.getNumber('population_count'), 258 | "pop_2000_nonflood_urban":pop_2000_nonflood_urban, 259 | 260 | "pop_delta_flood": pdelta_flood, 261 | "pop_2000_flood": p2000_flood, 262 | "pop_delta_all": pdelta_all, 263 | "pop_2000_all": p2000_all 264 | }) 265 | } 266 | 267 | var hotspot_countries = countries.map(hotspotByPoly) 268 | 269 | Export.table.toDrive({ 270 | collection:hotspot_countries, 271 | description: "hotspot_country_jrc_20190803", 272 | fileNamePrefix: "hotspot_country_jrc_20190803", 273 | fileFormat: "CSV" 274 | }) 275 | -------------------------------------------------------------------------------- /main_popsensitivity.txt: -------------------------------------------------------------------------------- 1 | // Imports 2 | var gfd = ee.ImageCollection("projects/global-flood-db/gfd_v3"), 3 | ghsl_pop = ee.ImageCollection("JRC/GHSL/P2016/POP_GPW_GLOBE_V1"), 4 | ghsl_settle = ee.ImageCollection("JRC/GHSL/P2016/SMOD_POP_GLOBE_V1"), 5 | hrsl = ee.ImageCollection("projects/sat-io/open-datasets/hrslpop"), 6 | jrc = ee.Image("JRC/GSW1_1/GlobalSurfaceWater"), 7 | mod44w = ee.Image("MODIS/MOD44W/MOD44W_005_2000_02_24"); 8 | 9 | // STEP 0 - Check out population data and read in GripPop3 10 | 11 | // GHSL 12 | print("GHSL:", ghsl_pop) 13 | var ghsl_2015 = ee.Image(ghsl_pop.filterMetadata('system:index','equals','2015').first()) 14 | var ghsl_2015_masked = ghsl_2015.selfMask() 15 | 16 | // HRSL 17 | // List of HRSL images to remove (duplicates) 18 | var rm_list =['population_AF01_2018-10-01', 19 | 'population_AF02_2018-10-01', 20 | 'population_AF03_2018-10-01', 21 | 'population_AF04_2018-10-01', 22 | 'population_AF05_2018-10-01', 23 | 'population_AF06_2018-10-01', 24 | 'population_AF07_2018-10-01', 25 | 'population_AF08_2018-10-01', 26 | 'population_AF09_2018-10-01', 27 | 'population_AF10_2018-10-01', 28 | 'population_AF11_2018-10-01', 29 | 'population_AF12_2018-10-01', 30 | 'population_AF13_2018-10-01', 31 | 'population_AF14_2018-10-01', 32 | 'population_AF15_2018-10-01', 33 | 'population_AF16_2018-10-01', 34 | 'population_AF17_2018-10-01', 35 | 'population_AF18_2018-10-01', 36 | 'population_AF19_2018-10-01', 37 | 'population_AF20_2018-10-01', 38 | 'population_AF21_2018-10-01', 39 | 'population_AF22_2018-10-01', 40 | 'population_AF23_2018-10-01', 41 | 'population_AF24_2018-10-01', 42 | 'population_AF25_2018-10-01', 43 | 'population_AF26_2018-10-01', 44 | 'population_AF27_2018-10-01', 45 | 'population_AF28_2018-10-01', // africa continent images 46 | 'population_AS42_2018-10-01', 47 | 'population_AS43_2018-10-01', 48 | 'population_AS44_2018-10-01', 49 | 'population_AS47_2018-10-01', // south asia images 50 | 'population_ago_2018-10-01', // earlier version of angola data 51 | 'population_bdi_2018-10-01', // earlier version of burundi data 52 | 'population_ben_2018-10-01', // earlier version of benin data 53 | 'population_bwa_2018-10-01', // earlier version of botswana data 54 | 'population_civ_2018-10-01', // earlier version of cote d'ivoire data 55 | 'population_cmr_2018-10-01', // earlier version of cameroon data 56 | 'population_cpv_2018-10-01', // earlier version of cape verde 57 | 'population_dji_2018-10-01', // earlier version of djibouti 58 | 'population_eri_2018-10-01', // earlier version of eritrea 59 | 'population_gha_2018-10-01', // earlier version of ghana 60 | 'population_gmb_2018-10-01', // earlier version of gambia 61 | 'population_lso_2018-10-01', // earlier version of lesotho 62 | 'population_moz_2018-10-01', // earlier version of mozambique 63 | 'population_myt_2018-10-01', // earlier version of mayotte 64 | 'population_nam_2018-10-01', // earlier version of nambia 65 | 'population_sle_2018-10-01', // earlier version of sierra Leone 66 | 'population_stp_2018-10-01', // earlier version of sao tome 67 | 'population_swz_2018-10-01', // earlier version of swaziland 68 | 'population_tgo_2018-10-01', // earlier version of togo 69 | 'population_uga_2018-10-01', // earlier version of uganda 70 | 'population_zaf_2018-10-01', // earlier version of south africa 71 | 'population_zmb_2018-10-01', // earlier version of zambia 72 | 'population_zwe_2018-10-01'] // earlier version of zimbabwe 73 | 74 | // Filter to remove items in list 75 | var hrsl_filter = ee.Filter.listContains({leftValue:rm_list, 76 | rightField:'id_no'}).not() 77 | var hrsl_filtered = hrsl.filter(hrsl_filter) 78 | var hrsl_img = hrsl_filtered.mosaic() 79 | print("HRSL:",hrsl_filtered) 80 | print("HRSL Scale", ee.Image(hrsl.first()).projection().nominalScale()) 81 | 82 | // GridPop3 83 | // Add Gridpop data from other countries 84 | var gpop3_sle = ee.Image("projects/global-flood-db/GRIDpop3_SLE") 85 | var gpop3_ssd = ee.Image("projects/global-flood-db/GRID3pop_SSD") 86 | var gpop3_cod = ee.Image("projects/global-flood-db/gridpop3_COD") 87 | var gpop3_gha = ee.Image("projects/c2s-ee-cloud/assets/GRIDpop3_GHA") 88 | var gpop3_moz = ee.Image("projects/global-flood-db/GRID3pop_MOZ") 89 | var gpop3_nga = ee.Image("projects/global-flood-db/GRID3pop_NGA") 90 | var gpop3_zmb = ee.Image("projects/global-flood-db/GRID3pop_ZMB") 91 | 92 | var gridpop3 = ee.ImageCollection([gpop3_sle, 93 | gpop3_ssd, 94 | gpop3_cod, 95 | gpop3_gha, 96 | gpop3_moz, 97 | gpop3_nga, 98 | gpop3_zmb]) 99 | var gridpop3_img = gridpop3.mosaic() 100 | print("Grid Pop3:", gridpop3) 101 | print("Grid Pop Scale", ee.Image(gridpop3.first()).projection().nominalScale()) 102 | 103 | // STEP 1 - Prep permanent water layers & masks 104 | var gfd_first = ee.Image(gfd.first()) 105 | var scale_gfd = gfd_first.projection().nominalScale() 106 | var crs_gfd = gfd_first.projection().crs() 107 | print("GFD CRS:", crs_gfd) 108 | print("GFD Scale:",scale_gfd) 109 | 110 | // JRC Mask 111 | var jrc_250m = jrc.select('transition') 112 | .eq(1) 113 | .unmask() 114 | .reproject({crs:crs_gfd, scale:scale_gfd}) 115 | var jrc_250m_mask = jrc_250m.neq(1) 116 | 117 | // MOD44W Mask 118 | var mod44w_mask = ee.Image(mod44w.select('water_mask')).eq(0) 119 | Map.addLayer(jrc_250m_mask, {}, 'JRC', false) 120 | Map.addLayer(mod44w_mask, {}, 'MOD44W', false) 121 | 122 | // STEP 2 - Clean up GFD 123 | function maskPermWater(img){ 124 | var all_water = img.select("flooded") 125 | var water_mask = jrc_250m_mask 126 | return img.updateMask(water_mask) 127 | } 128 | 129 | function filterIsoPix (img){ 130 | 131 | // Calculate the number of connected pixels 132 | var size = img.select("flooded") 133 | .selfMask() 134 | .int() 135 | .connectedPixelCount(2, false) 136 | 137 | return size.updateMask(size.gte(2)) 138 | .multiply(0) 139 | .add(1) 140 | .reproject('EPSG:4326', null, img.projection().nominalScale())} 141 | 142 | var gfd_flood = gfd.map(maskPermWater) 143 | var gfd_cleaned = gfd_flood.map(filterIsoPix) 144 | 145 | // STEP 3 - Sum entire GFD collection images 146 | var gfd_dirty_sum = gfd_flood.select('flooded').sum().selfMask() 147 | var gfd_cleaned_sum = gfd_cleaned.select('flooded').sum().selfMask() 148 | 149 | var flood_palette = ['#fff7fb','#ece7f2','#d0d1e6','#a6bddb','#74a9cf', 150 | '#3690c0','#0570b0','#045a8d','#023858'] 151 | Map.addLayer(gfd_dirty_sum, {min:1,max:9,palette:flood_palette}, 'GFD Dirty') 152 | Map.addLayer(gfd_cleaned_sum, {min:1,max:9,palette:flood_palette}, 'GFD Clean') 153 | 154 | // STEP 4 - Summarize populatoin change in flood plains for countries & watersheds 155 | var countries = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017') 156 | 157 | // Prep GHSL Settlement Layer 158 | var ghsl_settle_2015 = ee.Image(ghsl_settle.filterMetadata('system:index','equals','2015').first()) 159 | var rural = ghsl_settle_2015.select('smod_code').lte(1) 160 | var semiurban = ghsl_settle_2015.select('smod_code').eq(2) 161 | var urban = ghsl_settle_2015.select('smod_code').eq(3) 162 | 163 | // Flood exposure estimates by different datasets & land-use zones 164 | function hotspotByPoly(ft){ 165 | var gfd_ft = gfd_cleaned_sum.clip(ft.bounds()) 166 | var map_scale = gfd_ft.projection().nominalScale() 167 | 168 | // GHSL 169 | var ghsl_2015_ft = ghsl_2015_masked.clip(ft.bounds()) 170 | var ghsl_scale = ghsl_2015_ft.projection().nominalScale() 171 | 172 | // HRSL 173 | var hrsl_ft = hrsl_img.clip(ft.bounds()) 174 | var hrsl_scale = ee.Image(hrsl.first()).projection().nominalScale() 175 | 176 | // GridPop3 177 | var gridpop3_ft = gridpop3_img.clip(ft.bounds()) 178 | var gridpop3_scale = ee.Image(gridpop3.first()).projection().nominalScale() 179 | 180 | // Mask population datasets by GFD 181 | var ghsl_2015_flood_img = ghsl_2015_ft.updateMask(gfd_ft.gte(1)) 182 | var hrsl_flood_img = hrsl.mosaic().updateMask(gfd_ft.gte(1)) 183 | var gridpop3_flood_img = gridpop3_ft.updateMask(gfd_ft.gte(1)) 184 | 185 | // Calculate flood exposed populations using different datsets 186 | // Rural zone 187 | var pop_ghsl2015_flood_rural = ghsl_2015_flood_img.updateMask(rural).reduceRegion({ 188 | reducer: ee.Reducer.sum(), 189 | geometry: ft.geometry(), 190 | scale: ghsl_scale, 191 | maxPixels: 1e11, 192 | tileScale:16 193 | }) 194 | 195 | var pop_hrsl_flood_rural = hrsl_flood_img.updateMask(rural).reduceRegion({ 196 | reducer: ee.Reducer.sum(), 197 | geometry: ft.geometry(), 198 | scale: hrsl_scale, 199 | maxPixels: 1e11, 200 | tileScale:16 201 | }) 202 | 203 | var gridpop3_flood_rural = gridpop3_flood_img.updateMask(rural).reduceRegion({ 204 | reducer: ee.Reducer.sum(), 205 | geometry: ft.geometry(), 206 | scale: gridpop3_scale, 207 | maxPixels: 1e11, 208 | tileScale:16 209 | }) 210 | 211 | // Semiurban zone 212 | var pop_ghsl2015_flood_semiurban = ghsl_2015_flood_img.updateMask(semiurban).reduceRegion({ 213 | reducer: ee.Reducer.sum(), 214 | geometry: ft.geometry(), 215 | scale: ghsl_scale, 216 | maxPixels: 1e11, 217 | tileScale:16 218 | }) 219 | 220 | var pop_hrsl_flood_semiurban = hrsl_flood_img.updateMask(semiurban).reduceRegion({ 221 | reducer: ee.Reducer.sum(), 222 | geometry: ft.geometry(), 223 | scale: hrsl_scale, 224 | maxPixels: 1e11, 225 | tileScale:16 226 | }) 227 | 228 | var gridpop3_flood_semiurban = gridpop3_flood_img.updateMask(semiurban).reduceRegion({ 229 | reducer: ee.Reducer.sum(), 230 | geometry: ft.geometry(), 231 | scale: gridpop3_scale, 232 | maxPixels: 1e11, 233 | tileScale:16 234 | }) 235 | 236 | // Urban zone 237 | var pop_ghsl2015_flood_urban = ghsl_2015_flood_img.updateMask(urban).reduceRegion({ 238 | reducer: ee.Reducer.sum(), 239 | geometry: ft.geometry(), 240 | scale: ghsl_scale, 241 | maxPixels: 1e11, 242 | tileScale:16 243 | }) 244 | 245 | var pop_hrsl_flood_urban = hrsl_flood_img.updateMask(urban).reduceRegion({ 246 | reducer: ee.Reducer.sum(), 247 | geometry: ft.geometry(), 248 | scale: hrsl_scale, 249 | maxPixels: 1e11, 250 | tileScale:16 251 | }) 252 | 253 | var gridpop3_flood_urban = gridpop3_flood_img.updateMask(urban).reduceRegion({ 254 | reducer: ee.Reducer.sum(), 255 | geometry: ft.geometry(), 256 | scale: gridpop3_scale, 257 | maxPixels: 1e11, 258 | tileScale:16 259 | }) 260 | 261 | // 1=rural; 2=semiurban; 3=urban 262 | return ee.Feature(null, {"id":ft.get('id'), 263 | "country_abbrev":ft.get('abbreviati'), 264 | "countrycode":ft.get('country_co'), 265 | "country_name":ft.get('country_na'), 266 | "world_region":ft.get("wld_rgn"), 267 | 268 | // Flood exposed populations (rural) 269 | "floodpop_ghsl_1":pop_ghsl2015_flood_rural.getNumber('population_count'), 270 | "floodpop_hrsl_1":pop_hrsl_flood_rural.getNumber('b1'), 271 | "floodpop_gridpop3_1":gridpop3_flood_rural.getNumber('b1'), 272 | 273 | // Flood exposed populations (semiubran) 274 | "floodpop_ghsl_2":pop_ghsl2015_flood_semiurban.getNumber('population_count'), 275 | "floodpop_hrsl_2":pop_hrsl_flood_semiurban.getNumber('b1'), 276 | "floodpop_gridpop3_2":gridpop3_flood_semiurban.getNumber('b1'), 277 | 278 | // Flood exposed populations (urban) 279 | "floodpop_ghsl_3":pop_ghsl2015_flood_urban.getNumber('population_count'), 280 | "floodpop_hrsl_3":pop_hrsl_flood_urban.getNumber('b1'), 281 | "floodpop_gridpop3_3":gridpop3_flood_urban.getNumber('b1') 282 | }) 283 | } 284 | 285 | // Calculate flood exposures for each region 286 | // Create list of world regions 287 | var wld_rgn = countries.aggregate_array('wld_rgn').distinct() 288 | 289 | // Loop over world region list and prep export 290 | var i 291 | for (i = 0; i < 17; i++) { 292 | 293 | // Get region 294 | var region = wld_rgn.get(i) 295 | var region_str = ee.String(region) 296 | .toLowerCase() 297 | .replace(' ', '') 298 | .getInfo() 299 | 300 | // Filter by region & run pop summary 301 | var region_countries = countries.filterMetadata('wld_rgn','equals',region) 302 | var region_flood_exposure = region_countries.map(hotspotByPoly) 303 | 304 | var base = "sensitivity_analysis" 305 | var desc = base + '_' + region_str 306 | var file_name = base + '_' + region_str + '_' + '20210105' 307 | 308 | Export.table.toDrive({ 309 | collection:region_flood_exposure, 310 | description: desc, 311 | fileNamePrefix: file_name, 312 | fileFormat: "CSV" 313 | }) 314 | } 315 | -------------------------------------------------------------------------------- /main_popstats.py: -------------------------------------------------------------------------------- 1 | # Colin Doyle 2 | # October 10, 2017 3 | 4 | # use this template to run the flood stats functions (area, population, etc.) 5 | # on an image collection and export results as a csv 6 | 7 | import ee 8 | ee.Initialize() 9 | 10 | from flood_stats import pop_utils 11 | import time, csv 12 | 13 | # Image Collection of flood maps, each needs layer called "flooded" that 14 | # is 1 = flooded, 0 = not flooded 15 | gfd = ee.ImageCollection('projects/global-flood-db/gfd_v3').filterMetadata('id','greater_than',4335) 16 | 17 | # Create Error Log file 18 | log_file = "error_logs/event_stats/pop_error_log_{0}.csv".format(time.strftime("%d_%m_%Y")) 19 | with open(log_file,"w", newline='') as out_file: 20 | wr = csv.writer(out_file) 21 | wr.writerow(["error_type", "dfo_id", "error_message"]) 22 | 23 | # Create list of events from input fusion table 24 | event_ids = ee.List(gfd.aggregate_array('id')).sort() 25 | id_list = event_ids.getInfo() 26 | id_list = [int(i) for i in id_list] 27 | 28 | for event_id in id_list: 29 | # Get event date range, they can be passed as Strings 30 | flood_event = ee.Image(gfd.filterMetadata('id', 'equals', event_id).first()) 31 | 32 | try: 33 | # Calculate flood stats 34 | flood_stats = pop_utils.getFloodPopbyCountry_GHSLTimeSeries(flood_event) 35 | index = flood_stats.get("id").getInfo() 36 | print("calculated results, exporting results for DFO {0}...".format(int(index))) 37 | 38 | except Exception as e: 39 | s = str(e) 40 | with open(log_file,"w", newline='') as out_file: 41 | wr = csv.writer(out_file) 42 | wr.writerow(["Calculation Error", event_id, s]) 43 | print("Calculation Error {0} - Cataloguing and moving onto next event".format(event_id)) 44 | print("-------------------------------------------------") 45 | 46 | # Export results 47 | try: 48 | task = ee.batch.Export.table.toCloudStorage( 49 | collection = flood_stats, 50 | description = 'GFD_bycountryEstimates_GHSL_TS_{0}'.format(str(int(index))), 51 | bucket = 'event_stats', 52 | fileNamePrefix = 'ghsl_fpu/GFD_{0}_Pop_Area_GHSL_TS_2019_07_29'.format(str(int(index))), 53 | fileFormat = 'CSV') 54 | 55 | task.start() 56 | 57 | except Exception as e: 58 | s = str(e) 59 | with open(log_file,"ab") as out_file: 60 | wr = csv.writer(out_file) 61 | wr.writerow(["Export Error", event_id, s]) 62 | print("Export Error DFO {0} - Cataloguing and moving onto next event".format(event_id)) 63 | print("-------------------------------------------------") 64 | 65 | print('Done!') 66 | -------------------------------------------------------------------------------- /main_sensitivityanalysis.R: -------------------------------------------------------------------------------- 1 | library(tidyverse) 2 | library(countrycode) 3 | 4 | # --- POP SENSITIVITY ANALYSIS --- 5 | # Set working directory 6 | pop_base = "data/pop_sensitivity_analysis" 7 | 8 | # List csv files 9 | files = list.files(pop_base, pattern = "*.csv") 10 | hrsl_file = files[1] 11 | pop_files = files[2:length(files)] 12 | 13 | # Load metadata for HRSL dataset 14 | hrsl_metadata = read.csv(paste(pop_base, hrsl_file, sep='/')) %>% 15 | mutate(iso3 = toupper(iso3)) 16 | 17 | # Load pop analysis data and bind files together 18 | drop_cols = c('country_abbrev', 'id','.geo') 19 | pop_sensitivity <- pop_files %>% 20 | map_df(~read.csv(paste(pop_base, ., sep='/'))) %>% # reading all csvs and bindind 21 | select(-drop_cols) %>% # removing columns in drop_cols() 22 | mutate(world_region = if_else(country_name=='United States', "North America", world_region)) %>% # fixing Hawaii that is in region Oceania 23 | rename('iso2c' = 'countrycode') # renaming column 24 | 25 | # Add code with 3-digit iso-code 26 | iso3c = countrycode(pop_sensitivity$country_name, origin = 'country.name', destination = 'iso3c') 27 | pop_sensitivity$iso3c = iso3c 28 | 29 | # Remove some small islands that are creating duplicates 30 | country_rm = c('Portugal (Azores)', 'Portugal (Madeira Is)', 'Spain (Canary Is)', 31 | 'Spain (Africa)', 'Korean Is. (UN Jurisdiction)', 32 | 'US Minor Pacific Is. Refuges') 33 | 34 | # Filter pop sensitivity to those with HRSL data 35 | `%notin%` = Negate(`%in%`) 36 | bias_factor = pop_sensitivity %>% 37 | filter(iso3c %in% hrsl_metadata$iso3) %>% # filter pop_sensitivity to countries with HRSL data 38 | filter(country_name %notin% country_rm) %>% # removing some odd island 39 | group_by(country_name, iso3c, iso2c, world_region) %>% # grouping for later aggregation stats 40 | summarise_if(is.numeric, sum, na.rm = TRUE) %>% # summing all numeric columns (e.g. different geometries for Italy or now just one record) 41 | mutate(floodpop_ghsl_tot = floodpop_ghsl_1+floodpop_ghsl_2+floodpop_ghsl_3, 42 | floodpop_gridpop3_tot = floodpop_gridpop3_1+floodpop_gridpop3_2+floodpop_ghsl_3, 43 | floodpop_hrsl_tot = floodpop_hrsl_1+floodpop_hrsl_2+floodpop_hrsl_3, 44 | bias_factor = floodpop_hrsl_tot/floodpop_ghsl_tot) # creating new columns 45 | 46 | 47 | continent = countrycode(bias_factor$country_name, origin='country.name', destination = 'continent') 48 | bias_factor$continent = continent 49 | 50 | # Plot 51 | ggplot(data=bias_factor, aes(x=continent, y=bias_factor))+ 52 | geom_boxplot(fill='#377eb8', alpha=0.5) + 53 | geom_hline(yintercept=1, size=1, linetype='dashed') + 54 | labs(x="Continent", y="Correction Factor") + 55 | theme_minimal() + 56 | theme(axis.title.x = element_text(size=18), 57 | axis.title.y = element_text(size=18), 58 | axis.text.x = element_text(size=14), 59 | axis.text.y = element_text(size=14)) 60 | 61 | # Write CSV 62 | #write.csv(bias_factor, "data/bias_factor.csv") 63 | 64 | # --- FLOOD PROPORTION --- # 65 | # Main results from Beth 66 | gfd_main = read.csv("data/GFDabove.13.csv") 67 | 68 | # Add 3-digit country code 69 | iso3c = countrycode(gfd_main$country, origin = 'country.name', destination = 'iso3c') 70 | gfd_main$iso3c = iso3c 71 | 72 | # Join main analysis to bias factor by 3-digit country code 73 | bias2join = bias_factor %>% 74 | ungroup() %>% 75 | select(iso3c, 76 | floodpop_hrsl_1, floodpop_hrsl_2, floodpop_hrsl_3, 77 | bias_factor) 78 | 79 | # Join main analysis and bias together 80 | gfd_main_bias = gfd_main %>% 81 | left_join(bias2join, by='iso3c') 82 | 83 | # Calculation bias by region 84 | main_region_bias = gfd_main_bias %>% 85 | group_by(region) %>% 86 | summarize(region_mean_bias = mean(bias_factor, na.rm=T), 87 | region_sd_bias = sd(bias_factor, na.rm=T)) 88 | 89 | # Final dataset! 90 | gfd_main_bias_final = gfd_main_bias %>% 91 | left_join(main_region_bias, by='region') %>% 92 | mutate(hrsl_data = if_else(is.na(bias_factor), "No", "Yes"), 93 | bias_factor = if_else(is.na(bias_factor), region_mean_bias, bias_factor)) 94 | 95 | # Annnnnnddd...write to disk 96 | #write.csv(gfd_main_bias_final, "data/GFDabove_13_wBias.csv") 97 | 98 | 99 | #--- EVENT STATS ---# 100 | ghsl_events = read.csv("data/compiled_pop_ghsl_ts_2019_08_04.csv") 101 | 102 | # Clean up some country names 103 | ghsl_events$country[ghsl_events$country=="Byelarus"] = "Belarus" 104 | ghsl_events$country[ghsl_events$country=="Korea, Peoples Republic of"] = "North Korea" 105 | ghsl_events$country[ghsl_events$country=="Iraq-Saudi Arabia Neutral Zone"] = "Iraq" 106 | ghsl_events$country[ghsl_events$country=="Yugoslavia"] = "Serbia" 107 | 108 | # Add ISO3 109 | iso3c = countrycode(ghsl_events$country, origin = 'country.name', destination = 'iso3c') 110 | ghsl_events$iso3c = iso3c 111 | 112 | # World region2join 113 | region2join = pop_sensitivity %>% 114 | filter(country_name %notin% country_rm) %>% 115 | select(iso3c, world_region) %>% 116 | filter(!is.na(iso3c)) %>% 117 | unique() 118 | 119 | # Reduce bias2join further 120 | bias2join = bias_factor %>% 121 | ungroup() %>% 122 | select(iso3c, bias_factor) 123 | 124 | ghsl_events_bias = ghsl_events %>% 125 | rename(exposed_ghsl=exposed) %>% 126 | left_join(region2join, by="iso3c") %>% 127 | left_join(bias2join, by="iso3c") %>% 128 | mutate(bias_factor = if_else(is.infinite(bias_factor), as.numeric(NA), bias_factor), 129 | bias_factor = if_else(is.nan(bias_factor), as.numeric(NA), bias_factor)) 130 | 131 | # Bermuda, Turks and Caicos, and Bahamas missing a world region 132 | ghsl_events_bias$world_region[is.na(ghsl_events_bias$world_region)] = "Caribbean" 133 | 134 | # Calculate regional bias based in the LSIB classification 135 | lsib_region_bias = bias_factor %>% 136 | mutate(bias_factor = if_else(is.infinite(bias_factor), as.numeric(NA), bias_factor), 137 | bias_factor = if_else(is.nan(bias_factor), as.numeric(NA), bias_factor)) %>% 138 | group_by(world_region) %>% 139 | summarize(region_mean_bias = mean(bias_factor, na.rm=T)) 140 | 141 | ghsl_events_out = ghsl_events_bias %>% 142 | left_join(lsib_region_bias, by="world_region") %>% 143 | mutate(bias_factor = if_else(is.na(bias_factor), region_mean_bias, bias_factor), 144 | exposed_adjusted = exposed_ghsl * bias_factor) 145 | 146 | # And....write to csv 147 | #write.csv(ghsl_events_out, "data/compiled_pop_ghsl_ts_wbias_2019_08_04.csv") 148 | 149 | 150 | # ------- FLOOD MECHANISMS ---------- # 151 | fmech_base = 'data/flood_mechanism' 152 | surge = read.csv(paste(fmech_base, 'hotspot_countries_jrc_20210112_Surge.csv', sep='/')) 153 | snowicerain = read.csv(paste(fmech_base, 'hotspot_countries_jrc_20210112_SnowIceRain.csv', sep='/')) 154 | heavyrain = read.csv(paste(fmech_base, 'hotspot_countries_jrc_20210112_HeavyRain.csv', sep='/')) 155 | dam = read.csv(paste(fmech_base, 'hotspot_countries_jrc_20210112_Dam.csv', sep='/')) 156 | 157 | # removing these classification from LSIB 158 | no_country = c("Abyei Area", "Akrotiri", "Aksai Chin", "Demchok Area", "Dhekelia", 159 | "Dragonja River Mouth", "Dramana-Shakatoe Area", "Halaib Triangle", 160 | "IN-CH Small Disputed Areas", "Invernada Area", "Jan Mayen", "Kalapani Area", 161 | "Kosovo", "No Man's Land", "Paracel Is", "Siachen-Saltoro Area", 162 | "St Martin", "US Virgin Is", "Christmas I", "Cocos (Keeling) Is") 163 | 164 | 165 | drop_cols = c("system.index", ".geo") 166 | flood_mechanism = rbind(surge, snowicerain, heavyrain, dam) %>% 167 | select(-drop_cols) %>% 168 | rename('iso2c' = 'cc') %>% # renaming column 169 | mutate(country = if_else(iso2c=='US', "United States", country), # Hawaii and Alaska have weird names and regions 170 | region = if_else(iso2c=='US', "North America", region)) %>% 171 | mutate(sum=rowSums(.[,3:25])) %>%# Remove rows where no flood exposure was detected (e.g. equal to 0) 172 | filter(sum>0 & country %notin% no_country) 173 | 174 | # Add code with 3-digit iso-code 175 | iso3c = countrycode(flood_mechanism$country, origin = 'country.name', destination = 'iso3c') 176 | region = countrycode(flood_mechanism$country, origin = 'country.name', destination = 'region23') 177 | 178 | flood_mechanism$iso3c = iso3c 179 | flood_mechanism$region = region 180 | 181 | 182 | # Join main analysis and bias together 183 | oceania = c("Polynesia", "Micronesia", "Melanesia") # these regions have no floods so grouping together 184 | 185 | flood_mechanism_bias = flood_mechanism %>% 186 | left_join(bias2join, by='iso3c') %>% 187 | mutate(bias_factor = na_if(bias_factor, Inf), 188 | bias_factor = na_if(bias_factor, "NaN"), 189 | bias_factor = na_if(bias_factor, NaN), 190 | hrsl_data = if_else(is.na(bias_factor), "N", "Y"), 191 | region = if_else(region %in% oceania, "Australia and New Zealand", region)) 192 | 193 | # Calculation bias by region 194 | wb_region_bias = flood_mechanism_bias %>% 195 | group_by(region) %>% 196 | summarize(region_mean_bias = mean(bias_factor, na.rm=T), 197 | region_sd_bias = sd(bias_factor, na.rm=T)) 198 | 199 | # Join region bias estimates 200 | flood_mechanism_out = flood_mechanism_bias %>% 201 | left_join(wb_region_bias, by = 'region') %>% 202 | mutate(bias_factor = if_else(is.na(bias_factor), region_mean_bias, bias_factor)) 203 | 204 | # And DONE DONE DONE! 205 | # write.csv(flood_mechanism_out, "data/flood_mechanism_wbias.csv") 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /uncertaintyanalysis.R: -------------------------------------------------------------------------------- 1 | #main GFD numbers 2 | 3 | GFDmainstats<-read.csv('data/GFDabove_13_wBias.csv') 4 | 5 | #this script generate the uncertainty metrics and quadrat plot in the Supplementary discussion 6 | 7 | #how different would population have to be to "flip" the trend 8 | 9 | GFDmainstats$floodpop2000<-GFDmainstats$pop_2000_flood_rural+GFDmainstats$pop_2000_flood_semiurban+GFDmainstats$pop_2000_flood_urban 10 | GFDmainstats$pop2000<-(GFDmainstats$pop_2000_all_rural+GFDmainstats$pop_2000_all_semiurban+GFDmainstats$pop_2000_all_urban) 11 | GFDmainstats$pop2015<-(GFDmainstats$pop_2000_all_rural+GFDmainstats$pop_2000_all_semiurban+GFDmainstats$pop_2000_all_urban+ 12 | GFDmainstats$pop_delta_all_rural+GFDmainstats$pop_delta_all_semiurban+GFDmainstats$pop_delta_all_urban) 13 | GFDmainstats$floodpop2015<-GFDmainstats$floodpop2000+GFDmainstats$pop_delta_flood_rural+GFDmainstats$pop_delta_flood_semiurban+GFDmainstats$pop_delta_flood_urban 14 | 15 | #equation 2, solve for flood pop in 2015 if no trend were present 16 | GFDmainstats$x<-(GFDmainstats$floodpop2000/GFDmainstats$pop2000)*GFDmainstats$pop2015 17 | #euquation 3, solve for margin of error 18 | GFDmainstats$errorrange<-GFDmainstats$floodpop2015-GFDmainstats$x 19 | 20 | #estimate population in floodplain for HRSL 21 | GFDmainstats$HRSL2015<-GFDmainstats$floodpop2015*GFDmainstats$bias_factor 22 | 23 | #equation 4, uncertainty range for HRSL 24 | GFDmainstats$uncertaintyrange<-GFDmainstats$errorrange-(GFDmainstats$floodpop2015-GFDmainstats$HRSL2015) 25 | #normalize by floodpop 2015 GHSL 26 | GFDmainstats$uncperc<-GFDmainstats$uncertaintyrange/GFDmainstats$floodpop2015 27 | 28 | #exploratory graphs of the data 29 | hist((GFDmainstats$uncertaintyrange)) 30 | min(GFDmainstats$uncperc) 31 | max(GFDmainstats$uncperc) 32 | plot(GFDmainstats$uncertaintyrange/1000000,GFDmainstats$relexp) 33 | plot(GFDmainstats$uncertaintyrange,GFDmainstats$relexp) 34 | #percentchange 35 | 36 | 37 | #quadrant plot, Figure 2 in the paper 38 | library(ggplot2) 39 | library(ggrepel) 40 | p<-ggplot(GFDmainstats, aes(x=uncperc, y=relexp, color=continent, label= unit_name)) + 41 | geom_point(size=.5) + 42 | #lims(x=c(0,6),y=c(0,4)) + 43 | scale_x_continuous(limits= c(-2,2))+ 44 | #,labels=c("0" = "decreasing population", "3" = "increasing population"))+ 45 | scale_y_continuous(expand = c(0, 0), 46 | limits= c(0,6))+ 47 | #,labels=c(".5" = "population growth", "3" = "climate change"))+ 48 | #geom_label_repel(size = 1, 49 | #fill = "deepskyblue", 50 | #colour = "black", 51 | #min.segment.length = unit(0, "lines"))+ 52 | theme_minimal() + 53 | coord_fixed() + 54 | geom_vline(xintercept = 0) + geom_hline(yintercept = 1) + 55 | geom_text(aes(label = cc), 56 | position = "jitter", hjust=0.6, vjust=1.1, size = 3) + 57 | labs(x = "Uncertainty feasibility", 58 | y = "Flood trend")+ 59 | #annotate("text", x = 3, y = 0, label = "C Demographic Risk")+ 60 | annotate("text", x = 1, y = .5, label = "unc. high for dec.")+ 61 | annotate("text", x = -1.5, y = .5, label = "unc. low ")+ 62 | annotate("text", x = -1.5, y = 2.5, label = "unc. low ")+ 63 | annotate("text", x = 1, y = 4, label = " unc. high for inc.")+ 64 | theme(axis.title.x = element_text(size = 16), 65 | axis.title.y = element_text(size = 16), 66 | legend.text=element_text(size=16), legend.title=element_text(size=14)) 67 | 68 | p 69 | 70 | #remove uncertain countries, recalculte mean of trend reported in the paper 71 | #these are the uncertain countries 72 | GFDmainstatsuncertain<-subset(GFDmainstats, GFDmainstats$uncperc>0) 73 | GFDmainstatscertain<-subset(GFDmainstats, GFDmainstats$uncperc<0) 74 | 75 | #recalculate flood trend in paper if uncertain countries are remove 76 | mean(GFDmainstatscertain$relexp, na.rm=TRUE) 77 | 78 | 79 | --------------------------------------------------------------------------------