convert_dec_to_base4frac: Convert a vector of values from the 'GRTSmaster_habitats'...

View source: R/GRTSmh.R

convert_dec_to_base4fracR Documentation

Convert a vector of values from the GRTSmaster_habitats data source to base 4 fractions

Description

Converts decimal (i.e. base 10) integer values from the raster data source GRTSmaster_habitats into base 4 fractions, using a precision of 13 digits behind the decimal mark (as needed to cope with the range of values). For example, the integer 16 (= 4^2) is converted into 0.0000000000100 and 4^12 is converted into 0.1000000000000.

Usage

convert_dec_to_base4frac(x)

Arguments

x

A decimal (i.e. base 10) scalar or vector of integer values from the GRTSmaster_habitats raster.

Details

Long base 4 fractions seem to be handled and stored easier than long (base 4) integers. This approach follows the one of Stevens & Olsen (2004) to represent the reverse hierarchical order in a GRTS sample as base-4-fraction addresses.

The function works on a vector and retains NA values. As such, it can be used in raster::calc(). When writing such a raster to a file, it is needed to use the FLT8S data type (see dataType). Otherwise several digits will change.

The function is based on code from the baseConvert() function in Will Gray's Gmisc package.

Value

The corresponding base4 scalar or vector, stored as a fraction.

References

Stevens D.L. & Olsen A.R. (2004). Spatially Balanced Sampling of Natural Resources. Journal of the American Statistical Association 99 (465): 262–278. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1198/016214504000000250")}.

See Also

Other functions involved in processing the 'GRTSmaster_habitats' data source: convert_base4frac_to_dec(), read_GRTSmh(), read_GRTSmh_base4frac(), read_GRTSmh_diffres()

Examples

oldoption <- options(list(digits = 15, scipen = 999))
convert_dec_to_base4frac(c(14, 15, NA, 456))
options(oldoption)


inbo/n2khab documentation built on Jan. 15, 2025, 9:36 a.m.