categorize | R Documentation |
A function to categorize (discretize or binning) numerical data in the form of a raster layer, or a vector.
categorize(x,nc,probs,...)
x |
A |
nc |
A single numeric: Number of classes, or a vector specifying the categorization thresholds (in case if x is a multi-layer raster, nc can be a list of vectors); 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 |
... |
Additional parameters for |
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
.
RasterLayer |
if x is a |
numeric vector |
if x is a numeric |
Babak Naimi naimi.b@gmail.com
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.
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')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.