Learn R Programming

HYPEtools (version 1.6.4)

ReadDescription: Read a 'description.txt' file

Description

Read a 'description.txt' file as list object into R. A 'description.txt' file contains land use, soil, and crop class names of a HYPE set-up, as well as model set-up name and version.

Usage

ReadDescription(
  filename,
  gcl = NULL,
  ps = NULL,
  encoding = c("unknown", "UTF-8", "latin1")
)

Value

ReadDescription returns a named list with named character elements, corresponding to the imported lines:

Name, Version, lu.id, Landuse, lu (short names), so.id, Soil, so (short names), cr.id, Crop, cr (short names), ps.id, PointSource, ps (short names)

Arguments

filename

Path to and file name of the 'description.txt' file to import.

gcl

dataframe, GeoClass.txt file imported with ReadGeoClass to compare class IDs with. A warning will be thrown if not all class IDs in gcl exist in the description file.

ps

dataframe, PointSourceData.txt file imported with ReadPointSourceData to compare point source type IDs with. A warning will be thrown if not all type IDs in ps exist in the description file.

encoding

Character string, encoding of non-ascii characters in imported text file. Particularly relevant when importing files created under Windows (default encoding "Latin-1") in Linux (default encoding "UTF-8") and vice versa. See also argument description in scan.

Details

ReadDescription imports a 'description.txt' into R. This file is not used by HYPE, but is convenient for e.g. plotting legend labels or examining imported GeoClass files. E.g., PlotBasinSummary requires a list as returned from ReadDescription for labeling.

A 'description.txt' file consists of 28 lines, alternating names and semicolon-separated content. Lines with names are not read by the import function, they just make it easier to compose and read the actual text file.

File contents read by ReadDescription:

  • HYPE set-up name (line 2)

  • HYPE set-up version (line 4)

  • Land use class IDs (line 6)

  • Land use class names (line 8)

  • Land use class short names (line 10)

  • Soil class IDs (line 12)

  • Soil class names (line 14)

  • Soil class short names (line 16)

  • Crop class IDs (line 18)

  • Crop class names (line 20)

  • Crop class short names (line 22)

  • Point Source IDs (line 24)

  • Point Source type names (line 26)

  • Point Source type short names (line 28)

Note that Crop class IDs start from 0, which means no crop, whereas land use and soil IDs start from 1 (or higher).

Formatting example for description.txt files:

# Name
MyHYPE
# Version
0.1
# Land use class IDs
1;2
# Land use class names
Agriculture;Coniferous forest
# Short land use class names
Agric.;Conif. f.
# Soil class IDs
1;2
# Soil class names
Coarse soils;Medium to fine soils
# Short soil class names
Coarse;Medium
# Crop class IDs
0;1;2
# Crop class names
None;Row crops;Autumn-sown cereal
# Short crop class names
None;Row;Aut.-sown
# Point source type IDs
-1;1;2
# Point source type names
Abstraction;Primary;Secondaryl
# Short point source type names
ABS;NP1;NP2

Examples

Run this code
te <- ReadDescription(filename = system.file("demo_model",
"description.txt", package = "HYPEtools"))
te

Run the code above in your browser using DataLab