Skip to contents

Classify habitats


classify_habitats(raster, return_breaks = FALSE, ...)



SpatRaster with continuous environmental values.


Logical if breaks should be returned as well.


Arguments passed on to classIntervals.




Classifies a SpatRaster from the raster packages with continuous values into n discrete classes. The cut function used to classify the raster, uses include.lowest = TRUE.

For more information about the classification methods, see classIntervals from the classInt package and/or the provided References. The help page of classIntervals also includes further possible arguments to find breaks (e.g., different styles, number of classes, fixed breaks, etc.).


Armstrong, M.P., Xiao, N., Bennett, D.A., 2003. Using genetic algorithms to create multicriteria class intervals for choropleth maps. Annals of the Association of American Geographers 93, 595–623. <>

Dent, B.D., 1999. Cartography: Thematic map design, 5th ed. WCB/McGraw-Hill, Boston, USA. ISBN 978-0-697-38495-9

Fisher, W.D., 1958. On grouping for maximum homogeneity. Journal of the American Statistical Association 53, 789–798. <>

Jenks, G.F., Caspall, F.C., 1971. Error in choroplethic maps: Definition, measurement, reduction. Annals of the Association of American Geographers 61, 217–244. <>

Jiang, B., 2013. Head/tail breaks: A new classification scheme for data with a heavy-tailed distribution. The Professional Geographer 65, 482-494. <>

Slocum, T.A., McMaster, R.B., Kessler, F.C., Howard, H.H., 2009. Thematic cartography and geovisualization, 3rd ed. ed, Prentice Hall Series in Geographic Information Science. Pearson Prentice Hall, Upper Saddle River, USA. ISBN 978-0-13-229834-6

Wand, M. P., 1995. Data-based choice of histogram binwidth. The American Statistician 51, 59-64. <>

See also



landscape_classified <- classify_habitats(terra::rast(landscape), n = 5, style = "fisher")

landscape_classified <- classify_habitats(terra::rast(landscape), style = "fixed",
fixedBreaks = c(0, 0.25, 0.75, 1.0), return_breaks = TRUE)