categorize: Categorizing continious data

Description Usage Arguments Details Value Author(s) References Examples

Description

A function to categorize (discretize or binning) numerical data in the form of a raster layer, or a vector.

Usage

1
categorize(x,nc,probs,...)

Arguments

x

A RasterLayer or a numerical vector

nc

Number of classes, if missing, it will be automatically detected

probs

a two-item numeric vector of the lower and upper probabilities within the range of [0,1], e.g., c(0.025, 0.975) (default: NULL) to consider a quantile range of values in categorization (to avoid the effects of outliers); if NULL or FALSE, then the whole range is used.

...

Additional parameters for writeRaster function (filename should be specified as additional argument)

Details

If nc is not specified, the function calls the function nclass to find the best number of classes. For the details of how nclass works, see the reference.

When outliers do exist in x, it is likely that they affect the quality of categorization. To avoid their affects, a quantile with the specified probabilities can be used. default is recommended: c(0.025,0.975), but to ignore it, you can turn the probs argument to NULL.

Value

RasterLayer

if x is a RasterLayer

numeric vector

if x is a numeric vector

Author(s)

Babak Naimi naimi.b@gmail.com

http://r-gis.net

References

Naimi, B., Hamm, N. A., Groen, T. A., Skidmore, A. K., Toxopeus, A. G., & Alibakhshi, S. (2019). ELSA: Entropy-based local indicator of spatial association. Spatial statistics, 29, 66-88.

Examples

1
2
3
4
5
6
7
categorize(1:10,3) # categorizeing a numeric vector into 3 categories

file <- system.file('external/dem_example.grd',package='elsa')
r <- raster(file)
plot(r,main='a continuous raster map')
rc <- categorize(r,nc=4)
plot(rc, main='categorized map')

elsa documentation built on March 19, 2020, 5:12 p.m.