├── screen_lvl1.png ├── screen_lvl2.png ├── IUCN_mapping_legend.xlsx ├── styles ├── level1.clr ├── lvl1_style.qml ├── level2.clr └── lvl2_style.qml ├── README.md ├── KNOWNISSUES.txt ├── CHANGELOG.txt ├── LICENSE.txt └── code_buildIUCNHabitats.js /screen_lvl1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin-Jung/Habitatmapping/HEAD/screen_lvl1.png -------------------------------------------------------------------------------- /screen_lvl2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin-Jung/Habitatmapping/HEAD/screen_lvl2.png -------------------------------------------------------------------------------- /IUCN_mapping_legend.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin-Jung/Habitatmapping/HEAD/IUCN_mapping_legend.xlsx -------------------------------------------------------------------------------- /styles/level1.clr: -------------------------------------------------------------------------------- 1 | 0 0 45 225 255 Water 2 | 100 10 148 28 255 Forest 3 | 200 198 255 83 255 Savanna 4 | 300 234 160 63 255 Shrubland 5 | 400 152 250 231 255 Grassland 6 | 500 91 181 255 255 Wetlands (inland) 7 | 600 165 146 131 255 Rocky Areas 8 | 800 255 252 225 255 Desert 9 | 900 153 221 247 255 Marine - Neritic 10 | 1000 29 162 216 255 Marine - Oceanic 11 | 1100 127 205 255 255 Deep Ocean Floor 12 | 1200 76 230 230 255 Marine - Intertidal 13 | 1400 217 80 73 255 Artificial - Terrestrial 14 | 1700 255 255 255 255 Unknown -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Habitatmapping 2 | Repository for creating a habitat type map in [Google Earth Engine](https://earthengine.google.com/). 3 | 4 | The code and map is released under a Creative Commons Attribution 4.0 International license and thus can be freely shared, used or modified. 5 | The most recent version of the habitat type layer will be contained in this repository and assigned a Zenodo version number. 6 | 7 | To run the code for creating the habitat type map an account on Google Earth Engine is necessary. No Python code was developed as part of this project. Note that while the code for the habitat type map is openly available, the underlying datasets ('assets' in Google Earth Engine) are not all (yet) publicly available. Assets can be shared depending on the request, however there is no guarantee that I will host all original input assets for long, since they might change as improved data becomes available. 8 | 9 | If you want to suggest edits to the map, please use the issue functionality in github or directly fork the code and make a push request. 10 | 11 | ## Online viewer 12 | 13 | The map can be interactively navigated [here](https://uploads.users.earthengine.app/view/habitat-types-map). 14 | 15 | ## Suggested citation: 16 | 17 | Jung, M., Dahal, P.R., Butchart, S.H.M. et al. A global map of terrestrial habitat types. Sci Data 7, 256 (2020). https://doi.org/10.1038/s41597-020-00599-8 18 | 19 | Martin Jung, Prabhat Raj Dahal, Stuart H. M. Butchart, Paul F. Donald, Xavier De Lamo, Myroslava Lesiv, Valerie Kapos, Carlo Rondini & Piero Visconti. (2020). A global map of terrestrial habitat types (Version 004) [Data set]. Zenodo. https://zenodo.org/record/4058819 20 | 21 | ## Example screenshots 22 | 23 | Visualization styles files (qml and clr) can be found in the styles folder. 24 | 25 | **Level1** 26 | ![Level 1](screen_lvl1.png) 27 | 28 | **Level2** 29 | ![Level 2](screen_lvl2.png) 30 | -------------------------------------------------------------------------------- /KNOWNISSUES.txt: -------------------------------------------------------------------------------- 1 | Known Issues as of version 004: 2 | 3 | - There can be underestimates of pastoral land in South Africa, Brazil and East Asia due to the conservative pasture mask being used. 4 | 5 | - Owing to the scale of the Copernicus land cover and Global Lakes of the World (GLWD) data some rivers can be missed and seasonal dynamics misclassified. 6 | 7 | - Tidal wetlands still need to better distinguished from inland wetlands. 8 | 9 | - The Copernicus Land cover data has known artifacts (linear break) at the dateline (>180° - 0° Longitude) break. 10 | 11 | - Some errors can remain, particularly for the Copernicus Land cover data set. A list of known Limitations is given here on Page 142 (https://zenodo.org/record/3938968) 12 | 13 | - Between Copernicus v.2 and v.3 the grid cells shifted slightly in Longitude, therefore causing misalignement with the forest management layer. 14 | 15 | - The global potential seagrass layer is likely overestimated. 16 | 17 | - Land cover in the northern polar regions (Antarctica and Northpole) is a guess as the global Copernicus Land cover product does not extend that far (latitudinal range: -60 to 80). Therefore those areas are mapped as Desert / Icy Desert by default. Users interested in polar land cover are therefore encouraged to search for regional habitat and land cover products. 18 | 19 | - (Reported by Renato Augusto Ferreira de Lima) The Serra do Espinhaço range in Brazil which is mainly covered by exposed rocks and high altitude grasslands/shrublands, while the map currently indicates pasture. This will probably be fixed when better pasture data becomes available. 20 | 21 | - (Reported by Renato Augusto Ferreira de Lima) The upper Rio Negro region (Brazil, Coombia and Venezuela) is known by the occurrence of Campinaranas (similar to heat forests) over white-sand soils, ranging from grass lands to small forests. These habitats are currently not represented, probably because of fine-scale errors in Copernicus Land cover data. 22 | -------------------------------------------------------------------------------- /styles/lvl1_style.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 1 6 | 1 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | None 19 | WholeRaster 20 | Estimated 21 | 0.02 22 | 0.98 23 | 2 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 0 48 | 49 | -------------------------------------------------------------------------------- /styles/level2.clr: -------------------------------------------------------------------------------- 1 | 0 0 45 225 255 Water 2 | 100 10 148 28 255 Forest 3 | 101 17 94 78 255 Forest - Boreal 4 | 102 7 161 135 255 Forest - Subarctic 5 | 103 0 250 192 255 Forest - Subantarctic 6 | 104 39 161 112 255 Forest - Temperate 7 | 105 157 249 65 255 Forest - Subtropical-tropical dry 8 | 106 42 244 52 255 Forest - Subtropical-tropical moist lowland 9 | 107 160 254 204 255 Forest - Subtropical-tropical mangrove vegetation 10 | 108 103 126 45 255 Forest - Subtropical-tropical swamp 11 | 109 0 196 16 255 Forest - Subtropical-tropical moist montane 12 | 200 198 255 83 255 Savanna 13 | 201 245 233 54 255 Savanna - Dry 14 | 202 205 255 39 255 Savanna - Moist 15 | 300 234 160 63 255 Shrubland 16 | 301 100 88 0 255 Shrubland - Subarctic 17 | 302 123 122 96 255 Shrubland - Subantarctic 18 | 303 132 167 155 255 Shrubland - Boreal 19 | 304 154 221 212 255 Shrubland - Temperate 20 | 305 255 233 123 255 Shrubland - Subtropical-tropical dry 21 | 306 240 166 37 255 Shrubland - Subtropical-tropical moist 22 | 307 206 155 194 255 Shrubland - Subtropical-tropical high altitude 23 | 308 127 29 213 255 Shrubland - Mediterranean-type 24 | 400 152 250 231 255 Grassland 25 | 401 189 238 216 255 Grassland - Tundra 26 | 402 173 196 192 255 Grassland - Subarctic 27 | 403 38 71 88 255 Grassland - Subantarctic 28 | 404 51 185 136 255 Grassland - Temperate 29 | 405 255 245 203 255 Grassland - Subtropical-tropical dry 30 | 406 137 232 240 255 Grassland - Subtropical-tropical seasonally wet or flooded 31 | 407 250 203 255 255 Grassland - Subtropical-tropical high altitude 32 | 500 91 181 255 255 Wetlands (inland) 33 | 501 0 250 250 255 Wetlands (inland) - Permanent rivers streams creeks 34 | 502 214 160 249 255 Wetlands (inland) - Seasonal/intermittent/irregular rivers/streams/creeks 35 | 503 191 42 232 255 Wetlands (inland) - Shrub dominated wetlands 36 | 504 49 72 114 255 Wetlands (inland) - Bogs/marshes/swamps/fens/peatlands 37 | 505 14 119 217 255 Wetlands (inland) - Permanent freshwater lakes 38 | 506 110 150 196 255 Wetlands (inland) - Seasonal/intermittent freshwater lakes (over 8 ha) 39 | 507 0 173 216 255 Wetlands (inland) - Permanent freshwater marshes/pools (under 8 ha) 40 | 508 33 142 214 255 Wetlands (inland) - Seasonal/intermittent freshwater marshes/pools (under 8 ha) 41 | 509 48 31 153 255 Wetlands (inland) - Freshwater springs and oases 42 | 510 161 230 236 255 Wetlands (inland) - Tundra wetlands 43 | 511 199 225 228 255 Wetlands (inland) - Alpine wetlands 44 | 512 249 233 212 255 Wetlands (inland) - Geothermal wetlands 45 | 513 0 37 252 255 Wetlands (inland) - Permanent inland deltas 46 | 514 22 107 149 255 Wetlands (inland) - Permanent saline brackish or alkaline lakes 47 | 515 70 164 192 255 Wetlands (inland) - Seasonal/intermittent saline brackish or alkaline lakes and flats 48 | 516 62 113 224 255 Wetlands (inland) - Permanent /saline / brackish or alkaline marshes/pools 49 | 517 156 117 208 255 Wetlands (inland) - Seasonal/intermittent /saline / brackish or alkaline marshes/pools 50 | 518 255 1 188 255 Wetlands (inland) / Karst and other subterranean hydrological systems 51 | 600 165 146 131 255 Rocky Areas 52 | 800 255 252 225 255 Desert 53 | 801 255 183 1 255 Desert - Hot 54 | 802 228 233 212 255 Desert - Temperate 55 | 803 218 237 245 255 Desert - Cold 56 | 900 153 221 247 255 Marine - Neritic 57 | 901 209 236 247 255 Marine - Neritic Pelagic 58 | 908 253 124 110 255 Marine - Coral Reefs 59 | 909 134 164 117 255 Marine - Seagrass (submerged) 60 | 1000 29 162 216 255 Marine - Oceanic 61 | 1001 23 129 172 255 Marine - Epipelagic 62 | 1002 14 81 108 255 Marine - Mesopelagic 63 | 1003 8 48 64 255 Marine - Bathypelagic 64 | 1004 2 16 21 255 Marine - Abyssopelagic 65 | 1100 127 205 255 255 Marine - Deep Ocean Floor 66 | 1101 17 153 209 255 Marine - Continental Slope/Bathyl zone 67 | 1102 96 189 227 255 Marine - Abyssal Plain 68 | 1103 26 145 194 255 Marine - Abyssal Mountains/Hills 69 | 1104 2 116 149 255 Marine - Hadal/Deep Sea Trench 70 | 1105 107 174 214 255 Marine - Seamounts 71 | 1106 127 0 255 255 Marine - Deep Sea Vent 72 | 1200 76 230 230 255 Marine - Intertidal 73 | 1206 50 18 179 255 Marine - Tidepools 74 | 1207 124 217 204 255 Marine - Mangroves submerged Roots 75 | 1400 217 80 73 255 Artificial - Terrestrial 76 | 1401 255 160 131 255 Arable land 77 | 1402 255 131 202 255 Pastureland 78 | 1403 255 8 0 255 Plantations 79 | 1404 221 203 37 255 Rural Gardens 80 | 1405 0 0 0 255 Urban Areas 81 | 1406 255 22 1 255 Subtropical/Tropical Heavily Degraded Former Forest 82 | 1700 255 255 255 255 Unknown -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | _________________________________________________________________________ 2 | Version 004: 3 | 4 | - Updated underlying Copernicus data to version V.3.0.1. See technical documents here https://zenodo.org/communities/copernicus-land-cover?page=1&size=20 5 | 6 | - Added changemasks for the years 2016-2019. The changemasks are exported at 100m as change in class (new class) and at 1km as change in fractional cover (before-after). 7 | 8 | - Added description for many IUCN Marine classes in 9.X Marine Neritic, 10.X Marine Oceanic, 11.X Marine Deep Ocean Floor and 12.X Marine Intertidal. Specifically the classes added were: 9. Marine Neritic, 9.1. Marine Neritic – Pelagic, 9.8. Marine Neritic – Coral Reef, 9.9 Seagrass (Submerged), 10 Marine Oceanic, 10.1 Epipelagic (0–200 m), 10.2 Mesopelagic (200–1,000 m), 10.3 Bathypelagic (1,000–4,000 m), 10.4 Abyssopelagic (4,000–6,000 m), 11 Marine Deep Ocean Floor (Benthic and Demersal), 11.1 Continental Slope/Bathyl Zone (200–4,000 m), 11.2 Abyssal Plain (4,000–6,000 m), 11.3 Abyssal Mountain/Hills (4,000–6,000 m), 11.4 Hadal/Deep Sea Trench (>6,000 m), 11.5 Seamount, 11.6 Deep Sea Vents (Rifts/Seeps), 12 Marine Intertidal, 12.6 Tidepools, 12.7 Mangrove Submerged Roots 9 | 10 | Used data sources: 11 | Amante, C. and B. W. Eakins, ETOPO1 1 Arc-Minute Global Relief Model: Procedures, Data Sources and Analysis. NOAA Technical Memorandum NESDIS NGDC-24, 19 pp, March 2009. 12 | 13 | Becker, J. J., Sandwell, D. T., Smith, W. H. F., Braud, J., Binder, B., Depner, J. L., ... & Ladner, R. (2009). Global bathymetry and elevation data at 30 arc seconds resolution: SRTM30_PLUS. Marine Geodesy, 32(4), 355-371. 14 | 15 | Harris, P. T., Macmillan-Lawler, M., Rupp, J., & Baker, E. K. (2014). Geomorphology of the oceans. Marine Geology, 352, 4-24. 16 | Burke, L., Reytar, K., Spalding, M., & Perry, A. (2011). Reefs at risk revisited. World Resources Institute. https://www.wri.org/publication/reefs-risk-revisited 17 | 18 | Jayathilake D.R.M., Costello M.J. (2018). A modelled global distribution of the seagrass biome. Biological Conservation. https://doi.org/10.1016/j.biocon.2018.07.009 https://data.unep-wcmc.org/datasets/46 19 | 20 | Ramirez-Llodra, E. and M.C. Baker. (2006) Data on the location of hydrothermal vents. Biogeography of Chemosynthetic Ecosystems (ChEss) Project (www.noc.soton.ac.uk/chess). https://adaptwest.databasin.org/datasets/1c6af28887364008969f94c7e9df796e 21 | 22 | Yesson, C., Clark, M. R., Taylor, M. L., & Rogers, A. D. (2011). The global distribution of seamounts based on 30 arc seconds bathymetry data. Deep Sea Research Part I: Oceanographic Research Papers, 58(4), 442-453. https://doi.pangaea.de/10.1594/PANGAEA.757564 23 | 24 | - Marine Oceanic classes and the pelagic Neritic class (9.1) are __not__ mapped in the global composite map, but instead supplied separetely in the fractional exports 25 | 26 | - Changed data source for Mangrove class (Class 1.7) to Bunting et al. (2018) for the year 2015 to 2018. 27 | Bunting P., Rosenqvist A., Lucas R., Rebelo L-M., Hilarides L., Thomas N., Hardy A., Itoh T., Shimada M. and Finlayson C.M. (2018). The Global Mangrove Watch – a New 2010 Global Baseline of Mangrove Extent. Remote Sensing 10(10): 1669. doi: 10.3390/rs1010669. https://data.unep-wcmc.org/datasets/45 28 | 29 | - Improved mapping of Mangrove classes around the globe, in part overriding the mapped Copernicus land cover class, for instance if Global Mangrove Watch identifies a Mangrove, but Copernicus indicates vegetation of only height shrubland 30 | 31 | - Changed mapping of moist savanna's, now mapping wetlands and moist savannas in the everglade and pantanal better. 32 | 33 | _________________________________________________________________________ 34 | Version 003: 35 | - Updated Koeppen climate zones (Beck et al.) and biomes layer with a region growth version (increase by 5km). This accounts for small mismatches between Copernicus land area near coastlines which previously resulted in lvl1 classes being mapped to lvl2. 36 | - Fixed remote sensing issues (stripes) in the Kaspian see that originated from Copernicus land cover. 37 | 38 | _________________________________________________________________________ 39 | Version 002: 40 | - Updated plantation layer to newest estimates. Major improvements in SE-Asia and Russia particular 41 | - Used Improved Small field size from Lesiv et al. 42 | - Provided fractional data at 1km for all lvl1 and lvl2 classes 43 | - In addition to GLWD now using HydroLAKES and the JRC Water seasonality product as additional ancillary data. Order of wetland mapping changed. 44 | - Criteria for Rocky habitat (6.) adjusted, mapping overall less 45 | - Switched to Copernicus Land-cover asset available directly from GEE 46 | 47 | _________________________________________________________________________ 48 | Version 001: 49 | - Initial Release 50 | -------------------------------------------------------------------------------- /styles/lvl2_style.qml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 1 6 | 1 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | None 19 | WholeRaster 20 | Estimated 21 | 0.02 22 | 0.98 23 | 2 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 0 116 | 117 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Attribution 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution 4.0 International Public License 58 | 59 | By exercising the Licensed Rights (defined below), You accept and agree 60 | to be bound by the terms and conditions of this Creative Commons 61 | Attribution 4.0 International Public License ("Public License"). To the 62 | extent this Public License may be interpreted as a contract, You are 63 | granted the Licensed Rights in consideration of Your acceptance of 64 | these terms and conditions, and the Licensor grants You such rights in 65 | consideration of benefits the Licensor receives from making the 66 | Licensed Material available under these terms and conditions. 67 | 68 | 69 | Section 1 -- Definitions. 70 | 71 | a. Adapted Material means material subject to Copyright and Similar 72 | Rights that is derived from or based upon the Licensed Material 73 | and in which the Licensed Material is translated, altered, 74 | arranged, transformed, or otherwise modified in a manner requiring 75 | permission under the Copyright and Similar Rights held by the 76 | Licensor. For purposes of this Public License, where the Licensed 77 | Material is a musical work, performance, or sound recording, 78 | Adapted Material is always produced where the Licensed Material is 79 | synched in timed relation with a moving image. 80 | 81 | b. Adapter's License means the license You apply to Your Copyright 82 | and Similar Rights in Your contributions to Adapted Material in 83 | accordance with the terms and conditions of this Public License. 84 | 85 | c. Copyright and Similar Rights means copyright and/or similar rights 86 | closely related to copyright including, without limitation, 87 | performance, broadcast, sound recording, and Sui Generis Database 88 | Rights, without regard to how the rights are labeled or 89 | categorized. For purposes of this Public License, the rights 90 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 91 | Rights. 92 | 93 | d. Effective Technological Measures means those measures that, in the 94 | absence of proper authority, may not be circumvented under laws 95 | fulfilling obligations under Article 11 of the WIPO Copyright 96 | Treaty adopted on December 20, 1996, and/or similar international 97 | agreements. 98 | 99 | e. Exceptions and Limitations means fair use, fair dealing, and/or 100 | any other exception or limitation to Copyright and Similar Rights 101 | that applies to Your use of the Licensed Material. 102 | 103 | f. Licensed Material means the artistic or literary work, database, 104 | or other material to which the Licensor applied this Public 105 | License. 106 | 107 | g. Licensed Rights means the rights granted to You subject to the 108 | terms and conditions of this Public License, which are limited to 109 | all Copyright and Similar Rights that apply to Your use of the 110 | Licensed Material and that the Licensor has authority to license. 111 | 112 | h. Licensor means the individual(s) or entity(ies) granting rights 113 | under this Public License. 114 | 115 | i. Share means to provide material to the public by any means or 116 | process that requires permission under the Licensed Rights, such 117 | as reproduction, public display, public performance, distribution, 118 | dissemination, communication, or importation, and to make material 119 | available to the public including in ways that members of the 120 | public may access the material from a place and at a time 121 | individually chosen by them. 122 | 123 | j. Sui Generis Database Rights means rights other than copyright 124 | resulting from Directive 96/9/EC of the European Parliament and of 125 | the Council of 11 March 1996 on the legal protection of databases, 126 | as amended and/or succeeded, as well as other essentially 127 | equivalent rights anywhere in the world. 128 | 129 | k. You means the individual or entity exercising the Licensed Rights 130 | under this Public License. Your has a corresponding meaning. 131 | 132 | 133 | Section 2 -- Scope. 134 | 135 | a. License grant. 136 | 137 | 1. Subject to the terms and conditions of this Public License, 138 | the Licensor hereby grants You a worldwide, royalty-free, 139 | non-sublicensable, non-exclusive, irrevocable license to 140 | exercise the Licensed Rights in the Licensed Material to: 141 | 142 | a. reproduce and Share the Licensed Material, in whole or 143 | in part; and 144 | 145 | b. produce, reproduce, and Share Adapted Material. 146 | 147 | 2. Exceptions and Limitations. For the avoidance of doubt, where 148 | Exceptions and Limitations apply to Your use, this Public 149 | License does not apply, and You do not need to comply with 150 | its terms and conditions. 151 | 152 | 3. Term. The term of this Public License is specified in Section 153 | 6(a). 154 | 155 | 4. Media and formats; technical modifications allowed. The 156 | Licensor authorizes You to exercise the Licensed Rights in 157 | all media and formats whether now known or hereafter created, 158 | and to make technical modifications necessary to do so. The 159 | Licensor waives and/or agrees not to assert any right or 160 | authority to forbid You from making technical modifications 161 | necessary to exercise the Licensed Rights, including 162 | technical modifications necessary to circumvent Effective 163 | Technological Measures. For purposes of this Public License, 164 | simply making modifications authorized by this Section 2(a) 165 | (4) never produces Adapted Material. 166 | 167 | 5. Downstream recipients. 168 | 169 | a. Offer from the Licensor -- Licensed Material. Every 170 | recipient of the Licensed Material automatically 171 | receives an offer from the Licensor to exercise the 172 | Licensed Rights under the terms and conditions of this 173 | Public License. 174 | 175 | b. No downstream restrictions. You may not offer or impose 176 | any additional or different terms or conditions on, or 177 | apply any Effective Technological Measures to, the 178 | Licensed Material if doing so restricts exercise of the 179 | Licensed Rights by any recipient of the Licensed 180 | Material. 181 | 182 | 6. No endorsement. Nothing in this Public License constitutes or 183 | may be construed as permission to assert or imply that You 184 | are, or that Your use of the Licensed Material is, connected 185 | with, or sponsored, endorsed, or granted official status by, 186 | the Licensor or others designated to receive attribution as 187 | provided in Section 3(a)(1)(A)(i). 188 | 189 | b. Other rights. 190 | 191 | 1. Moral rights, such as the right of integrity, are not 192 | licensed under this Public License, nor are publicity, 193 | privacy, and/or other similar personality rights; however, to 194 | the extent possible, the Licensor waives and/or agrees not to 195 | assert any such rights held by the Licensor to the limited 196 | extent necessary to allow You to exercise the Licensed 197 | Rights, but not otherwise. 198 | 199 | 2. Patent and trademark rights are not licensed under this 200 | Public License. 201 | 202 | 3. To the extent possible, the Licensor waives any right to 203 | collect royalties from You for the exercise of the Licensed 204 | Rights, whether directly or through a collecting society 205 | under any voluntary or waivable statutory or compulsory 206 | licensing scheme. In all other cases the Licensor expressly 207 | reserves any right to collect such royalties. 208 | 209 | 210 | Section 3 -- License Conditions. 211 | 212 | Your exercise of the Licensed Rights is expressly made subject to the 213 | following conditions. 214 | 215 | a. Attribution. 216 | 217 | 1. If You Share the Licensed Material (including in modified 218 | form), You must: 219 | 220 | a. retain the following if it is supplied by the Licensor 221 | with the Licensed Material: 222 | 223 | i. identification of the creator(s) of the Licensed 224 | Material and any others designated to receive 225 | attribution, in any reasonable manner requested by 226 | the Licensor (including by pseudonym if 227 | designated); 228 | 229 | ii. a copyright notice; 230 | 231 | iii. a notice that refers to this Public License; 232 | 233 | iv. a notice that refers to the disclaimer of 234 | warranties; 235 | 236 | v. a URI or hyperlink to the Licensed Material to the 237 | extent reasonably practicable; 238 | 239 | b. indicate if You modified the Licensed Material and 240 | retain an indication of any previous modifications; and 241 | 242 | c. indicate the Licensed Material is licensed under this 243 | Public License, and include the text of, or the URI or 244 | hyperlink to, this Public License. 245 | 246 | 2. You may satisfy the conditions in Section 3(a)(1) in any 247 | reasonable manner based on the medium, means, and context in 248 | which You Share the Licensed Material. For example, it may be 249 | reasonable to satisfy the conditions by providing a URI or 250 | hyperlink to a resource that includes the required 251 | information. 252 | 253 | 3. If requested by the Licensor, You must remove any of the 254 | information required by Section 3(a)(1)(A) to the extent 255 | reasonably practicable. 256 | 257 | 4. If You Share Adapted Material You produce, the Adapter's 258 | License You apply must not prevent recipients of the Adapted 259 | Material from complying with this Public License. 260 | 261 | 262 | Section 4 -- Sui Generis Database Rights. 263 | 264 | Where the Licensed Rights include Sui Generis Database Rights that 265 | apply to Your use of the Licensed Material: 266 | 267 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 268 | to extract, reuse, reproduce, and Share all or a substantial 269 | portion of the contents of the database; 270 | 271 | b. if You include all or a substantial portion of the database 272 | contents in a database in which You have Sui Generis Database 273 | Rights, then the database in which You have Sui Generis Database 274 | Rights (but not its individual contents) is Adapted Material; and 275 | 276 | c. You must comply with the conditions in Section 3(a) if You Share 277 | all or a substantial portion of the contents of the database. 278 | 279 | For the avoidance of doubt, this Section 4 supplements and does not 280 | replace Your obligations under this Public License where the Licensed 281 | Rights include other Copyright and Similar Rights. 282 | 283 | 284 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 285 | 286 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 287 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 288 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 289 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 290 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 291 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 292 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 293 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 294 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 295 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 296 | 297 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 298 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 299 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 300 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 301 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 302 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 303 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 304 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 305 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 306 | 307 | c. The disclaimer of warranties and limitation of liability provided 308 | above shall be interpreted in a manner that, to the extent 309 | possible, most closely approximates an absolute disclaimer and 310 | waiver of all liability. 311 | 312 | 313 | Section 6 -- Term and Termination. 314 | 315 | a. This Public License applies for the term of the Copyright and 316 | Similar Rights licensed here. However, if You fail to comply with 317 | this Public License, then Your rights under this Public License 318 | terminate automatically. 319 | 320 | b. Where Your right to use the Licensed Material has terminated under 321 | Section 6(a), it reinstates: 322 | 323 | 1. automatically as of the date the violation is cured, provided 324 | it is cured within 30 days of Your discovery of the 325 | violation; or 326 | 327 | 2. upon express reinstatement by the Licensor. 328 | 329 | For the avoidance of doubt, this Section 6(b) does not affect any 330 | right the Licensor may have to seek remedies for Your violations 331 | of this Public License. 332 | 333 | c. For the avoidance of doubt, the Licensor may also offer the 334 | Licensed Material under separate terms or conditions or stop 335 | distributing the Licensed Material at any time; however, doing so 336 | will not terminate this Public License. 337 | 338 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 339 | License. 340 | 341 | 342 | Section 7 -- Other Terms and Conditions. 343 | 344 | a. The Licensor shall not be bound by any additional or different 345 | terms or conditions communicated by You unless expressly agreed. 346 | 347 | b. Any arrangements, understandings, or agreements regarding the 348 | Licensed Material not stated herein are separate from and 349 | independent of the terms and conditions of this Public License. 350 | 351 | 352 | Section 8 -- Interpretation. 353 | 354 | a. For the avoidance of doubt, this Public License does not, and 355 | shall not be interpreted to, reduce, limit, restrict, or impose 356 | conditions on any use of the Licensed Material that could lawfully 357 | be made without permission under this Public License. 358 | 359 | b. To the extent possible, if any provision of this Public License is 360 | deemed unenforceable, it shall be automatically reformed to the 361 | minimum extent necessary to make it enforceable. If the provision 362 | cannot be reformed, it shall be severed from this Public License 363 | without affecting the enforceability of the remaining terms and 364 | conditions. 365 | 366 | c. No term or condition of this Public License will be waived and no 367 | failure to comply consented to unless expressly agreed to by the 368 | Licensor. 369 | 370 | d. Nothing in this Public License constitutes or may be interpreted 371 | as a limitation upon, or waiver of, any privileges and immunities 372 | that apply to the Licensor or You, including from the legal 373 | processes of any jurisdiction or authority. 374 | 375 | 376 | ======================================================================= 377 | 378 | Creative Commons is not a party to its public 379 | licenses. Notwithstanding, Creative Commons may elect to apply one of 380 | its public licenses to material it publishes and in those instances 381 | will be considered the “Licensor.” The text of the Creative Commons 382 | public licenses is dedicated to the public domain under the CC0 Public 383 | Domain Dedication. Except for the limited purpose of indicating that 384 | material is shared under a Creative Commons public license or as 385 | otherwise permitted by the Creative Commons policies published at 386 | creativecommons.org/policies, Creative Commons does not authorize the 387 | use of the trademark "Creative Commons" or any other trademark or logo 388 | of Creative Commons without its prior written consent including, 389 | without limitation, in connection with any unauthorized modifications 390 | to any of its public licenses or any other arrangements, 391 | understandings, or agreements concerning use of licensed material. For 392 | the avoidance of doubt, this paragraph does not form part of the 393 | public licenses. 394 | 395 | Creative Commons may be contacted at creativecommons.org. 396 | 397 | -------------------------------------------------------------------------------- /code_buildIUCNHabitats.js: -------------------------------------------------------------------------------- 1 | var kaspian_seafix = 2 | /* color: #d63000 */ 3 | /* shown: false */ 4 | ee.FeatureCollection( 5 | [ee.Feature( 6 | ee.Geometry.Polygon( 7 | [[[50.18038630001961, 39.77872317044922], 8 | [50.18038630001961, 37.87891402335348], 9 | [52.11398005001961, 37.87891402335348], 10 | [52.11398005001961, 39.77872317044922]]], null, false), 11 | { 12 | "system:index": "0" 13 | }), 14 | ee.Feature( 15 | ee.Geometry.Polygon( 16 | [[[49.6180574638418, 42.630888564946225], 17 | [49.6180574638418, 40.98504149687882], 18 | [51.5955965263418, 40.98504149687882], 19 | [51.5955965263418, 42.630888564946225]]], null, false), 20 | { 21 | "system:index": "1" 22 | }), 23 | ee.Feature( 24 | ee.Geometry.Polygon( 25 | [[[48.7061922294668, 43.918631262542625], 26 | [48.7061922294668, 42.27422108236781], 27 | [50.3651277763418, 42.27422108236781], 28 | [50.3651277763418, 43.918631262542625]]], null, false), 29 | { 30 | "system:index": "2" 31 | }), 32 | ee.Feature( 33 | ee.Geometry.Polygon( 34 | [[[47.97305592192894, 42.67203632356086], 35 | [47.97305592192894, 42.502174262916576], 36 | [48.449587904350814, 42.502174262916576], 37 | [48.449587904350814, 42.67203632356086]]], null, false), 38 | { 39 | "system:index": "3" 40 | }), 41 | ee.Feature( 42 | ee.Geometry.Polygon( 43 | [[[48.12686451567894, 42.452543985758226], 44 | [48.12686451567894, 42.40084618145372], 45 | [48.194155775444564, 42.40084618145372], 46 | [48.194155775444564, 42.452543985758226]]], null, false), 47 | { 48 | "system:index": "4" 49 | }), 50 | ee.Feature( 51 | ee.Geometry.Polygon( 52 | [[[50.71881499087915, 40.30021437711546], 53 | [50.71881499087915, 40.299167006755376], 54 | [50.72018828189478, 40.299167006755376], 55 | [50.72018828189478, 40.30021437711546]]], null, false), 56 | { 57 | "system:index": "5" 58 | }), 59 | ee.Feature( 60 | ee.Geometry.Polygon( 61 | [[[50.7270547369729, 40.30021437711546], 62 | [50.7270547369729, 40.194347991600246], 63 | [50.92618193423853, 40.194347991600246], 64 | [50.92618193423853, 40.30021437711546]]], null, false), 65 | { 66 | "system:index": "6" 67 | })]); 68 | 69 | /* 70 | This is the script for producing a global composite layer containing classes comparable 71 | to the IUCN habitat classification. 72 | The idea is to do a two-step (Level 1, then Level 2) hierarchical mapping intersecting 73 | land cover, climatic and other layers (including land use). 74 | The script has parameters that allow specifiying different masks. For using different input adaptions to the decision tree 75 | have to be made. 76 | It generates a number of output products - for each class - that can be individually exported 77 | or in the end as overal composite layer. 78 | 79 | Scheme: https://www.iucnredlist.org/resources/habitat-classification-scheme 80 | Author: Martin Jung | Email: jung@iiasa.ac.at 81 | License: CC-BY 4.0 82 | Citation: Jung, M., Dahal, P.R., Butchart, S.H.M., Donald, P.F., De Lamo, X., Lesiv, M., Kapos, V., Rondinini, C., Visconti, P., 2020. A global map of terrestrial habitat types. Sci. Data 7, 256. https://doi.org/10.1038/s41597-020-00599-8 83 | */ 84 | 85 | // Parameters 86 | var level = 1; // Options 1 | 2 of the IUCN hierarchy 87 | var scale = 100; // Output scale (1000 is recommended, 100 Copernicus, 250m for PNV) 88 | var year = 2019; // Which Copernicus year to use 89 | var output_path = 'habitattypes'; // Google drive output folder 90 | var toasset = true; // Should the map be exported to an asset or google drive? 91 | var reduceToCop = false; // Should the output be reduced to copernicus resolution? 92 | var pasture_mask = ['glwd','hyde','hoskins'][0]; // Use gridded livestock density of the world dataset, Hyde or Hoskins as pasture mask 93 | var calculate_pnv = false; // Calculate potential natural vegetation instead (Normally Irrelavent) 94 | var version = "004"; // Current version of the habitat type layer 95 | var export_classes = false; // (true|false) Should individual classes rather than the composite be exported? 96 | var exportRegion = ee.Geometry.Rectangle([-180, -90, 180, 90], null, false); // Export region (leave unchanged, unless smaller areas need to be exported) 97 | 98 | // -------------------------------------------------------------------- // 99 | // Input asset data (not all required) // 100 | var copernicus = ee.Image("COPERNICUS/Landcover/100m/Proba-V-C3/Global/" + year).select('discrete_classification'); // Copernicus asset - Google Earth Engine Asset 101 | var treecover = ee.Image("COPERNICUS/Landcover/100m/Proba-V-C3/Global/" + year).select('tree-coverfraction'); // Copernicus asset - Google Earth Engine Asset 102 | if(year > 2015){ 103 | // Loading changemask for later years 104 | var changemask = ee.Image("COPERNICUS/Landcover/100m/Proba-V-C3/Global/" + year).select('change-confidence'); // Change Confidence mask 105 | // Get grid cells with medium or higher confidence of change 106 | changemask = changemask.expression('b(0) >= 2'); 107 | Map.addLayer(changemask.randomVisualizer(),{},'Changemask',0); 108 | } 109 | print('Loaded Copernicus for year ' + year); 110 | 111 | // The rest of the assets 112 | var koeppen = ee.Image("users/Uploads/beck_koeppenpresent_1km_expanded5km"); // Source: https://doi.org/10.1038/sdata.2018.214 113 | var srtm = ee.Image("CGIAR/SRTM90_V4"); // Google Earth Engine Asset 114 | var cifor_wetland = ee.Image("users/Uploads/TROP-SUBTROP_WetlandV2_2016_CIFOR"); // Source: https://doi.org/10.1111/gcb.13689 115 | var gmw_mangroves = ee.Image('users/Uploads/naturemap_otherdata/GMW_2015_mangroves'); // https://data.unep-wcmc.org/datasets/45 116 | var glwd = ee.Image("users/Uploads/GLWD_GlobalLakesWetlands"); // Source: https://doi.org/10.1016/j.jhydrol.2004.03.028 117 | var hydrolakes = ee.Image('users/Uploads/naturemap_otherdata/hydrolakes_100m').selfMask(); // Source: https://www.hydrosheds.org/pages/hydrolakes 118 | var GSW = ee.Image("JRC/GSW1_1/GlobalSurfaceWater").select('transition'); // Source: (doi:10.1038/nature20584) 119 | var intertidal = ee.Image("UQ/murray/Intertidal/v1_1/global_intertidal/2014-2016"); // Source: Murray, N.J., Phinn, S.R., DeWitt, M., Ferrari, R., Johnston, R., Lyons, M.B., Clinton, N., Thau, D. & Fuller, R.A. (2019) The global distribution and trajectory of tidal flats. Nature, 565, 222-225. 120 | var iiasa_smallfields = ee.Image("users/Uploads/IIASA_smallfields"); // Source: https://onlinelibrary.wiley.com/doi/full/10.1111/gcb.14492 121 | var k1 = ee.Image("users/Uploads/k1classes"); // Level 1 class from https://doi.org/10.1659/MRD-JOURNAL-D-17-00107.1 122 | var alpineBiomes = ee.Image('users/Uploads/naturemap_otherdata/AlpineShapes'); // Rasterized from https://onlinelibrary.wiley.com/doi/10.1111/ecog.05012 123 | var biomes = ee.Image("users/Uploads/biomes_1km_expanded5km"); // Reclassified Google Earth Engine Asset 124 | var biomecog = ee.FeatureCollection("RESOLVE/ECOREGIONS/2017"); // Google Earth Engine Asset 125 | var FMlayer = ee.Image("users/Uploads/naturemap_otherdata/FML_v32"); // Small fix for nodata values. equal to zenodo version 126 | //var FMlayer = ee.Image('users/Uploads/naturemap_otherdata/plantation_extent'); // Source: https://zenodo.org/record/3931930/ 127 | var pasture = ee.Image("users/Uploads/naturemap_otherdata/PAS_1km_2005_0ice"); // Source: https://doi.org/10.1002/ece3.2104 128 | var globallivestockdensity = ee.Image("users/Uploads/naturemap_otherdata/LifestockDensity_grazingonly_mask_Aw_LSU"); // Prepared mask, data from Source: http://dx.doi.org/10.1038/sdata.2018.227 129 | var hyde = ee.Image("users/Uploads/naturemap_otherdata/HYDEPasture2015_fraction"); // Source: https://doi.org/10.1007/s10584-011-0153-2 130 | var pnv = ee.Image("users/Uploads/habitattypes/pnv_potentiallandcover_probavlc100_c_250m_s00cm_2017_v05"); // Potential natural land cover (only available as variant) 131 | // Add Caspian sea fix // 132 | var kaspian_seafix_image = ee.Image().byte(); 133 | kaspian_seafix_image = kaspian_seafix_image.paint({ 134 | featureCollection: kaspian_seafix, 135 | color: 1 136 | }); 137 | // --------------------------------- // 138 | // --> Marine data 139 | // Global seabed geomorphic data 140 | var marine_seabedzones = ee.Image('users/Uploads/naturemap_otherdata/marine/HarrisEtAl_SeafloorGeomorphic_rasterized'); 141 | var abyss_class = ee.FeatureCollection('users/Uploads/naturemap_otherdata/marine/HarrisEtAl_AbyssClassification'); 142 | var seamounts = ee.FeatureCollection('users/Uploads/naturemap_otherdata/marine/YessonEtAl_SeamountsBaseAreaSmoothed'); 143 | var vents = ee.FeatureCollection('users/Uploads/naturemap_otherdata/marine/RamirezLlodraAndBaker_seavents_outdated'); 144 | var ocean_bedrock = ee.Image('NOAA/NGDC/ETOPO1').select('bedrock'); // Ocean bedrock 145 | var coral_reefs = ee.FeatureCollection('users/Uploads/naturemap_otherdata/marine/WRI_reefsAtRisk_smoothedmultipart'); // WRI Reefs at Risk 146 | var seagrass = ee.FeatureCollection('users/Uploads/naturemap_otherdata/marine/JayathilakeAndCostello_Seagrass_smoothed'); // Jayathilake D.R.M., Costello M.J. 2018. A modelled global distribution of the seagrass biome. Biological Conservation. https://doi.org/10.1016/j.biocon.2018.07.009 147 | // Kelp -> https://biogeoscienceslaboxford.users.earthengine.app/view/kelpforests 148 | // -------------------------------------------------------------------- // 149 | // #################################################################### // 150 | // Start of code 151 | // #################################################################### // 152 | // -------------------------------------------------------------------- // 153 | var reprojectImage = function(image){ 154 | // Use the Beck et al. Koeppen layer as reference template 155 | if(scale < 500){ 156 | // If scale is below 500 use copernicus other koeppen for 1km 157 | var targProj = copernicus.projection(); 158 | } else { 159 | var targProj = koeppen.projection(); 160 | } 161 | image = image.reproject({crs: targProj}); 162 | var res = image.reproject(image.projection()) 163 | // Force the next reprojection to aggregate instead of resampling. 164 | .reduceResolution({ 165 | reducer: ee.Reducer.mode(), 166 | maxPixels: 1024 167 | }) 168 | // Request the data at the scale and projection at gfsad 169 | .reproject({ 170 | crs: targProj 171 | }); 172 | return(res); 173 | }; 174 | 175 | // Function for adding a changemask 176 | var updateComposite = function(comp_earlier,changemask){ 177 | // Mask out all gridcells from previous year 178 | var y = comp_earlier.mask(changemask.unmask().expression('b(0) == 0')); 179 | var z = y.unmask().add(changemask.unmask()); 180 | return(z); 181 | }; 182 | 183 | var createOutput = function(image,output_path,name,scale){ 184 | // Export wrapper 185 | if(toasset){ 186 | Export.image.toAsset({ 187 | image: image, 188 | description: name, 189 | assetId: output_path, 190 | scale: 100, // Overwrote this since this is the default projection 191 | // scale: image.projection().nominalScale().getInfo(), 192 | region: exportRegion, 193 | maxPixels: 1e13, 194 | pyramidingPolicy: { 195 | '.default': 'mode', 196 | } 197 | }); 198 | } else { 199 | Export.image.toDrive({ 200 | image: image, 201 | description: name, 202 | folder: output_path, 203 | scale: scale, 204 | // scale: image.projection().nominalScale().getInfo(), 205 | region: exportRegion, 206 | fileFormat: 'GeoTIFF', 207 | maxPixels: 1e12, 208 | formatOptions: { 209 | cloudOptimized: false 210 | } 211 | }); 212 | } 213 | }; 214 | 215 | // Resampling function to Copernicus 216 | var resampleToCopernicus = function(image){ 217 | var res = image.resample('bilinear').reproject({ 218 | crs: copernicus.projection().crs(), 219 | scale: copernicus.projection().nominalScale() 220 | }); 221 | return(res); 222 | }; 223 | 224 | // --------------------------------------------- // 225 | print('Preparing input data'); 226 | 227 | // Get ther elevation data from the SRTM mission 228 | var elevation = srtm.select('elevation'); 229 | var elev_products = ee.Terrain.products(elevation); 230 | 231 | // Now prepare global mountain mask 232 | var mountains = k1.rename('mountains'); 233 | if(reduceToCop){mountains = resampleToCopernicus(mountains);} 234 | 235 | // ------------- // 236 | // Köppen-Geiger climate zoneing by Beck et al. 237 | koeppen = koeppen.rename('koeppen'); 238 | if(reduceToCop){koeppen = resampleToCopernicus(koeppen);} 239 | 240 | // IIASA small field dataset 241 | //iiasa_smallfields = iiasa_smallfields//.expression('b(0) == 3506 || b(0) == 3505').rename('iiasa_smallfields'); 242 | if(reduceToCop){iiasa_smallfields = resampleToCopernicus(iiasa_smallfields);} 243 | 244 | // Forest management layer 245 | var forestmanagement = FMlayer.rename('plantation'); 246 | //11 – forest without any signs of human impact 247 | //20 - forest with signs of human impact, including clear cuts, logging, built-up roads. 248 | //31 – replanted forest, forest with rotation period longer than 20 years 249 | //32 - woody plantations, rotation period of maximum 15 years 250 | //40 – oil palm plantations 251 | //53 – agroforestry, including fruit tree plantations, tree shelterbelts, individual trees on pastures 252 | forestmanagement = forestmanagement.expression('b(0) >= 31 && b(0) <= 53').rename('plantation'); 253 | // No resampling necessary. Already at Copernicus resolution 254 | 255 | // Prepare the Land cover data 256 | if(calculate_pnv){ 257 | var LC = pnv; // Normal Copernicus layer 258 | var pnv_watermask = hydrolakes.expression('b(0) >0').unmask().remap([1],[80]); 259 | LC = LC.unmask(pnv_watermask); 260 | } else { 261 | var LC = copernicus; // Normal Copernicus layer 262 | } 263 | // Global land area mask for the marine class 264 | var land_mask = LC.unmask().expression('b(0) < 200 && b(0) != 0'); 265 | // Create buffered landmask to be set to neritic if no other marine class present 266 | var land_buffered = land_mask.unmask().distance(ee.Kernel.euclidean({radius:50,units:'pixels'})) 267 | .expression('b(0)>0').selfMask(); 268 | // Now remove areas with positive elevation 269 | var land_buffered2 = land_buffered.addBands(elevation).expression('b(0) == 1 && b(1) > 0'); 270 | land_buffered = land_buffered.subtract(land_buffered2.unmask()).selfMask(); 271 | 272 | // Resample the bedrock data 273 | ocean_bedrock = ocean_bedrock.resample('bilinear'); 274 | 275 | // Same for the abyss classifcation 276 | abyss_class = abyss_class 277 | .filter(ee.Filter.notNull(['code'])) 278 | .reduceToImage({ 279 | properties: ['code'], 280 | reducer: ee.Reducer.max() 281 | }); 282 | // For the Seamounts 283 | seamounts = seamounts 284 | .filter(ee.Filter.notNull(['code'])) 285 | .reduceToImage({ 286 | properties: ['code'], 287 | reducer: ee.Reducer.max() 288 | }); 289 | // Vents 290 | vents = vents.map(function(f){ return f.buffer(1000)}) 291 | .filter(ee.Filter.notNull(['code'])) 292 | .reduceToImage({ 293 | properties: ['code'], 294 | reducer: ee.Reducer.max() 295 | }); 296 | 297 | // Coral Reefs 298 | coral_reefs = coral_reefs 299 | .filter(ee.Filter.notNull(['code'])) 300 | .reduceToImage({ 301 | properties: ['code'], 302 | reducer: ee.Reducer.max() 303 | }); 304 | // Seagrass 305 | // Coral Reefs 306 | seagrass = seagrass 307 | .filter(ee.Filter.notNull(['code'])) 308 | .reduceToImage({ 309 | properties: ['code'], 310 | reducer: ee.Reducer.max() 311 | }); 312 | 313 | // Buffered Mangroves for overlap with intertidal area 314 | var mangrove_buffered = gmw_mangroves 315 | .convolve(ee.Kernel.euclidean({radius:500,units:'meters'})).expression('b(0)>0'); 316 | 317 | // ---- // 318 | // Apply a focal_mode filter to the GLWD data to account for wall-wall uncertainties. 319 | // This will only affect the classes within the tenary statement 320 | glwd = glwd.focal_mode(5); // 5 Units 321 | if(reduceToCop){glwd = resampleToCopernicus(glwd);} 322 | 323 | // Prepare the CIFOR Tropical wetland layer 324 | // Please cite this work as: Gumbricht et al. (2017) An expert system model for mapping tropical wetlands and peatlands reveals South America as the largest contributor. Global Change Biology. DOI: 10.1111/gcb.13689 325 | // Open Water = 10 | Mangrove = 20 | Swamps = 30 | Fens = 40 | Riverine and lacustrine = 50 | Floodplains = 60/70 326 | // Marshed = 80/90/100 327 | if(reduceToCop){ cifor_wetland = resampleToCopernicus(cifor_wetland);} 328 | 329 | // Copernicus tree cover. Project to 1km and reduce by average 330 | if(calculate_pnv){ 331 | // Assume 100% tree cover everywhere by default 332 | var treecovermask = ee.Image.constant(100).rename('treecovermask'); 333 | } else { 334 | var treecovermask = treecover.rename('treecovermask'); 335 | if(reduceToCop){ 336 | var treecovermask = treecovermask.reproject({crs: koeppen.projection()}) 337 | .reduceResolution({ 338 | reducer: ee.Reducer.mean(), 339 | maxPixels: 1024 340 | }); 341 | } 342 | } 343 | 344 | // For degraded forest? 345 | // TODO: 346 | //var copernicus = ee.ImageCollection("COPERNICUS/Landcover/100m/Proba-V/Global").select('discrete_classification').max(); // Copernicus asset - Google Earth Engine Asset 347 | //var treecover = ee.ImageCollection("COPERNICUS/Landcover/100m/Proba-V/Global").select('tree-coverfraction').max(); // Copernicus asset - Google Earth Engine Asset 348 | //var x = copernicus.addBands(treecover).expression('b(0) & (b(1) < 25)').selfMask() 349 | //Map.addLayer(x) 350 | 351 | // Get the Global biomes and realms 352 | biomes = biomes.rename('biomes'); 353 | 354 | // Global tropics & subtropics mask 355 | //var subtropics = ee.Image.pixelLonLat().select('latitude').expression("b(0) >= -23.5 && b(0) <= 23.5").selfMask(); 356 | var subtropics = biomes.addBands( ee.Image.pixelLonLat().select('latitude').expression("b(0) >= -23.5 && b(0) <= 23.5") ).expression('b(0) >= 1 && b(0) <= 3 || b(0) == 7 || b(1) == 1 ').selfMask();// Subtropics based on biomes 357 | // For Rural gardens we create a mask that convolves close to urban/rural areas 358 | var urban_boundary_ring = LC.expression("b(0) == 50").convolve(ee.Kernel.euclidean({radius:500,units:'meters'})).expression('b(0)>0'); 359 | var urban_boundary = urban_boundary_ring.subtract( LC.expression("b(0) == 50") ).selfMask(); 360 | if(reduceToCop){urban_boundary = resampleToCopernicus(urban_boundary)} 361 | 362 | print('Using pasture mask = ',pasture_mask); 363 | if(pasture_mask === 'glwd'){ 364 | // Thresholded gridded livestock of the world data 365 | var pasture = globallivestockdensity.rename('glwd').addBands(koeppen).addBands(LC.rename('LC')); 366 | pasture = pasture.expression( 367 | "((glwd >= 1) && ( (koeppen >= 1 && koeppen <= 2) || (koeppen >= 8 && koeppen <= 16) || (koeppen >= 17 && koeppen <= 18) || (koeppen >= 21 && koeppen <= 22) || (koeppen >= 25 && koeppen <= 26) )) ? 1" + 368 | ": 0", 369 | { 370 | 'glwd': pasture.select('glwd'), 371 | 'LC': pasture.select('LC'), 372 | 'koeppen': pasture.select('koeppen') 373 | }); 374 | pasture = pasture.rename('pasture');//lifestock_density.rename('pasture');// Make a global mask 375 | } else if(pasture_mask === 'hoskins') { 376 | // Make global pasture mask with raw hoskins dat 377 | var pasture = pasture.rename('hoskins').addBands(mountains).addBands(biomes.rename('biomes')).addBands(LC.rename('LC')).addBands(koeppen); 378 | pasture = pasture.expression( 379 | // Tropical climates 380 | // "(koeppen >= 1 && koeppen <= 3) && ((LC == 30 && hoskins > 0.5) || (LC == 20 && hoskins > 0.5)) ? 1 " + 381 | // Arid climates 382 | // ": (koeppen >= 4 && koeppen <= 8) && ((LC == 30 && hoskins > 0.9) || (LC == 20 && hoskins > 0.9)) ? 1 " + 383 | // Temperate climates 384 | // ": (koeppen >= 9 && koeppen <= 27) && ((LC == 30 && hoskins > 0.5) || (LC == 20 && hoskins > 0.5)) ? 1 " + 385 | // Bare spare vegetation and moss lichen set to a different threshold 386 | // ": (LC == 100 && hoskins > 0.8) || (LC == 60 && hoskins > 0.8) ? 1 " + 387 | "(hoskins >= 0.5) ? 1" + 388 | ": 0", 389 | { 390 | 'hoskins': pasture.select('hoskins'), 391 | 'LC': pasture.select('LC'), 392 | 'biome': pasture.select('biomes'), 393 | 'mountains': pasture.select('mountains').expression('b(0) >= 1'), 394 | 'koeppen': pasture.select('koeppen') 395 | }); 396 | pasture = pasture.rename('pasture');//lifestock_density.rename('pasture');// Make a global mask 397 | //Map.addLayer(pasture.selfMask().randomVisualizer()); 398 | } else if(pasture_mask === 'hyde') { 399 | // Apply a threshold of 50% pasture cover 400 | var pasture = hyde.expression('b(0) > .5').rename('pasture') 401 | } 402 | 403 | if(reduceToCop){pasture = resampleToCopernicus(pasture);} 404 | 405 | // -------------------------------------------------------------------- // 406 | // #################################################################### // 407 | 408 | print('Processing Rocky areas and deserts - 6 + 8'); 409 | var iucn_desert_lvl1 = LC.expression('b(0) == 60 || b(0) == 70 || b(0) == 100').rename('desert'); 410 | if(calculate_pnv){ 411 | iucn_desert_lvl1 = LC.expression('b(0) == 60 || b(0) == 70 || b(0) == 100 || b(0) == 21').rename('desert'); 412 | } 413 | iucn_desert_lvl1 = iucn_desert_lvl1.addBands(koeppen).addBands(mountains).addBands(LC.rename('LC')).addBands(elev_products); 414 | iucn_desert_lvl1 = iucn_desert_lvl1.expression( 415 | "((LC == 60 || LC == 100) && ( mountains <= 3 || slope > 8.75 ) ) ? 600" + // 6 Rocky Areas (e.g., inland cliffs, mountain peaks) 416 | ": (desert == 1 && ((koeppen >= 4 && koeppen <= 7) || koeppen >= 29)) ? 800" + // 800 Desert 417 | ": (koeppen == 29 || koeppen == 30) ? 800" + // Everything icy being a desert otherwise 418 | ": 0 ",{ 419 | 'desert': iucn_desert_lvl1.select('desert'), 420 | 'LC': iucn_desert_lvl1.select('LC'), 421 | 'mountains': iucn_desert_lvl1.select('mountains'), 422 | 'slope': iucn_desert_lvl1.select('slope'), 423 | 'elevation': iucn_desert_lvl1.select('elevation'), 424 | 'koeppen': iucn_desert_lvl1.select('koeppen') 425 | }).rename('comp'); 426 | // Mask out land area 427 | iucn_desert_lvl1 = iucn_desert_lvl1.selfMask(); 428 | 429 | // ------- 430 | var iucn_desert_lvl2 = iucn_desert_lvl1.rename('desert'); 431 | iucn_desert_lvl2 = iucn_desert_lvl2.addBands(koeppen).addBands(elev_products.select('elevation')); 432 | iucn_desert_lvl2 = iucn_desert_lvl2.expression( 433 | "(desert == 600) ? 600" + // Rocky cliff 434 | ": (desert == 800 && koeppen == 4) ? 801" + // 8.1. Desert – Hot 435 | ": (desert == 800 && (koeppen >= 5 && koeppen <= 6)) ? 802" + // 8.2. Desert – Temperate 436 | ": (desert == 800 && (koeppen == 7 || koeppen >= 29)) ? 803" + // 8.3. Desert – Cold 437 | ": (desert == 800) ? 800" + 438 | ": 0 ",{ 439 | 'desert': iucn_desert_lvl2.select('desert'), 440 | 'elevation': iucn_desert_lvl2.select('elevation'), 441 | 'koeppen': iucn_desert_lvl2.select('koeppen') 442 | }).rename('comp'); 443 | // Mask out land area 444 | iucn_desert_lvl2 = iucn_desert_lvl2.selfMask(); 445 | 446 | // -------------------------------------------------------------------- // 447 | print('Processing artifical terrestrial - 14'); 448 | var iucn_artific = LC.rename('artific'); // Take all land cover classes for now 449 | iucn_artific = iucn_artific.addBands(pasture).addBands(iiasa_smallfields.rename('iiasa_smallfields')).addBands(subtropics.unmask().add(1).rename('subtropics')) 450 | .addBands(urban_boundary.rename("urbanboundary")) 451 | .addBands(mountains.selfMask()) 452 | .addBands(treecovermask) 453 | .addBands(forestmanagement) 454 | .addBands(iucn_desert_lvl1.rename("desert")); 455 | 456 | var iucn_artific = iucn_artific.expression( 457 | "((subtropics == 2 && iiasa_smallfields == 1) && (LC == 40 && urbanboundary == 1) ) ? 1404" + // 14.4 Rural Gardens 458 | ": (LC == 40 ) ? 1401" + // 14.1 Arable Land 459 | ": ((LC == 30 || LC == 20 || LC == 100 || LC == 60) && pasture == 1) ? 1402" + // 14.2 Pastureland 460 | ": (plantation == 1 && ((LC >= 111 && LC <= 116) || ((LC >= 111 && LC <= 126) && subtropics == 1 )) ) ? 1403" + // 14.3 Plantations 461 | ": (LC == 50 ) ? 1405" + // 14.5 Urban Areas 462 | ": (LC == 50 || LC == 40 ) ? 1400" + // Alternative 463 | ": 0 ",{ // Other class 464 | 'LC': iucn_artific.select('artific'), 465 | 'urbanboundary': iucn_artific.select('urbanboundary'), 466 | 'pasture': iucn_artific.select('pasture'), 467 | 'treecovermask' : iucn_artific.select('treecovermask'), 468 | 'mountains': iucn_artific.select('mountains').expression('b(0) >= 1'), 469 | 'plantation': iucn_artific.select('plantation'), 470 | 'subtropics': iucn_artific.select('subtropics'), 471 | 'iiasa_smallfields': iucn_artific.select('iiasa_smallfields') 472 | }).rename('comp'); 473 | // Mask out land area 474 | 475 | // Use PNV instead 476 | if(calculate_pnv){ 477 | // No artifical land cover's in here, so empty image 478 | iucn_artific = ee.Image.constant(0).rename('comp'); 479 | } else { 480 | iucn_artific = iucn_artific.unmask(); 481 | } 482 | 483 | print('Starting with forest - 1'); 484 | var iucn_forest_lvl1 = LC.expression('(b(0) >= 111 && b(0) <= 126) ').rename('forest'); 485 | if(calculate_pnv){ 486 | iucn_forest_lvl1 = LC.expression('(b(0) >= 111 && b(0) <= 127) ').rename('forest'); 487 | } 488 | iucn_forest_lvl1 = iucn_forest_lvl1.addBands(koeppen).addBands(treecovermask) 489 | .addBands(gmw_mangroves.unmask().rename('mangroves')) 490 | .addBands(LC.rename('LC')); 491 | 492 | // Edited so that mangroves overrule Copernicus if in doubt 493 | var iucn_forest_lvl1 = iucn_forest_lvl1.expression( 494 | "(LC >= 111 && LC <= 116) ? 100" + // All closed forest 495 | ": ( mangroves == 1 && ((LC == 90 || LC == 20 ) || (LC >= 121 && LC <= 126) ) ) ? 100" + // Special case for mangrove vegetation 496 | ": (forest == 1 && treecovermask >= 50) ? 100" + // Forest 497 | ": 0",{ 498 | 'forest': iucn_forest_lvl1.select('forest'), 499 | 'LC': iucn_forest_lvl1.select('LC'), 500 | 'mangroves': iucn_forest_lvl1.select('mangroves'), 501 | 'treecovermask': iucn_forest_lvl1.select('treecovermask'), 502 | 'koeppen': iucn_forest_lvl1.select('koeppen') 503 | }).rename('comp'); 504 | // Self Mask 505 | iucn_forest_lvl1 = iucn_forest_lvl1.selfMask(); 506 | // Map out anything that is artifical 507 | iucn_forest_lvl1 = iucn_forest_lvl1.updateMask(iucn_artific.expression('(b(0) == 0)')); 508 | 509 | // -------------------- // 510 | // For Level 2 511 | if(calculate_pnv){ 512 | // Take the mangrove class 513 | var pot_mangroves = LC.expression('b(0) == 127'); 514 | var subtropics = subtropics.unmask().add(1).rename("subtropics"); 515 | var swamps = cifor_wetland.addBands(koeppen).expression('b(0)>20 && (b(1) >=1 && b(1) < 3) '); 516 | 517 | var iucn_forest_lvl2 = iucn_forest_lvl1.rename('forest'); 518 | iucn_forest_lvl2 = iucn_forest_lvl2.addBands(koeppen) 519 | .addBands(LC.rename("LC")) 520 | .addBands(biomes) 521 | .addBands(subtropics) 522 | .addBands(mountains).addBands(ee.Image.pixelLonLat()) 523 | .addBands(swamps.rename('swamp')) // Wetland cifor set to 1 524 | .addBands(pot_mangroves.rename('mangroves')) 525 | .addBands(elev_products.select('elevation')); 526 | } else{ 527 | var iucn_forest_lvl2 = iucn_forest_lvl1.rename('forest'); 528 | iucn_forest_lvl2 = iucn_forest_lvl2.addBands(koeppen) 529 | .addBands(LC.rename("LC")) 530 | .addBands(biomes) 531 | .addBands(subtropics.unmask().add(1).rename("subtropics")) 532 | .addBands(mountains).addBands(ee.Image.pixelLonLat()) 533 | .addBands(gmw_mangroves.unmask().rename('mangroves')) 534 | .addBands(cifor_wetland.expression('b(0) >= 30 && b(0) <= 60').rename('swamp')) 535 | .addBands(elev_products.select('elevation')); 536 | } 537 | 538 | var iucn_forest_lvl2 = iucn_forest_lvl2.expression( 539 | "((forest == 100 && mountains == 1 && subtropics == 2) && ((koeppen >=1 && koeppen < 3) || ((koeppen == 12 || koeppen == 15) && elevation >= 1200 ) || ((koeppen >= 8 && koeppen <= 9) && biome == 3)) || ((biome == 10 || biome ==1) && (koeppen >= 9 && koeppen <= 10) ) || ( (biome == 1 && koeppen >=22) || (biome == 10 && koeppen >=29)) ) ? 109" + // 1.9. Forest – Subtropical/tropical moist montane 540 | ": ((forest == 100 && mangroves == 1 ) ) ? 107" + // 1.7. Forest – Subtropical/tropical mangrove vegetation above high tide level 541 | ": ( mangroves == 1 && ((LC == 90 || LC == 20 ) || (LC >= 121 && LC <= 126) ) ) ? 107" + // 1.7. Forest – Subtropical/tropical mangrove vegetation above high tide level 542 | ": (forest == 100 && swamp == 1) ? 108" + // 1.8. Forest – Subtropical/tropical swamp 543 | ": (forest == 100 && ((koeppen >= 1 && koeppen <= 2) || (koeppen == 11) || ( subtropics == 2 && (koeppen >= 12 && koeppen <= 15 )) || (subtropics == 2 && ((koeppen >= 8 && koeppen <= 9) && biome == 3)) ) ) ? 106" + // 1.6. Forest – Subtropical/tropical moist lowland 544 | // Moved temperate here 545 | ": ((forest == 100 && subtropics == 1) && ((koeppen >= 8 && koeppen <= 10) || ( koeppen >= 12 && koeppen <= 16) || (koeppen >= 17 && koeppen <= 18) || (koeppen >= 21 && koeppen <= 26) || ( biome >= 4 && biome <= 5) || (biome == 8 && koeppen == 7) ) ) ? 104" + // 1.4. Forest – Temperate 546 | ": (forest == 100 && ((subtropics == 2 && (koeppen >= 3 && koeppen <= 7)) || (biome >= 12 && biome <= 13) || (biome == 2) || (biome == 8 && (koeppen == 6 || koeppen == 4) ) ) ) ? 105" + // 1.5. Forest – Subtropical/tropical dry 547 | ": (forest == 100 && (biome == 11 && koeppen == 30 )) ? 102" + // 1.2. Forest - Subarctic 548 | ": (forest == 100 && (latitude > 45 && ((koeppen >= 27 && koeppen <= 29) || (koeppen >= 19 && koeppen <= 20) || (koeppen >= 23 && koeppen <= 24) || (biome == 6 && koeppen == 7) )) ) ? 101" + // 1.1. Forest – Boreal 549 | ": (forest == 100 && ((latitude < 0 && subtropics == 1) && (koeppen == 16 || (koeppen >= 29 && koeppen <= 30 )) ) ) ? 103" + // 1.3. Forest – Subantarctic 550 | ": (forest == 100) ? 100" + // Higher class. Identity unknown 551 | ": 0",{ 552 | 'forest': iucn_forest_lvl2.select('forest'), 553 | 'LC': iucn_forest_lvl2.select('LC'), 554 | 'biome' : iucn_forest_lvl2.select('biomes'), 555 | 'koeppen': iucn_forest_lvl2.select('koeppen'), 556 | 'mangroves': iucn_forest_lvl2.select('mangroves'), 557 | 'mountains': iucn_forest_lvl2.select('mountains').expression('b(0) >= 1'), 558 | 'elevation': iucn_forest_lvl2.select('elevation'), 559 | 'swamp' : iucn_forest_lvl2.select('swamp'), 560 | 'subtropics' : iucn_forest_lvl2.select('subtropics'), 561 | 'latitude': iucn_forest_lvl2.select('latitude') 562 | }).rename('comp'); 563 | // Mask out land area 564 | iucn_forest_lvl2 = iucn_forest_lvl2.selfMask(); 565 | // ------------- // 566 | print('Processing savanna - 2'); 567 | if(calculate_pnv) 568 | { // Reset tree cover mask for Savanna mapping 569 | treecovermask = ee.Image.constant(0).rename('treecovermask'); 570 | } 571 | var iucn_savanna_lvl1 = LC.expression('b(0) == 20 || b(0) == 30 || (b(0) >= 121 && b(0) <= 126)').rename('savanna'); 572 | iucn_savanna_lvl1 = iucn_savanna_lvl1.addBands(koeppen) 573 | .addBands(subtropics.unmask().add(1).rename("subtropics")) 574 | .addBands(LC.rename('LC')) 575 | .addBands(biomes) 576 | .addBands(ee.Image.pixelLonLat()).addBands(treecovermask); 577 | 578 | var iucn_savanna_lvl1 = iucn_savanna_lvl1.expression( 579 | "((savanna == 1 && koeppen == 3) && treecovermask < 50 ) ? 200" + // Broad Savanna class 580 | ": (savanna == 1 && ((subtropics == 2 && (koeppen == 6 || koeppen == 11 || koeppen == 14)) && treecovermask < 50)) ? 200" + // Broad Savanna class 581 | ": (savanna == 1 && koeppen == 6 && treecovermask < 50) ? 200" + // Default Savanna 582 | ": ((LC == 90 && biome == 9) && treecovermask < 50) ? 200 " +// Flooded grassland biome as special case for moist savannas 583 | ": 0",{ 584 | 'treecovermask' : iucn_savanna_lvl1.select('treecovermask'), 585 | 'savanna': iucn_savanna_lvl1.select('savanna'), 586 | 'LC': iucn_savanna_lvl1.select('LC'), 587 | 'biome': iucn_savanna_lvl1.select('biomes'), 588 | 'subtropics' : iucn_savanna_lvl1.select('subtropics'), 589 | 'latitude': iucn_savanna_lvl1.select('latitude'), 590 | 'koeppen': iucn_savanna_lvl1.select('koeppen') 591 | }).rename('comp'); 592 | // Mask out land area 593 | iucn_savanna_lvl1 = iucn_savanna_lvl1.selfMask(); 594 | // Map out anything that is artifical 595 | iucn_savanna_lvl1 = iucn_savanna_lvl1.updateMask(iucn_artific.expression('(b(0) == 0)')); 596 | 597 | // ---------------- 598 | // Level 2 savanna 599 | var iucn_savanna_lvl2 = iucn_savanna_lvl1.rename('savanna'); 600 | iucn_savanna_lvl2 = iucn_savanna_lvl2 601 | .addBands(koeppen) 602 | .addBands(LC.rename('LC')) 603 | .addBands(biomes); 604 | 605 | iucn_savanna_lvl2 = iucn_savanna_lvl2.expression( 606 | "((savanna == 200 && LC == 90) && biome == 9) ? 202" + // 2.2. Savanna - Moist (special case for paternal) 607 | ": (savanna == 200 && ((koeppen == 3 || koeppen == 4 || koeppen == 6) ) ) ? 201" + // 2.1. Savanna - Dry 608 | ": (savanna == 200 && ((koeppen == 11 || koeppen == 14) || ((koeppen == 3 || koeppen == 6) && biome == 9 ) ) ) ? 202" + // 2.2. Savanna - Moist 609 | ": savanna == 200 ? 200" + 610 | ": 0",{ // Default Savanna 611 | 'savanna': iucn_savanna_lvl2.select('savanna'), 612 | 'LC': iucn_savanna_lvl2.select('LC'), 613 | 'biome' : iucn_savanna_lvl2.select('biomes'), 614 | 'koeppen': iucn_savanna_lvl2.select('koeppen') 615 | }).rename('comp'); 616 | // Mask out land area 617 | iucn_savanna_lvl2 = iucn_savanna_lvl2.selfMask(); 618 | 619 | // ------------- // 620 | print('Processing Shrubland - 3'); 621 | var iucn_shrub_lvl1 = LC.expression('b(0) == 20 || (b(0) >= 121 && b(0) <= 126) ').rename('shrub'); 622 | iucn_shrub_lvl1 = iucn_shrub_lvl1.addBands(koeppen.rename('koeppen')) 623 | .addBands(iucn_artific.rename("artific")).addBands(iucn_savanna_lvl1.rename('savanna')).addBands(treecovermask); 624 | 625 | iucn_shrub_lvl1 = iucn_shrub_lvl1.expression( 626 | "(shrub == 1 && savanna == 0) ? 300" + // 3. Shrubland 627 | ": (shrub == 1 && treecovermask < 50) ? 300" + 628 | ": 0",{ 629 | 'treecovermask' : iucn_shrub_lvl1.select('treecovermask'), 630 | 'savanna' : iucn_shrub_lvl1.select('savanna').unmask().expression("b(0) > 0"), // To remove savanna's 631 | 'shrub': iucn_shrub_lvl1.select('shrub'), 632 | 'koeppen': iucn_shrub_lvl1.select('koeppen') 633 | }).rename('comp'); 634 | // Mask out land area 635 | iucn_shrub_lvl1 = iucn_shrub_lvl1.selfMask(); 636 | // Map out anything that is artifical 637 | iucn_shrub_lvl1 = iucn_shrub_lvl1.updateMask(iucn_artific.expression('(b(0) == 0)')); 638 | 639 | // ------------------- 640 | var iucn_shrub_lvl2 = iucn_shrub_lvl1.rename('shrub'); 641 | iucn_shrub_lvl2 = iucn_shrub_lvl2.addBands(koeppen.rename('koeppen')) 642 | .addBands(mountains).addBands(ee.Image.pixelLonLat()) 643 | .addBands(biomes) 644 | .addBands(alpineBiomes.rename('alpine_abovetreelines')) // Alpine regions above the tree line 645 | .addBands(subtropics.unmask().add(1).rename("subtropics")) 646 | .addBands(elev_products.select('elevation')); 647 | 648 | var iucn_shrub_lvl2 = iucn_shrub_lvl2.expression( 649 | "( ((shrub == 300 && mountains == 1 && subtropics == 2) || (shrub == 300 && alpine_abovetreelines == 1 && subtropics == 2)) && ((koeppen >=1 && koeppen < 3) || ((koeppen >= 9 && koeppen <= 12 || (koeppen == 15 || koeppen >= 29 ) || (biome == 10) || (biome == 1 && koeppen >=22) ) && elevation >= 1200 )) ) ? 307" + // 3.7. Shrubland – Subtropical/tropical high altitude 650 | ": (shrub == 300 && ((koeppen >=8 && koeppen <= 10) && (subtropics == 1 && biome == 12)) ) ? 308" + // 3.8. Shrubland – Mediterranean-type shrubby vegetation 651 | ": (shrub == 300 && (biome == 11 && koeppen == 30)) ? 301" + // 3.1. Shrubland – Subarctic 652 | ": (shrub == 300 && (latitude > 45 && ((koeppen >= 27 && koeppen <= 29) || (koeppen >= 19 && koeppen <= 20) || (koeppen >= 23 && koeppen <= 24) || (biome == 6 && koeppen == 7) )) ) ? 303" + // 3.3. Shrubland – Boreal 653 | ": (shrub == 300 && ((latitude < 0 && subtropics == 1) && (koeppen == 16 || (koeppen >= 29 && koeppen <= 30 )) ) ) ? 302" + // 3.2. Shrubland – Subantarctic 654 | ": (shrub == 300 && ((koeppen >= 3 && koeppen <= 7) || (koeppen == 7 && subtropics == 2 ) || (biome >= 2 && biome <= 3) || ( biome == 7 ) ) ) ? 305" + // 3.5. Shrubland – Subtropical/tropical dry 655 | ": ((shrub == 300 && subtropics == 1) && ((koeppen >=8 && koeppen <= 10) || (koeppen >= 12 && koeppen <= 19) || (koeppen >= 21 && koeppen <= 26) || (((biome >= 4 && biome <= 5) || biome == 8 || biome == 10 ) && koeppen >= 27) )) ? 304" + // 3.4. Shrubland – Temperate 656 | ": (shrub == 300 && ((koeppen == 1 || koeppen == 2) || (koeppen >= 11 && koeppen <= 12) || ((koeppen >= 14 && koeppen <= 15) && subtropics == 2) ) ) ? 306" + // 3.6. Shrubland – Subtropical/tropical moist 657 | ": shrub == 300 ? 300" + // Higher class 658 | ": 0",{ 659 | 'shrub': iucn_shrub_lvl2.select('shrub'), 660 | 'biome' : iucn_shrub_lvl2.select('biomes'), 661 | 'koeppen': iucn_shrub_lvl2.select('koeppen'), 662 | 'alpine_abovetreelines' : iucn_shrub_lvl2.select('alpine_abovetreelines').unmask(), 663 | 'mountains': iucn_shrub_lvl2.select('mountains').expression('b(0) >= 1'), 664 | 'elevation': iucn_shrub_lvl2.select('elevation'), 665 | 'subtropics': iucn_shrub_lvl2.select('subtropics'), 666 | 'latitude': iucn_shrub_lvl2.select('latitude') 667 | }).rename('comp'); 668 | // Mask out land area 669 | iucn_shrub_lvl2 = iucn_shrub_lvl2.selfMask(); 670 | 671 | // ------------- // 672 | print('Processing Grassland - 4'); 673 | var iucn_grass_lvl1 = LC.expression('b(0) == 30').rename('grass'); 674 | if(calculate_pnv){ 675 | var pasture = ee.Image.constant(0).rename('pasture'); // Empty since we don't artifical land cover for PNV 676 | iucn_grass_lvl1 = LC.expression('b(0) == 30 || b(0) == 21').rename('grass'); 677 | } 678 | iucn_grass_lvl1 = iucn_grass_lvl1.addBands(pasture) 679 | .addBands(iucn_desert_lvl1.rename("desert")) 680 | .addBands(LC.rename("LC")) 681 | .addBands(iucn_artific.rename("artific")).addBands(koeppen); 682 | 683 | var iucn_grass_lvl1 = iucn_grass_lvl1.expression( 684 | // After 003. Removed '&& koeppen != 3' from here 685 | "((grass == 1 ) && pasture == 0) ? 400" + // Grassland 686 | ": ((LC == 60 || LC == 100) && desert == 0) ? 400" + // Alternative condition 687 | ": 0",{ 688 | 'grass': iucn_grass_lvl1.select('grass'), 689 | 'koeppen': iucn_grass_lvl1.select('koeppen'), 690 | 'desert': iucn_grass_lvl1.unmask().select('desert'), 691 | 'LC': iucn_grass_lvl1.select('LC'), 692 | 'pasture': iucn_grass_lvl1.unmask().select('pasture') 693 | }).rename('comp'); 694 | // Mask out land area 695 | iucn_grass_lvl1 = iucn_grass_lvl1.selfMask(); 696 | // Map out anything that is artifical 697 | iucn_grass_lvl1 = iucn_grass_lvl1.updateMask(iucn_artific.expression('(b(0) == 0)')); 698 | 699 | // --------------- 700 | var iucn_grass_lvl2 = iucn_grass_lvl1.rename('grass'); 701 | iucn_grass_lvl2 = iucn_grass_lvl2.addBands(koeppen.rename('koeppen')) 702 | .addBands(mountains).addBands(ee.Image.pixelLonLat()) 703 | .addBands(LC.rename("LC")) 704 | .addBands(biomes) 705 | .addBands(alpineBiomes.rename('alpine_abovetreelines')) // Alpine regions above the tree line 706 | .addBands(subtropics.unmask().add(1).rename("subtropics")) 707 | .addBands(elev_products.select('elevation')); 708 | 709 | var iucn_grass_lvl2 = iucn_grass_lvl2.expression( 710 | "((grass == 400 && (alpine_abovetreelines == 1 || mountains == 1)) && ((koeppen >= 1 && koeppen < 3) || ((koeppen == 11 || koeppen == 12 || koeppen == 15 || (koeppen >= 29 && subtropics == 2) || biome == 10 ) && elevation >= 1200 )) )? 407" + // 4.7. Grassland – Subtropical/tropical high altitude 711 | ": ((grass == 400 || LC == 100) && (biome == 11 && (koeppen == 30 || (koeppen == 7 && latitude > 60) ) ) ) ? 402" + // 4.2. Grassland – Subarctic 712 | ": (grass == 400 && ( (koeppen >= 19 && koeppen <= 20) || (koeppen >= 23 && koeppen <= 24) || ((koeppen >= 27 && koeppen <= 30) && (biome == 6 || biome == 11 || (biome == 13 && subtropics == 1)) || (biome == 6 && koeppen == 7) ) ) ) ? 401" + // 4.1. Grassland – Tundra 713 | ": (grass == 400 && ((latitude < 0 && subtropics == 1) && (koeppen == 16 || (koeppen >= 29 && koeppen <= 30 )) ) ) ? 403" + // 4.3. Grassland – Subantarctic 714 | ": (grass == 400 && (koeppen >= 3 && koeppen <= 5) || ( biome == 7 ) ) ? 405" + // 4.5. Grassland – Subtropical/tropical dry 715 | ": ((grass == 400 && subtropics == 1) && ((koeppen >=7 && koeppen <= 10) || (koeppen >= 12 && koeppen <= 16) || (koeppen >= 17 && koeppen <= 18) || (koeppen >= 21 && koeppen <= 26) || ((koeppen >= 27 && (biome >= 4 && biome <= 5) || biome == 8 || biome == 10)) ) ) ? 404" + // 4.4. Grassland – Temperate 716 | ": (grass == 400 && ((koeppen >= 1 && koeppen <= 2) || (koeppen >= 11 && koeppen <= 12) || ((koeppen >= 14 && koeppen <= 15) && subtropics == 2) ) ) ? 406" + // 4.6. Grassland – Subtropical/tropical seasonally wet/flooded 717 | ": grass == 400 ? 400" + // Higher class 718 | ": 0",{ 719 | 'grass': iucn_grass_lvl2.select('grass'), 720 | 'biome' : iucn_grass_lvl2.select('biomes'), 721 | 'LC' : iucn_grass_lvl2.select('LC'), 722 | 'koeppen': iucn_grass_lvl2.select('koeppen'), 723 | 'alpine_abovetreelines' : iucn_grass_lvl2.select('alpine_abovetreelines').unmask(), 724 | 'mountains': iucn_grass_lvl2.select('mountains').expression('b(0) >= 1'), 725 | 'elevation': iucn_grass_lvl2.select('elevation'), 726 | 'subtropics': iucn_grass_lvl2.select('subtropics'), 727 | 'latitude': iucn_grass_lvl2.select('latitude') 728 | }).rename('comp'); 729 | // Mask out land area 730 | iucn_grass_lvl2 = iucn_grass_lvl2.selfMask(); 731 | 732 | // ------------- // 733 | print('Processing Wetlands - 5'); 734 | // Level 1 735 | var iucn_wetlands_lvl1 = LC.expression('b(0) == 80 || b(0) == 90').rename('wetlands'); 736 | iucn_wetlands_lvl1 = iucn_wetlands_lvl1 737 | .addBands(gmw_mangroves.unmask().rename('mangroves')) 738 | .addBands(iucn_artific.rename("artific")); 739 | iucn_wetlands_lvl1 = iucn_wetlands_lvl1.expression( 740 | "(wetlands == 1 && mangroves == 0) ? 500" + // 5 Wetland areas 741 | ": 0 ",{ 742 | 'mangroves': iucn_wetlands_lvl1.select('mangroves'), // To prevent mangroves being mapped as wetlands 743 | 'wetlands': iucn_wetlands_lvl1.select('wetlands') 744 | }).rename('comp'); 745 | // Mask out land area 746 | iucn_wetlands_lvl1 = iucn_wetlands_lvl1.selfMask(); 747 | // Map out anything that is artifical 748 | iucn_wetlands_lvl1 = iucn_wetlands_lvl1.updateMask(iucn_artific.expression('(b(0) == 0)')); 749 | 750 | // ------------------- 751 | var iucn_wetlands_lvl2 = iucn_wetlands_lvl1.rename('wetlands') 752 | .addBands(koeppen.rename('koeppen')).addBands(LC.rename('LC')) 753 | .addBands(hydrolakes.rename('hydrolakes')) // (1=Lake, 2: Reservoir, 3: Lake Control) 754 | .addBands(GSW.rename('GSWtransition')) 755 | .addBands(intertidal.rename('intertidal')) 756 | .addBands(glwd.rename('glwd')).addBands(mountains.rename('mountains')); 757 | // https://www.worldwildlife.org/publications/global-lakes-and-wetlands-database-lakes-and-wetlands-grid-level-3 758 | // 1 Lake | 2 Reservoir | 3 River | 4 Freshwater Marsh, Floodplain | 5 Swamp Forest, Flooded Forest 759 | // 6 Coastal Wetland (incl. Mangrove, Estuary, Delta, Lagoon) | 7 Pan, Brackish/Saline Wetland | 8 Bog, Fen, Mire (Peatland) 760 | // 9 Intermittent Wetland/Lake | 10 50-100% Wetland | 11 25-50% Wetland | 12 Wetland Compex (0-25% Wetland) 761 | var iucn_wetlands_lvl2 = iucn_wetlands_lvl2.expression( 762 | "(wetlands == 500 && (mountains >= 1 && mountains <= 4)) ? 511" + // 5.11. Wetlands (inland) – Alpine wetlands (inc. temporary waters from snowmelt) 763 | ": (LC == 80 && (glwd == 1 || hydrolakes == 1)) ? 505" + // 5.5. Wetlands (inland) – Permanent freshwater lakes (over 8 ha) 764 | ": (wetlands == 500 && ((hydrolakes == 1 || glwd == 9) && GSWtransition >= 4) ) ? 506" + // 5.6. Wetlands (inland) – Seasonal/intermittent freshwater lakes (over 8 ha) 765 | ": ((glwd == 5 && wetlands == 500) || (LC == 20 && (glwd == 10 || glwd == 11))) ? 503" + // 5.3. Wetlands (inland) – Shrub dominated wetlands 766 | ": (wetlands == 500 && ((glwd == 3) && GSWtransition >= 4 )) ? 502" + // 5.2. Wetlands (inland) – Seasonal/intermittent/irregular rivers/streams/creeks 767 | ": (LC == 80 && ((glwd == 3) && GSWtransition <= 3)) ? 501" + // 5.1. Wetlands (inland) – Permanent rivers/streams/creeks (includes waterfalls) 768 | ": (wetlands == 500 && ((koeppen >= 27 && koeppen <= 28) || (koeppen >= 19 && koeppen <= 20) || (koeppen >= 23 && koeppen <=24)) ) ? 510" + // 5.10. Wetlands (inland) – Tundra wetlands (inc. pools and temporary waters from snowmelt) 769 | ": (wetlands == 500 && ((glwd == 8 || glwd >= 10) && (intertidal == 0 && GSWtransition < 4) && (LC == 90 && glwd == 5)) ) ? 504" + // 5.4. Wetlands (inland) – Bogs, marshes, swamps, fens, peatlands 770 | ": (wetlands == 500 && glwd == 4) ? 507" + // 5.7. Wetlands (inland) – Permanent freshwater marshes/pools (under 8 ha) 771 | ": (LC == 90 && glwd == 12) ? 508" + // 5.8. Wetlands (inland) – Seasonal/intermittent freshwater marshes/pools (under 8 ha) 772 | //": (wetlands == 500 && (koeppen == 1 || koeppen == 2 || koeppen == 4) ) ? 509 " + // 5.9. Wetlands (inland) – Freshwater springs and oases 773 | // 5.12. Wetlands (inland) – Geothermal wetlands 774 | ": ((wetlands == 500 && intertidal == 0 && GSWtransition < 4) && (glwd == 4 || (glwd >= 9 && glwd <= 12) )) ? 513" +// 5.13. Wetlands (inland) – Permanent inland deltas 775 | ": (LC == 80 && glwd == 7) ? 514" +// 5.14. Wetlands (inland) – Permanent saline, brackish or alkaline lakes 776 | ": ((wetlands == 500 && intertidal == 1 && GSWtransition >= 4) && (glwd == 6 || (glwd >= 9 && glwd <= 12) )) ? 515" +// 5.15. Wetlands (inland) – Seasonal/intermittent saline, brackish or alkaline lakes and flats 777 | // 5.16. Wetlands (inland) – Permanent saline, brackish or alkaline marshes/pools 778 | // 5.17. Wetlands (inland) – Seasonal/intermittent saline, brackish or alkaline marshes/pools 779 | // 5.18. Wetlands (inland) – Karst and other subterranean hydrological systems (inland) 780 | ": wetlands == 500 ? 500" + // Default wetland 781 | ": 0 ",{ 782 | 'LC': iucn_wetlands_lvl2.select('LC'), 783 | 'wetlands': iucn_wetlands_lvl2.select('wetlands'), 784 | 'hydrolakes': iucn_wetlands_lvl2.select('hydrolakes').expression('b(0)>1'), 785 | 'GSWtransition': iucn_wetlands_lvl2.select('GSWtransition'), 786 | 'intertidal': iucn_wetlands_lvl2.select('intertidal').unmask(), 787 | 'glwd': iucn_wetlands_lvl2.select('glwd').unmask(), 788 | 'mountains': iucn_wetlands_lvl2.select('mountains'), 789 | 'koeppen': iucn_wetlands_lvl2.select('koeppen') 790 | }).rename('comp'); 791 | // Mask out land area 792 | iucn_wetlands_lvl2 = iucn_wetlands_lvl2.selfMask(); 793 | 794 | // --------------------------------------------------------------- // 795 | // Marine habitat types // 796 | // --------------------------------------------------------------- // 797 | // Broad Marine Regions to be used for all Marine classes 798 | // Class 10 (Pelagic) is not mapped given that is a depth-related class (3D) 799 | // Filled from Harris et al. and other sources 800 | var iucn_marinesearegions = land_mask.unmask().add(1).rename('land_mask') 801 | .addBands(marine_seabedzones.rename('marinezones')) 802 | .addBands(ocean_bedrock.rename('bedrock')) 803 | .addBands(land_buffered.rename('land_buffered')) 804 | .addBands(intertidal.rename('intertidal')); 805 | iucn_marinesearegions = iucn_marinesearegions.expression( 806 | "intertidal == 2 ? 1200" + // 12. Marine - Intertidal 807 | ": (ocean == 1 && (((bedrock >= -200 && bedrock < 0) || (marinezones == 1)) ) ) ? 900" + // 9 Marine Neritic 808 | ": (ocean == 1 && (marinezones > 1) ) ? 1100" + // 11 Deep Ocean Floor classes 809 | ": (land_buffered == 1 && (marinezones == 1 || intertidal == 1)) ? 900" + // 9 Marine Neritic buffered filler 810 | ": (ocean == 1 && marinezones == 0 ) ? 900" + // Dummy class for rest of ocean with mismatchesof the marinezones layer 811 | // ": ? 1300" + // 13. Marine -Coastal/Supratidal 812 | ": 0 ",{ 813 | 'marinezones' : iucn_marinesearegions.select('marinezones').unmask(), 814 | 'intertidal' : iucn_marinesearegions.select('intertidal').add(1), 815 | 'land_buffered': iucn_marinesearegions.select('land_buffered'), 816 | 'ocean': iucn_marinesearegions.select('land_mask').rename('ocean'), 817 | 'bedrock': iucn_marinesearegions.select('bedrock') 818 | }).rename('comp'); 819 | iucn_marinesearegions = iucn_marinesearegions.selfMask(); 820 | Map.addLayer(iucn_marinesearegions.randomVisualizer(),{},'Broad Ocean regions',0); 821 | 822 | // --------- Marine Neritic ---------- // 823 | print('Processing Marine - neritic'); 824 | 825 | // Level 1 826 | var iucn_marineneritic_lvl1 = land_mask.add(1).rename('land_mask') 827 | .addBands(iucn_marinesearegions.rename('neritic')) 828 | .addBands(ocean_bedrock.rename('bedrock')) 829 | .addBands(marine_seabedzones.rename('marinezones')); 830 | iucn_marineneritic_lvl1 = iucn_marineneritic_lvl1.expression( 831 | "neritic == 900 ? 900" + // 9 Marine Neritic 832 | ": 0 ",{ 833 | 'neritic' : iucn_marineneritic_lvl1.select('neritic'), 834 | 'marinezones' : iucn_marineneritic_lvl1.select('marinezones'), 835 | 'bedrock': iucn_marineneritic_lvl1.select('bedrock'), 836 | 'ocean': iucn_marineneritic_lvl1.select('land_mask') 837 | }).rename('comp'); 838 | iucn_marineneritic_lvl1 = iucn_marineneritic_lvl1.selfMask(); 839 | 840 | // Level 2 841 | var iucn_marineneritic_lvl2 = iucn_marineneritic_lvl1.rename('marine_neritic') 842 | .addBands(coral_reefs.rename('coral_reefs')) 843 | .addBands(seagrass.rename('seagrass')) 844 | .addBands(mangrove_buffered.rename('mangrove_buffered')) 845 | .addBands(ocean_bedrock.rename('ocean_bedrock')); 846 | 847 | iucn_marineneritic_lvl2 = iucn_marineneritic_lvl2.expression( 848 | "(marine_neritic == 900 && coral_reefs == 1 ) ? 908" + // 9.8 Coral Reefs 849 | // ": (marine_neritic == 900 ) ? 900" + // 9.7 Marcoalgal/Kelp 850 | ": ((marine_neritic == 900 ) && (seagrass == 1 && ocean_bedrock > -60) ) ? 909" + // 9.9 Seagrass (submerged) 851 | // "(marine_neritic == 900 ) ? 910" + // 9.10 Estuaries 852 | // ": (marine_neritic == 900) ? 901" + // 9.1 Pelagic. Not mapped unless there are unclassified grid cells 853 | ": (marine_neritic == 900 ) ? 900" + // 9 Pelagic. Dummy class 854 | ": 0 ",{ // Only assign 0 to non-mapped ocean classes 855 | 'marine_neritic': iucn_marineneritic_lvl2.select('marine_neritic'), 856 | 'coral_reefs': iucn_marineneritic_lvl2.select('coral_reefs'), 857 | 'seagrass': iucn_marineneritic_lvl2.select('seagrass'), 858 | 'mangrove_buffered': iucn_marineneritic_lvl2.select('mangrove_buffered').unmask().add(1), 859 | 'ocean_bedrock': iucn_marineneritic_lvl2.select('ocean_bedrock') 860 | }).rename('comp'); 861 | iucn_marineneritic_lvl2 = iucn_marineneritic_lvl2.selfMask(); 862 | //Map.addLayer(iucn_marineneritic_lvl2.randomVisualizer(),{},"Marine neritic"); 863 | 864 | // --------- Marine Oceanic ---------- // 865 | // FIXME: This maps additively not exclusively. E.g. Zone 1002 has at least also 1001 866 | // Created and exported during Fractional aggregation! 867 | 868 | print('Processing Marine Oceanic zones'); 869 | // Build class 10 as base filler for all non-identified habitat types 870 | // Pelagic habitat is deeper than and beyond the continental or island shelf 871 | var iucn_marineoceanic_lvl1 = land_mask.add(1).rename('land_mask') 872 | .addBands(marine_seabedzones.rename('marinezones')); 873 | iucn_marineoceanic_lvl1 = iucn_marineoceanic_lvl1.expression( 874 | "(ocean == 1 && marinezones > 1) ? 1000" + // 10 Marine Ocean 875 | ": 0 ",{ 876 | 'marinezones' : iucn_marineoceanic_lvl1.select('marinezones'), 877 | 'ocean': iucn_marineoceanic_lvl1.select('land_mask').expression('b(0) == 1') 878 | }).rename('comp'); 879 | iucn_marineoceanic_lvl1 = iucn_marineoceanic_lvl1.selfMask(); 880 | 881 | // Level 2 882 | var iucn_marineoceanic_lvl2 = iucn_marineoceanic_lvl1.rename('oceanic') 883 | .addBands(ocean_bedrock.rename('ocean_bedrock')); 884 | iucn_marineoceanic_lvl2 = iucn_marineoceanic_lvl2.expression( 885 | "(oceanic == 1000 && ocean_bedrock <= -4000 ) ? 1004" + // 10.4 Abyssopelagic (4,000–6,000 m) 886 | ": (oceanic == 1000 && ocean_bedrock <= -1000 ) ? 1003" + // 10.3 Bathypelagic (1,000–4,000 m) 887 | ": (oceanic == 1000 && ocean_bedrock < -200 ) ? 1002" + // 10.2 Mesopelagic (200–1,000 m) 888 | ": (oceanic == 1000 && ocean_bedrock < 0) ) ? 1001" + // 10.1 Epipelagic (0–200 m) 889 | ": 0 ",{ // Only assign 0 to non-mapped ocean classes 890 | 'oceanic': iucn_marineoceanic_lvl2.select('oceanic'), 891 | 'ocean_bedrock': iucn_marineoceanic_lvl2.select('ocean_bedrock') 892 | }).rename('comp'); 893 | iucn_marineoceanic_lvl2 = iucn_marineoceanic_lvl2.selfMask(); // Self maks 894 | 895 | // --------- Marine Deep Ocean Floor (Benthis and Demersal ---------- // 896 | print('Processing Marine Deep Ocean Floor zones'); 897 | // Level 1 (Take from marine sea regions) 898 | var iucn_marinedeepocean_lvl1 = iucn_marinesearegions.expression('b(0) == 1100').multiply(1100).selfMask(); 899 | 900 | // Level 2 901 | var iucn_marinedeepocean_lvl2 = iucn_marinedeepocean_lvl1.rename('deepocean') 902 | .addBands(marine_seabedzones.rename('marinezones')) 903 | .addBands(ocean_bedrock.rename('bedrock')) 904 | .addBands(seamounts.rename('seamounts')) 905 | .addBands(vents.rename('vents')) 906 | .addBands(abyss_class.rename('abyss_class')); 907 | iucn_marinedeepocean_lvl2 = iucn_marinedeepocean_lvl2.expression( 908 | "(deepocean == 1100 && vents == 1) ? 1106" + // 11.6 Deep Sea Vents (Rifts/Seeps) 909 | ": (deepocean == 1100 && seamounts == 1) ? 1105" + // 11.5 Sea mount 910 | ": (marinezones == 2 ) ? 1101" + // 11.1 Continental Slope / Bathyl zone (200-4000m) 911 | ": (marinezones == 3 && (abyss_class == 1 || abyss_class == 2 )) ? 1102" + // 11.2 Abyssal Plain (4000m to 6000m) 912 | ": (marinezones == 3 && abyss_class > 2 ) ? 1103" + // 11.3 Abyssal Mountain/Hills (4000m to 6000m) 913 | ": (marinezones == 4 ) ? 1104" + // 11.4 Hadal/Deep Sea Trench 914 | ": 0",{ 915 | 'deepocean' : iucn_marinedeepocean_lvl2.select('deepocean'), 916 | 'abyss_class' : iucn_marinedeepocean_lvl2.select('abyss_class'), 917 | 'marinezones' : iucn_marinedeepocean_lvl2.select('marinezones'), 918 | 'seamounts' : iucn_marinedeepocean_lvl2.select('seamounts'), 919 | 'vents' : iucn_marinedeepocean_lvl2.select('vents'), 920 | 'ocean_bedrock': iucn_marinedeepocean_lvl2.select('bedrock') 921 | }).rename('comp'); 922 | iucn_marinedeepocean_lvl2 = iucn_marinedeepocean_lvl2.selfMask(); 923 | 924 | // --------- Marine - Intertidal ---------- // 925 | print('Processing Marine Intertidal zones'); 926 | // Level 1 (Take from marine sea regions) 927 | var iucn_marineintertidal_lvl1 = land_mask.add(1).rename('land_mask') 928 | .addBands(iucn_marinesearegions.expression('b(0) == 1200').selfMask().rename('intertidal')); 929 | iucn_marineintertidal_lvl1 = iucn_marineintertidal_lvl1.expression( 930 | "(ocean == 1 && intertidal == 1) ? 1200" + // 12 Intertidal. Area on the shore that is frequently covered by tides 931 | ": 0 ",{ 932 | 'intertidal' : iucn_marineintertidal_lvl1.select('intertidal'), 933 | 'ocean': iucn_marineintertidal_lvl1.select('land_mask').expression('b(0) == 1') 934 | }).rename('comp'); 935 | iucn_marineintertidal_lvl1 = iucn_marineintertidal_lvl1.selfMask(); 936 | 937 | // Level 2 938 | var iucn_marineintertidal_lvl2 = iucn_marineintertidal_lvl1.rename('intertidal') 939 | .addBands(marine_seabedzones.rename('marinezones')) 940 | .addBands(mangrove_buffered.rename('mangroves_buffered')) 941 | .addBands(GSW.rename('GSWtransition')); 942 | iucn_marineintertidal_lvl2 = iucn_marineintertidal_lvl2.expression( 943 | "(intertidal == 1200 && mangroves_buffered == 1) ? 1207" + // 12.7 Mangrove Submerged Roots 944 | ": (intertidal == 1200 && (GSWtransition == 9 || GSWtransition == 10 || GSWtransition == 4) ) ? 1206" + // 12.6 Tidepools 945 | // Salt Marshes! 946 | // Sand and Pebble Beaches 947 | ": intertidal == 1200 ? 1200" + // 1200 Map by default to Oceanic intertidal zone 948 | ": 0",{ 949 | 'intertidal' : iucn_marineintertidal_lvl2.select('intertidal'), 950 | 'marinezones' : iucn_marineintertidal_lvl2.select('marinezones'), 951 | 'mangroves_buffered' : iucn_marineintertidal_lvl2.select('mangroves_buffered'), 952 | 'GSWtransition': iucn_marineintertidal_lvl2.select('GSWtransition') 953 | }).rename('comp'); 954 | iucn_marineintertidal_lvl2 = iucn_marineintertidal_lvl2.selfMask(); 955 | //Map.addLayer(iucn_marineintertidal_lvl2.randomVisualizer()); 956 | 957 | // #################################################################### // 958 | // Compositing 959 | print('| Composite all layers together |'); 960 | 961 | // Use mode compositer 962 | if(level == 1){ 963 | // Construct marine and reduce first 964 | var marine = ee.ImageCollection([ iucn_marineneritic_lvl1.toInt16(),iucn_marinedeepocean_lvl1.toInt16(),iucn_marineintertidal_lvl1.toInt16(), 965 | land_buffered.multiply(900).rename('comp').toInt16()]); 966 | marine = marine.reduce(ee.Reducer.firstNonNull()).rename('comp'); 967 | 968 | // new Artifical 969 | var art_lvl1 = iucn_artific.expression('b(0)>=1400 & b(0) <= 1408').multiply(1400); 970 | art_lvl1 = art_lvl1.toInt16().selfMask(); 971 | 972 | if(calculate_pnv){ 973 | var ll = [iucn_forest_lvl1.toInt16(),iucn_savanna_lvl1.toInt16(),iucn_shrub_lvl1.toInt16(),iucn_grass_lvl1.toInt16(),iucn_desert_lvl1.toInt16(),iucn_wetlands_lvl1.toInt16(), 974 | marine]; 975 | } else { 976 | var ll = [iucn_forest_lvl1.toInt16(),iucn_savanna_lvl1.toInt16(),iucn_shrub_lvl1.toInt16(),iucn_grass_lvl1.toInt16(),iucn_desert_lvl1.toInt16(),iucn_wetlands_lvl1.toInt16(), 977 | art_lvl1, 978 | marine]; 979 | } 980 | } else { 981 | // Construct marine and reduce first 982 | var marine = ee.ImageCollection([ iucn_marineneritic_lvl2.toInt16(),iucn_marinedeepocean_lvl2.toInt16(),iucn_marineintertidal_lvl2.toInt16(), 983 | land_buffered.multiply(900).rename('comp').toInt16()]); 984 | marine = marine.reduce(ee.Reducer.firstNonNull()).rename('comp'); 985 | 986 | if(calculate_pnv){ 987 | var ll = [iucn_forest_lvl2.toInt16(),iucn_savanna_lvl2.toInt16(),iucn_shrub_lvl2.toInt16(),iucn_grass_lvl2.toInt16(),iucn_desert_lvl2.toInt16(),iucn_wetlands_lvl2.toInt16(), 988 | marine]; 989 | } else { 990 | var ll = [iucn_forest_lvl2.toInt16(),iucn_savanna_lvl2.toInt16(),iucn_shrub_lvl2.toInt16(),iucn_grass_lvl2.toInt16(),iucn_desert_lvl2.toInt16(),iucn_wetlands_lvl2.toInt16(), 991 | iucn_artific.selfMask().toInt16(), // Self mask the artifical layer 992 | marine]; 993 | } 994 | } 995 | var comp = ee.ImageCollection(ll); 996 | // Composite output layers and class checks 997 | var missing = comp.reduce(ee.Reducer.anyNonZero()).where(0,1); 998 | var duplicates = comp.reduce(ee.Reducer.countDistinct()); 999 | 1000 | // Composite to first class being mapped for a given level and clip 1001 | comp = comp.reduce(ee.Reducer.firstNonNull()).selfMask(); 1002 | 1003 | // Caspian sea fix 1004 | if(level == 1){ 1005 | comp = comp.where(kaspian_seafix_image,ee.Image(500)); 1006 | } else { 1007 | comp = comp.where(kaspian_seafix_image,ee.Image(505)); 1008 | } 1009 | 1010 | // Classes that only got mapped to level 1 at level 2 1011 | if(level == 2){ 1012 | var level1_only = comp.expression('(b(0) == 100) || (b(0) == 200) || (b(0) == 300) || (b(0) == 400) || (b(0) == 500) || (b(0) == 1400)'); 1013 | Map.addLayer(level1_only.selfMask().randomVisualizer(),{},'Level 2 only at level 1', 0); 1014 | } 1015 | 1016 | // #################################################################### // 1017 | // Exporting functions 1018 | if(level == 1){ 1019 | iucn_artific = iucn_artific.selfMask().expression('(b(0) > 0)').where(1,1400); 1020 | if(export_classes){ 1021 | // Export individual layers 1022 | createOutput(iucn_desert_lvl1,output_path, 'iucn_6and8_rockydeserts_lvl'+level); 1023 | createOutput(iucn_artific,output_path, 'iucn_14_artifical_lvl'+level); 1024 | createOutput(iucn_forest_lvl1,output_path, 'iucn_1_forests_lvl'+level); 1025 | createOutput(iucn_savanna_lvl1,output_path, 'iucn_2_savanna_lvl'+level); 1026 | createOutput(iucn_shrub_lvl1,output_path,'iucn_3_shrub_lvl'+level); 1027 | createOutput(iucn_grass_lvl1,output_path,'iucn_4_grass_lvl'+level); 1028 | createOutput(iucn_wetlands_lvl1,output_path,'iucn_5_wetland_lvl'+level); 1029 | // Marine 1030 | createOutput(iucn_marineneritic_lvl1,output_path,'iucn_9_neritic_lvl'+level); 1031 | createOutput(iucn_marineoceanic_lvl1,output_path,'iucn_10_pelagic_lvl'+level); 1032 | createOutput(iucn_marinedeepocean_lvl1,output_path,'iucn_11_deepocean_lvl'+level); 1033 | createOutput(iucn_marineintertidal_lvl1,output_path,'iucn_12_intertidal_lvl'+level); 1034 | } 1035 | } else { 1036 | if(export_classes){ 1037 | // Export individual layers 1038 | createOutput(iucn_desert_lvl2,output_path,'iucn_6and8_rockydeserts_lvl'+level); 1039 | createOutput(iucn_artific,output_path,'iucn_14_artifical_lvl'+level); 1040 | createOutput(iucn_forest_lvl2,output_path,'iucn_1_forests_lvl'+level); 1041 | createOutput(iucn_savanna_lvl2,output_path,'iucn_2_savanna_lvl'+level); 1042 | createOutput(iucn_shrub_lvl2,output_path,'iucn_3_shrub_lvl'+level); 1043 | createOutput(iucn_grass_lvl2,output_path,'iucn_4_grass_lvl'+level); 1044 | createOutput(iucn_wetlands_lvl2,output_path,'iucn_5_wetland_lvl'+level); 1045 | // Marine 1046 | createOutput(iucn_marineneritic_lvl2,output_path,'iucn_9_neritic_lvl'+level); 1047 | createOutput(iucn_marineoceanic_lvl2,output_path,'iucn_10_pelagic_lvl'+level); 1048 | createOutput(iucn_marinedeepocean_lvl2,output_path,'iucn_11_deepocean_lvl'+level); 1049 | createOutput(iucn_marineintertidal_lvl2,output_path,'iucn_12_intertidal_lvl'+level); 1050 | } 1051 | } 1052 | // If the year is after 2015, mask the composite layer to only those grid cells with recorded change 1053 | if(year > 2015){ 1054 | // Mask composite with changemask for the current year 1055 | comp = comp.mask(changemask).rename('comp' + year); 1056 | // Process differently for each year 1057 | if(year == 2016){ 1058 | // For year 2016, take 2015 full asset and update with change mask 1059 | try{ 1060 | var comp2015 = ee.Image( 'users/Uploads/habitattypes/iucn_habitatclassification_composite_lvl' + level + "_ver" + version ); 1061 | var comp_before = comp2015.mask(changemask).rename('comp2015'); 1062 | } catch(err) { 1063 | print('Composited map for ', year -1,' not available yet as asset. Run first!'); 1064 | } 1065 | } 1066 | if(year == 2017){ 1067 | try{ 1068 | // Build previous years 1069 | var comp2015 = ee.Image('users/Uploads/habitattypes/iucn_habitatclassification_composite_lvl' + level+"_ver" + version ); 1070 | var change2016 = ee.Image('users/Uploads/habitattypes/changemasks2016/iucn_habitatclassification_2016changemask_lvl' + level+"_ver" + version); 1071 | // Create 2016 composite 1072 | change2016 = change2016.select(['comp2016']); 1073 | var comp2016 = updateComposite(comp2015,change2016); 1074 | // Now create 2016 before change 1075 | var comp_before = comp2016.mask(changemask).rename('comp2016'); 1076 | } catch(err) { 1077 | print('Composited map for ', year -1,' not available yet as asset. Run first!'); 1078 | } 1079 | } 1080 | if(year == 2018){ 1081 | try{ 1082 | // Build previous years 1083 | var comp2015 = ee.Image('users/Uploads/habitattypes/iucn_habitatclassification_composite_lvl' + level+"_ver" + version ); 1084 | var change2016 = ee.Image('users/Uploads/habitattypes/changemasks2016/iucn_habitatclassification_2016changemask_lvl' + level+"_ver" + version); 1085 | var change2017 = ee.Image('users/Uploads/habitattypes/changemasks2017/iucn_habitatclassification_2017changemask_lvl' + level+"_ver" + version); 1086 | // Create 2017 composite 1087 | change2016 = change2016.select(['comp2016']); 1088 | change2017 = change2017.select(['comp2017']); 1089 | var comp2016 = updateComposite(comp2015,change2016); 1090 | var comp2017 = updateComposite(comp2016,change2017); 1091 | // Now create 2018 before change 1092 | var comp_before = comp2017.mask(changemask).rename('comp2017'); 1093 | } catch(err) { 1094 | print('Composited map for ', year -1,' not available yet as asset. Run first!'); 1095 | } 1096 | } 1097 | if(year == 2019){ 1098 | try{ 1099 | // Build previous years 1100 | var comp2015 = ee.Image('users/Uploads/habitattypes/iucn_habitatclassification_composite_lvl' + level+"_ver" + version ); 1101 | var change2016 = ee.Image('users/Uploads/habitattypes/changemasks2016/iucn_habitatclassification_2016changemask_lvl' + level+"_ver" + version); 1102 | var change2017 = ee.Image('users/Uploads/habitattypes/changemasks2017/iucn_habitatclassification_2017changemask_lvl' + level+"_ver" + version); 1103 | var change2018 = ee.Image('users/Uploads/habitattypes/changemasks2018/iucn_habitatclassification_2018changemask_lvl' + level+"_ver" + version); 1104 | // Create 2018 composite 1105 | change2016 = change2016.select(['comp2016']); 1106 | change2017 = change2017.select(['comp2017']); 1107 | change2018 = change2018.select(['comp2018']); 1108 | var comp2016 = updateComposite(comp2015,change2016); 1109 | var comp2017 = updateComposite(comp2016,change2017); 1110 | var comp2018 = updateComposite(comp2017,change2018); 1111 | // Now create 2019 before change 1112 | var comp_before = comp2018.mask(changemask).rename('comp2018'); 1113 | } catch(err) { 1114 | print('Composited map for ', year -1,' not available yet as asset. Run first!'); 1115 | } 1116 | } 1117 | // --------------------------------- // 1118 | // Now add together as bands 1119 | comp = comp_before.addBands(comp); 1120 | 1121 | // Now export this version 1122 | if(calculate_pnv){print('Years after 2015 not implemented yet');} 1123 | // Export the change mask 1124 | var name = 'iucn_habitatclassification_' + year + 'changemask_lvl' + level + "_ver" + version; 1125 | createOutput(comp,output_path + '/' + 'changemasks' + year + '/' + name, name); 1126 | 1127 | } else { 1128 | // Export 1129 | if(calculate_pnv){ 1130 | createOutput(comp,output_path + '/' + 'iucn_habitatclassification_composite_pnv_lvl'+level+"_ver"+version, 1131 | 'iucn_habitatclassification_composite_pnv_lvl'+level+"_ver"+version); 1132 | // createOutput(missing,'iucn_habitatclassification_nonmissing_pnv_lvl'+level+"_ver"+version); 1133 | // createOutput(duplicates,'iucn_habitatclassification_duplicates_pnv_lvl'+level+"_ver"+version); 1134 | } else { 1135 | createOutput(comp,output_path + '/' + 'iucn_habitatclassification_composite_lvl'+level+"_ver"+version, 1136 | 'iucn_habitatclassification_composite_lvl'+level+"_ver"+version); 1137 | // createOutput(missing,'iucn_habitatclassification_nonmissing_lvl'+level+"_ver"+version); 1138 | // createOutput(duplicates,'iucn_habitatclassification_duplicates_lvl'+level+"_ver"+version); 1139 | } 1140 | } 1141 | // #################################################################### // 1142 | // Visualization options for the colour map/// 1143 | // Define colours 1144 | var colours_level2 = 1145 | '' + 1146 | '' + 1147 | '' + 1148 | 1149 | '' + 1150 | '' + 1151 | '' + 1152 | '' + 1153 | '' + 1154 | '' + 1155 | '' + 1156 | '' + 1157 | '' + 1158 | '' + 1159 | 1160 | '' + 1161 | '' + 1162 | '' + 1163 | 1164 | '' + 1165 | '' + 1166 | '' + 1167 | '' + 1168 | '' + 1169 | '' + 1170 | '' + 1171 | '' + 1172 | '' + 1173 | 1174 | '' + 1175 | '' + 1176 | '' + 1177 | '' + 1178 | '' + 1179 | '' + 1180 | '' + 1181 | '' + 1182 | 1183 | '' + 1184 | '' + 1185 | '' + 1186 | '' + 1187 | '' + 1188 | '' + 1189 | '' + 1190 | '' + 1191 | '' + 1192 | '' + 1193 | '' + 1194 | '' + 1195 | '' + 1196 | '' + 1197 | '' + 1198 | '' + 1199 | '' + 1200 | '' + 1201 | '' + 1202 | 1203 | '' + 1204 | '' + 1205 | '' + 1206 | '' + 1207 | '' + 1208 | 1209 | '' + 1210 | '' + 1211 | '' + 1212 | '' + 1213 | '' + 1214 | '' + 1215 | '' + 1216 | '' + 1217 | '' + 1218 | '' + 1219 | '' + 1220 | '' + 1221 | '' + 1222 | '' + 1223 | '' + 1224 | '' + 1225 | '' + 1226 | '' + 1227 | '' + 1228 | 1229 | '' + 1230 | '' + 1231 | '' + 1232 | '' + 1233 | '' + 1234 | '' + 1235 | '' + 1236 | 1237 | '' + 1238 | 1239 | '' + 1240 | ''; 1241 | 1242 | // Visualization 1243 | if(year > 2015){ 1244 | Map.addLayer(comp.select('comp' +year), {shown:false}, 'Habitat codes year ' + year, 0); 1245 | Map.addLayer(comp.select('comp' +year).sldStyle(colours_level2), {}, "Level " + level + ' in year '+ year,0); // Redraw map 1246 | } else { 1247 | Map.addLayer(comp, {shown:false}, 'Habitat codes year ' + year, 0); 1248 | Map.addLayer(comp.sldStyle(colours_level2), {}, "Level " + level + ' in year '+ year,0); // Redraw map 1249 | } 1250 | //Map.addLayer(LC.randomVisualizer(),{},"Land cover"); 1251 | //Map.addLayer(missing.randomVisualizer(),{},"Missing", 0); 1252 | --------------------------------------------------------------------------------