class_map: Classify a raster.

View source: R/class_map.R

class_mapR Documentation

Classify a raster.

Description

Classify a raster image based on table of identified colour thresholds.

Usage

class_map(in.raster, colour.table = NULL, errors = 0, exceptions = NULL, plot.raster = TRUE, raster.summary = FALSE, return.raster=FALSE, save.raster = FALSE, out.file = NULL)

Arguments

in.raster

The smoothed raster to be Classified.

colour.table

Dataframe containing colour thresholds for different categories. Should either be an output from click_sample or else have an identical structure.

errors

Integer. Expand the range by n x the standard error within a sample. Higher numbers mean a larger range, but also increase the likelihood and magnitude of overlap between categories.

exceptions

Assign those (non-NA) pixels not falling within any colours in the colour table as a specific category string. Defaults to NULL, which can be useful for inspection, but will usually be assigned to a category in the end.

plot.raster

Logical. Plots the resulting classification, showing first the input raster, then each category separately, finishing with pixels not assigned to any class.

raster.summary

Logical. Print summary statistics describing the number of pixels and area (according to the attributes of the in raster)for each category in the classified raster.

return.raster

Logical. Do you want to return the raster as an object into your workspace? If so, you will also need to assign the function to an object, otherwise R will just print the raster information in the console.

save.raster

Logical. Do you want to save the resulting raster using writeRaster? Saves as GeoTiff with the data type INT1U.

out.file

Character. Filepath and name to pass to writeRaster. Include extenstion ".tif" (one f)

Value

Returns the classified raster. Values of raster cells in the output correspond to row numbers in the colour table input, i.e. the category represented by the first row will be 1, the second row 2 etc. Pixels that don't fit into any category (unless specified with 'exceptions') are given 0.

Author(s)

Alistair Auffret and Adam Kimberley

References

Auffret, A.G., Kimberley, A., et al., 2017, HistMapR: Rapid digitization of historical maps in R, Methods in Ecology and Evolution, doi: 10.1111/2041-210X.12788., Link. GitHub repository.

Hijmans, R.J. (2016) raster: Geographic Data Analysis and Modeling. R package version 2.5-8, http://CRAN.R-project.org/package=raster.

Examples

	data(HistMapRex)
	class_map(in.raster=ras.smoothed, colour.table = col.table, errors = 5, exceptions = "Arable", plot.raster = TRUE, raster.summary = TRUE, return.raster = FALSE, save.raster = FALSE, out.file = NULL) 

AGAuffret/HistMapR documentation built on July 20, 2023, 2:43 a.m.