| 1 | #!/usr/bin/env python
|
|---|
| 2 |
|
|---|
| 3 | """
|
|---|
| 4 | MODULE: r.euro.ecosystem
|
|---|
| 5 |
|
|---|
| 6 | AUTHOR(S): Helmut Kudrnovsky <alectoria AT gmx at>
|
|---|
| 7 |
|
|---|
| 8 | PURPOSE: Sets colors and category labels of European ecosystem raster data sets.
|
|---|
| 9 | Rules can be defined for level 1 and level 2 data.
|
|---|
| 10 | Color and category label rules donated by European Environment Agency (EEA).
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | COPYRIGHT: (C) 2015, 2019 by the GRASS Development Team
|
|---|
| 14 |
|
|---|
| 15 | This program is free software under the GNU General Public
|
|---|
| 16 | License (>=v2). Read the file COPYING that comes with GRASS
|
|---|
| 17 | for details.
|
|---|
| 18 | """
|
|---|
| 19 |
|
|---|
| 20 | #%module
|
|---|
| 21 | #% description: Sets colors and categories of European ecosystem raster data set
|
|---|
| 22 | #% keyword: raster
|
|---|
| 23 | #% keyword: color
|
|---|
| 24 | #% keyword: category
|
|---|
| 25 | #% keyword: ecosystem
|
|---|
| 26 | #%end
|
|---|
| 27 |
|
|---|
| 28 | #%option G_OPT_R_INPUT
|
|---|
| 29 | #% key: input
|
|---|
| 30 | #%end
|
|---|
| 31 |
|
|---|
| 32 | #%flag
|
|---|
| 33 | #% key: 1
|
|---|
| 34 | #% description: level 1 data
|
|---|
| 35 | #%end
|
|---|
| 36 |
|
|---|
| 37 | #%flag
|
|---|
| 38 | #% key: 2
|
|---|
| 39 | #% description: level 2 data
|
|---|
| 40 | #%end
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | import sys
|
|---|
| 44 | import os
|
|---|
| 45 | import csv
|
|---|
| 46 | import math
|
|---|
| 47 | import shutil
|
|---|
| 48 | import tempfile
|
|---|
| 49 | import grass.script as grass
|
|---|
| 50 |
|
|---|
| 51 | def main():
|
|---|
| 52 |
|
|---|
| 53 | iraster = options['input']
|
|---|
| 54 | eraster = options['input'].split('@')[0]
|
|---|
| 55 | level1 = flags['1']
|
|---|
| 56 | level2 = flags['2']
|
|---|
| 57 | if level1 :
|
|---|
| 58 | color_rules_level1 = eraster+'_color_level1.txt'
|
|---|
| 59 | cat_rules_level1 = eraster+'_cat_level1.txt'
|
|---|
| 60 | if level2 :
|
|---|
| 61 | color_rules_level2 = eraster+'_color_level2.txt'
|
|---|
| 62 | cat_rules_level2 = eraster+'_cat_level2.txt'
|
|---|
| 63 | global tmp
|
|---|
| 64 |
|
|---|
| 65 | # start settings
|
|---|
| 66 | grass.message( "Setting colors and categories ..." )
|
|---|
| 67 |
|
|---|
| 68 | # define intermediate folder files
|
|---|
| 69 | datatempdir = tempfile.gettempdir()
|
|---|
| 70 | if level1 :
|
|---|
| 71 | tmp_col_l1 = os.path.join( datatempdir, color_rules_level1 )
|
|---|
| 72 | tmp_cat_l1 = os.path.join( datatempdir, cat_rules_level1 )
|
|---|
| 73 | if level2 :
|
|---|
| 74 | tmp_col_l2 = os.path.join( datatempdir, color_rules_level2 )
|
|---|
| 75 | tmp_cat_l2 = os.path.join( datatempdir, cat_rules_level2 )
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 | # write intermediate color and cat rule file data level 1
|
|---|
| 79 | if level1 :
|
|---|
| 80 | # write intermediate color rule file level 1
|
|---|
| 81 | fcl1 = open('%s' % (tmp_col_l1), 'wt')
|
|---|
| 82 | fcl1.write("""1 115:178:255
|
|---|
| 83 | 2 255:211:127
|
|---|
| 84 | 3 0:112:255
|
|---|
| 85 | 4 223:115:255
|
|---|
| 86 | 5 85:255:0
|
|---|
| 87 | 6 255:170:0
|
|---|
| 88 | 7 38:115:0
|
|---|
| 89 | 8 178:178:178
|
|---|
| 90 | 9 255:255:0
|
|---|
| 91 | 10 255:0:0""")
|
|---|
| 92 | # close intermediate color level 1 rules
|
|---|
| 93 | fcl1.close()
|
|---|
| 94 | # write intermediate category rule file level 1
|
|---|
| 95 | fcal1 = open('%s' % (tmp_cat_l1), 'wt')
|
|---|
| 96 | fcal1.write("""1|A Marine habitats
|
|---|
| 97 | 2|B Coastal habitats
|
|---|
| 98 | 3|C Inland surface waters
|
|---|
| 99 | 4|D Mires, bogs and fens
|
|---|
| 100 | 5|E Grasslands and land dominated by forbs, mosses or lichens
|
|---|
| 101 | 6|F Heathland, scrub and tundra
|
|---|
| 102 | 7|G Woodland, forest and other wooded land
|
|---|
| 103 | 8|H Inland unvegetated or sparsely vegetated habitats
|
|---|
| 104 | 9|I Regularly or recently cultivated, hortocultural and domestic habitats
|
|---|
| 105 | 10|J Constructed, industrial and other artificial habitats""")
|
|---|
| 106 | # close intermediate category level 1 rules
|
|---|
| 107 | fcal1.close()
|
|---|
| 108 |
|
|---|
| 109 | # apply color rules level 1
|
|---|
| 110 | grass.message ( "applying color rules for data level 1..." )
|
|---|
| 111 | grass.run_command("r.colors", map = iraster,
|
|---|
| 112 | rules = tmp_col_l1,
|
|---|
| 113 | quiet = True)
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 | # apply category rules level 1
|
|---|
| 117 | grass.message ( "applying category rules for data level 1..." )
|
|---|
| 118 | grass.run_command("r.category", map = iraster,
|
|---|
| 119 | rules = tmp_cat_l1,
|
|---|
| 120 | separator = 'pipe',
|
|---|
| 121 | quiet = True)
|
|---|
| 122 |
|
|---|
| 123 | # write intermediate color and cat rule file data level 2
|
|---|
| 124 | if level2 :
|
|---|
| 125 | # write intermediate color rule file level 2
|
|---|
| 126 | fcl2 = open('%s' % (tmp_col_l2), 'wt')
|
|---|
| 127 | fcl2.write("""9 166:255:230
|
|---|
| 128 | 10 0:255:166
|
|---|
| 129 | 11 230:230:230
|
|---|
| 130 | 12 200:200:200
|
|---|
| 131 | 13 170:170:170
|
|---|
| 132 | 14 128:242:230
|
|---|
| 133 | 15 0:204:242
|
|---|
| 134 | 16 0:204:153
|
|---|
| 135 | 17 64:49:81
|
|---|
| 136 | 18 96:73:122
|
|---|
| 137 | 19 177:160:199
|
|---|
| 138 | 20 204:192:218
|
|---|
| 139 | 21 218:238:243
|
|---|
| 140 | 22 183:222:232
|
|---|
| 141 | 23 240:240:150
|
|---|
| 142 | 24 230:230:77
|
|---|
| 143 | 25 204:242:77
|
|---|
| 144 | 26 153:255:153
|
|---|
| 145 | 28 204:255:255
|
|---|
| 146 | 29 242:204:166
|
|---|
| 147 | 30 151:71:6
|
|---|
| 148 | 31 226:107:10
|
|---|
| 149 | 32 250:191:143
|
|---|
| 150 | 33 252:213:180
|
|---|
| 151 | 34 253:253:217
|
|---|
| 152 | 35 218:238:243
|
|---|
| 153 | 36 183:222:232
|
|---|
| 154 | 37 146:205:220
|
|---|
| 155 | 38 49:200:155
|
|---|
| 156 | 40 230:128:0
|
|---|
| 157 | 41 128:255:0
|
|---|
| 158 | 42 230:166:0
|
|---|
| 159 | 43 0:166:0
|
|---|
| 160 | 44 77:255:0
|
|---|
| 161 | 45 79:98:40
|
|---|
| 162 | 47 242:242:242
|
|---|
| 163 | 48 204:204:204
|
|---|
| 164 | 49 255:255:255
|
|---|
| 165 | 50 204:255:204
|
|---|
| 166 | 52 255:255:168
|
|---|
| 167 | 53 255:255:0
|
|---|
| 168 | 54 255:0:0
|
|---|
| 169 | 55 255:125:125
|
|---|
| 170 | 56 166:0:204
|
|---|
| 171 | 57 255:85:0
|
|---|
| 172 | 58 230:230:255
|
|---|
| 173 | 59 166:77:0
|
|---|
| 174 | 100 182:237:240
|
|---|
| 175 | 101 180:236:240
|
|---|
| 176 | 103 177:232:240
|
|---|
| 177 | 104 175:231:240
|
|---|
| 178 | 105 175:230:240
|
|---|
| 179 | 106 173:229:240
|
|---|
| 180 | 110 170:227:240
|
|---|
| 181 | 111 170:226:240
|
|---|
| 182 | 113 164:220:237
|
|---|
| 183 | 114 164:220:237
|
|---|
| 184 | 115 161:218:237
|
|---|
| 185 | 116 159:216:237
|
|---|
| 186 | 120 157:214:237
|
|---|
| 187 | 200 145:205:237
|
|---|
| 188 | 201 145:205:237
|
|---|
| 189 | 203 138:199:235
|
|---|
| 190 | 204 136:197:235
|
|---|
| 191 | 205 134:196:235
|
|---|
| 192 | 206 134:194:235
|
|---|
| 193 | 210 131:193:235
|
|---|
| 194 | 211 129:192:235
|
|---|
| 195 | 213 127:190:235
|
|---|
| 196 | 214 124:189:235
|
|---|
| 197 | 215 124:187:235
|
|---|
| 198 | 216 120:185:235
|
|---|
| 199 | 220 120:185:235
|
|---|
| 200 | 300 104:172:232
|
|---|
| 201 | 301 104:172:232
|
|---|
| 202 | 303 100:170:232
|
|---|
| 203 | 304 97:167:232
|
|---|
| 204 | 305 94:164:230
|
|---|
| 205 | 306 92:163:230
|
|---|
| 206 | 310 92:163:230
|
|---|
| 207 | 311 87:161:230
|
|---|
| 208 | 313 85:160:230
|
|---|
| 209 | 314 83:159:230
|
|---|
| 210 | 315 80:157:230
|
|---|
| 211 | 316 80:155:230
|
|---|
| 212 | 320 76:153:230
|
|---|
| 213 | 326 64:145:227
|
|---|
| 214 | 400 61:144:227
|
|---|
| 215 | 401 57:142:227
|
|---|
| 216 | 403 54:141:227
|
|---|
| 217 | 404 50:138:227
|
|---|
| 218 | 405 48:137:227
|
|---|
| 219 | 406 43:134:224
|
|---|
| 220 | 410 40:135:224
|
|---|
| 221 | 411 38:134:224
|
|---|
| 222 | 413 31:131:224
|
|---|
| 223 | 414 31:131:224
|
|---|
| 224 | 415 31:126:222
|
|---|
| 225 | 416 31:126:222
|
|---|
| 226 | 420 33:128:222
|
|---|
| 227 | 426 32:114:214
|
|---|
| 228 | 500 34:111:212
|
|---|
| 229 | 501 34:111:212
|
|---|
| 230 | 503 33:107:209
|
|---|
| 231 | 504 33:107:209
|
|---|
| 232 | 505 33:102:207
|
|---|
| 233 | 506 33:102:207
|
|---|
| 234 | 510 33:98:204
|
|---|
| 235 | 511 33:98:204
|
|---|
| 236 | 513 32:94:201
|
|---|
| 237 | 514 32:91:201
|
|---|
| 238 | 515 32:90:199
|
|---|
| 239 | 516 34:89:199
|
|---|
| 240 | 520 33:88:196
|
|---|
| 241 | 526 33:77:191
|
|---|
| 242 | 600 32:76:189
|
|---|
| 243 | 601 32:76:189
|
|---|
| 244 | 603 32:73:186
|
|---|
| 245 | 604 32:70:186
|
|---|
| 246 | 605 29:68:184
|
|---|
| 247 | 606 29:65:184
|
|---|
| 248 | 610 29:64:181
|
|---|
| 249 | 614 28:58:176
|
|---|
| 250 | 616 28:55:176
|
|---|
| 251 | 620 28:54:173
|
|---|
| 252 | 700 25:44:166
|
|---|
| 253 | 701 23:40:166
|
|---|
| 254 | 704 23:37:163
|
|---|
| 255 | 705 21:35:161
|
|---|
| 256 | 706 21:35:161
|
|---|
| 257 | 710 21:32:158
|
|---|
| 258 | 720 15:22:153""")
|
|---|
| 259 | # close intermediate color level 2 rules
|
|---|
| 260 | fcl2.close()
|
|---|
| 261 |
|
|---|
| 262 | # write intermediate category rule file level 2
|
|---|
| 263 | fcal2 = open('%s' % (tmp_cat_l2), 'wt')
|
|---|
| 264 | fcal2.write("""100|A100 - Littoral undetermined substrate with no sea ice presence
|
|---|
| 265 | 101|A101 - Littoral rock and biogenic with no sea ice presence
|
|---|
| 266 | 103|A103 - Littoral coarse sediment with no sea ice presence
|
|---|
| 267 | 104|A104 - Littoral mixed sediment with no sea ice presence
|
|---|
| 268 | 105|A105 - Littoral sand with no sea ice presence
|
|---|
| 269 | 106|A106 - Littoral mud with no sea ice presence
|
|---|
| 270 | 110|A110 - Littoral undetermined substrate with seasonal sea ice presence
|
|---|
| 271 | 111|A111 - Littoral rock and biogenic with seasonal sea ice presence
|
|---|
| 272 | 113|A113 - Littoral coarse sediment with seasonal sea ice presence
|
|---|
| 273 | 114|A114 - Littoral mixed sediment with seasonal sea ice presence
|
|---|
| 274 | 115|A115 - Littoral sand with seasonal sea ice presence
|
|---|
| 275 | 116|A116 - Littoral mud with seasonal sea ice presence
|
|---|
| 276 | 120|A120 - Littoral undetermined substrate with perrennial sea ice
|
|---|
| 277 | 200|A200 - Infralittoral undetermined substrate with no sea ice presence
|
|---|
| 278 | 201|A201 - Infralittoral rock and biogenic with no sea ice presence
|
|---|
| 279 | 203|A203 - Infralittoral coarse sediment with no sea ice presence
|
|---|
| 280 | 204|A204 - Infralittoral mixed sediment with no sea ice presence
|
|---|
| 281 | 205|A205 - Infralittoral sand with no sea ice presence
|
|---|
| 282 | 206|A206 - Infralittoral mud with no sea ice presence
|
|---|
| 283 | 210|A210 - Infralittoral undetermined substrate with seasonal sea ice presence
|
|---|
| 284 | 211|A211 - Infralittoral rock and biogenic with seasonal sea ice presence
|
|---|
| 285 | 213|A213 - Infralittoral coarse sediment with seasonal sea ice presence
|
|---|
| 286 | 214|A214 - Infralittoral mixed sediment with seasonal sea ice presence
|
|---|
| 287 | 215|A215 - Infralittoral sand with seasonal sea ice presence
|
|---|
| 288 | 216|A216 - Infralittoral mud with seasonal sea ice presence
|
|---|
| 289 | 220|A220 - Infralittoral undetermined substrate with perrennial sea ice
|
|---|
| 290 | 300|A300 - Circalittoral undetermined substrate with no sea ice presence
|
|---|
| 291 | 301|A301 - Circalittoral rock and biogenic with no sea ice presence
|
|---|
| 292 | 303|A303 - Circalittoral coarse sediment with no sea ice presence
|
|---|
| 293 | 304|A304 - Circalittoral mixed sediment with no sea ice presence
|
|---|
| 294 | 305|A305 - Circalittoral sand with no sea ice presence
|
|---|
| 295 | 306|A306 - Circalittoral mud with no sea ice presence
|
|---|
| 296 | 310|A310 - Circalittoral undetermined substrate with seasonal sea ice presence
|
|---|
| 297 | 311|A311 - Circalittoral rock and biogenic with seasonal sea ice presence
|
|---|
| 298 | 313|A313 - Circalittoral coarse sediment with seasonal sea ice presence
|
|---|
| 299 | 314|A314 - Circalittoral mixed sediment with seasonal sea ice presence
|
|---|
| 300 | 315|A315 - Circalittoral sand with seasonal sea ice presence
|
|---|
| 301 | 316|A316 - Circalittoral mud with seasonal sea ice presence
|
|---|
| 302 | 320|A320 - Circalittoral undetermined substrate with perrennial sea ice
|
|---|
| 303 | 326|A326 - Circalittoral mud with perrennial sea ice
|
|---|
| 304 | 400|A400 - Offshore circalittoral undetermined substrate with no sea ice presence
|
|---|
| 305 | 401|A401 - Offshore circalittoral rock and biogenic with no sea ice presence
|
|---|
| 306 | 403|A403 - Offshore circalittoral coarse sediment with no sea ice presence
|
|---|
| 307 | 404|A404 - Offshore circalittoral mixed sediment with no sea ice presence
|
|---|
| 308 | 405|A405 - Offshore circalittoral sand with no sea ice presence
|
|---|
| 309 | 406|A406 - Offshore circalittoral mud with no sea ice presence
|
|---|
| 310 | 410|A410 - Offshore circalittoral undetermined substrate with seasonal sea ice presence
|
|---|
| 311 | 411|A411 - Offshore circalittoral rock and biogenic with seasonal sea ice presence
|
|---|
| 312 | 413|A413 - Offshore circalittoral coarse sediment with seasonal sea ice presence
|
|---|
| 313 | 414|A414 - Offshore circalittoral mixed sediment with seasonal sea ice presence
|
|---|
| 314 | 415|A415 - Offshore circalittoral sand with seasonal sea ice presence
|
|---|
| 315 | 416|A416 - Offshore circalittoral mud with seasonal sea ice presence
|
|---|
| 316 | 420|A420 - Offshore circalittoral undetermined substrate with perrennial sea ice
|
|---|
| 317 | 426|A426 - Offshore circalittoral mud with perrennial sea ice
|
|---|
| 318 | 500|A500 - Upper bathyal undetermined substrate with no sea ice presence
|
|---|
| 319 | 501|A501 - Upper bathyal rock and biogenic with no sea ice presence
|
|---|
| 320 | 503|A503 - Upper bathyal coarse sediment with no sea ice presence
|
|---|
| 321 | 504|A504 - Upper bathyal mixed sediment with no sea ice presence
|
|---|
| 322 | 505|A505 - Upper bathyal sand with no sea ice presence
|
|---|
| 323 | 506|A506 - Upper bathyal mud with no sea ice presence
|
|---|
| 324 | 510|A510 - Upper bathyal undetermined substrate with seasonal sea ice presence
|
|---|
| 325 | 511|A511 - Upper bathyal rock and biogenic with seasonal sea ice presence
|
|---|
| 326 | 513|A513 - Upper bathyal coarse sediment with seasonal sea ice presence
|
|---|
| 327 | 514|A514 - Upper bathyal mixed sediment with seasonal sea ice presence
|
|---|
| 328 | 515|A515 - Upper bathyal sand with seasonal sea ice presence
|
|---|
| 329 | 516|A516 - Upper bathyal mud with seasonal sea ice presence
|
|---|
| 330 | 520|A520 - Upper bathyal undetermined substrate with perrennial sea ice
|
|---|
| 331 | 526|A526 - Upper bathyal mud with perrennial sea ice
|
|---|
| 332 | 600|A600 - Lower bathyal undetermined substrate with no sea ice presence
|
|---|
| 333 | 601|A601 - Lower bathyal rock and biogenic with no sea ice presence
|
|---|
| 334 | 603|A603 - Lower bathyal coarse sediment with no sea ice presence
|
|---|
| 335 | 604|A604 - Lower bathyal mixed sediment with no sea ice presence
|
|---|
| 336 | 605|A605 - Lower bathyal sand with no sea ice presence
|
|---|
| 337 | 606|A606 - Lower bathyal mud with no sea ice presence
|
|---|
| 338 | 610|A610 - Lower bathyal undetermined substrate with seasonal sea ice presence
|
|---|
| 339 | 614|A614 - Lower bathyal mixed sediment with seasonal sea ice presence
|
|---|
| 340 | 616|A616 - Lower bathyal mud with seasonal sea ice presence
|
|---|
| 341 | 620|A620 - Lower bathyal undetermined substrate with perrennial sea ice
|
|---|
| 342 | 700|A700 - Abyssal undetermined substrate with no sea ice presence
|
|---|
| 343 | 701|A701 - Abyssal rock and biogenic with no sea ice presence
|
|---|
| 344 | 704|A704 - Abyssal mixed sediment with no sea ice presence
|
|---|
| 345 | 705|A705 - Abyssal sand with no sea ice presence
|
|---|
| 346 | 706|A706 - Abyssal mud with no sea ice presence
|
|---|
| 347 | 710|A710 - Abyssal undetermined substrate with seasonal sea ice presence
|
|---|
| 348 | 720|A720 - Abyssal undetermined substrate with perrennial sea ice
|
|---|
| 349 | 9|X1 - Estuaries
|
|---|
| 350 | 10|X2_3 - Coastal lagoons
|
|---|
| 351 | 11|B1 - Coastal dunes and sandy shores
|
|---|
| 352 | 12|B2 - Coastal shingle
|
|---|
| 353 | 13|B3 - Rock cliffs, ledges and shores, including the supralittoral
|
|---|
| 354 | 14|C1 - Surface standing waters
|
|---|
| 355 | 15|C2 - Surface running waters
|
|---|
| 356 | 16|C3 - Littoral zone of inland surface waterbodies
|
|---|
| 357 | 17|D1 - Raised and blanket bogs
|
|---|
| 358 | 18|D2 - Valley mires, poor fens and transition mires
|
|---|
| 359 | 19|D3 - Aapa, palsa and polygon mires
|
|---|
| 360 | 20|D4 - Base-rich fens and calcareous spring mires
|
|---|
| 361 | 21|D5 - Sedge and reedbeds, normally without free-standing water
|
|---|
| 362 | 22|D6 - Inland saline and brackish marshes and reedbeds
|
|---|
| 363 | 23|E1 - Dry grasslands
|
|---|
| 364 | 24|E2 - Mesic grasslands
|
|---|
| 365 | 25|E3 - Seasonally wet and wet grasslands
|
|---|
| 366 | 26|E4 - Alpine and subalpine grasslands
|
|---|
| 367 | 28|E6 - Inland salt steppes
|
|---|
| 368 | 29|E7 - Sparsely wooded grasslands
|
|---|
| 369 | 30|F1 - Tundra
|
|---|
| 370 | 31|F2 - Arctic, alpine and subalpine scrub
|
|---|
| 371 | 32|F3 - Temperate and mediterranean-montane scrub
|
|---|
| 372 | 33|F4 - Temperate shrub heathland
|
|---|
| 373 | 34|F5 - Maquis, arborescent matorral and thermo-Mediterranean brushes
|
|---|
| 374 | 35|F6 - Garrigue
|
|---|
| 375 | 36|F7 - Spiny Mediterranean heaths (phrygana, hedgehog-heaths and related coastal cliff vegetation)
|
|---|
| 376 | 37|F8 - Thermo-Atlantic xerophytic scrub
|
|---|
| 377 | 38|F9 - Riverine and fen scrubs
|
|---|
| 378 | 40|FB - Shrub plantations
|
|---|
| 379 | 41|G1 - Broadleaved deciduous woodland
|
|---|
| 380 | 42|G2 - Broadleaved evergreen woodland
|
|---|
| 381 | 43|G3 - Coniferous woodland
|
|---|
| 382 | 44|G4 - Mixed deciduous and coniferous woodland
|
|---|
| 383 | 45|G5 - Lines of trees, small anthropogenic woodlands, recently felled woodland, early-stage woodland and coppice
|
|---|
| 384 | 47|H2 - Screes
|
|---|
| 385 | 48|H3 - Inland cliffs, rock pavements and outcrops
|
|---|
| 386 | 49|H4 - Snow or ice-dominated habitats
|
|---|
| 387 | 50|H5 - Miscellaneous inland habitats with very sparse or no vegetation
|
|---|
| 388 | 52|I1 - Arable land and market gardens
|
|---|
| 389 | 53|I2 - Cultivated areas of gardens and parks
|
|---|
| 390 | 54|J1 - Buildings of cities, towns and villages
|
|---|
| 391 | 55|J2 - Low density buildings
|
|---|
| 392 | 56|J3 - Extractive industrial sites
|
|---|
| 393 | 57|J4 - Transport networks and other constructed hard-surfaced areas
|
|---|
| 394 | 58|J5 - Highly artificial man-made waters and associated structures
|
|---|
| 395 | 59|J6 - Waste deposits""")
|
|---|
| 396 | # close intermediate category level 1 rules
|
|---|
| 397 | fcal2.close()
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 | # apply color rules level 2
|
|---|
| 401 | grass.message ( "applying color rules for data level 2..." )
|
|---|
| 402 | grass.run_command("r.colors", map = iraster,
|
|---|
| 403 | rules = tmp_col_l2,
|
|---|
| 404 | quiet = True)
|
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 | # apply category rules level 2
|
|---|
| 408 | grass.message ( "applying category rules for data level 2..." )
|
|---|
| 409 | grass.run_command("r.category", map = iraster,
|
|---|
| 410 | rules = tmp_cat_l2,
|
|---|
| 411 | separator = 'pipe',
|
|---|
| 412 | quiet = True)
|
|---|
| 413 |
|
|---|
| 414 | # do some clean up
|
|---|
| 415 | grass.message( "----" )
|
|---|
| 416 | grass.message( "cleaning intermediate files ...." )
|
|---|
| 417 | if level1 :
|
|---|
| 418 | os.remove("%s" % tmp_col_l1)
|
|---|
| 419 | os.remove("%s" % tmp_cat_l1)
|
|---|
| 420 |
|
|---|
| 421 | if level2 :
|
|---|
| 422 | os.remove("%s" % tmp_col_l2)
|
|---|
| 423 | os.remove("%s" % tmp_cat_l2)
|
|---|
| 424 |
|
|---|
| 425 | grass.message( "Cleaning done." )
|
|---|
| 426 | grass.message( "----" )
|
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 | if __name__ == "__main__":
|
|---|
| 430 | options, flags = grass.parser()
|
|---|
| 431 | sys.exit(main())
|
|---|