Learn R Programming

elsa (version 1.1-28)

categorize: Categorizing continious data

Description

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

Usage

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)

Value

RasterLayer

if x is a RasterLayer

numeric vector

if x is a numeric vector

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.

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

Run this code
# NOT RUN {
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')

# }

Run the code above in your browser using DataLab