|
|
Line 1: |
Line 1: |
− | [[Category:Projects]]
| |
− | [[Category:Hydrology in R]]
| |
| | | |
− | ===The topographic index===
| |
− |
| |
− | Some GIS programs can calculate the topographic index, but the [[Topmodel]]-package provides a function too. If you use the R function, you should delineate your catchment in your preferred GIS application and export a DEM of your catchment as a text file (ascii). Pixels outside the catchment area should be given a distinct value that can be set to NA in R.
| |
− |
| |
− | For now, the GIS functions of this package are quite limited. The DEM has to be imported as a matrix, which can then be processed by topidx(). Take for instance this minimalistic DEM, saved in a test file called "DEM.txt". Values outside the catchment are given the value -9999 (this can be any other value):
| |
− |
| |
− | -9999 -9999 828.9 835.6 -9999
| |
− | 818.3 826.0 830.7 834.5 836.0
| |
− | 817.1 824.0 825.2 833.3 836.9
| |
− | 816.5 820.0 824.1 330.8 -9999
| |
− | 810.7 815.6 822.2 -9999 -9999
| |
− |
| |
− | This file can be imported and processed in R with:
| |
− |
| |
− | DEM <- read.table("DEM.txt")
| |
− | DEM <- as.matrix(DEM)
| |
− |
| |
− | remove the values outside the catchment:
| |
− |
| |
− | DEM[DEM==-9999] <- NA
| |
− |
| |
− | plot the DEM:
| |
− |
| |
− | image(DEM)
| |
− |
| |
− | Calculate the topographic index. topidx() returns a list with two objects: atb and area. The first is the topographic index (a over tan b) and the second is the cumulative area a. In this case we are interested in atb:
| |
− |
| |
− | topindex <- topidx(DEM, resolution=25)$atb
| |
− |
| |
− | Split the values into a set of classes, for instance for use with topmodel():
| |
− |
| |
− | topidxclasses <- make.classes(topindex,16)
| |