HistWrapR: Smooth and classify a raster.

View source: R/HistWrapR.R

HistWrapRR Documentation

Smooth and classify a raster.

Description

A wrapper function that runs both smooth_map and class_map, useful for iterating the same arguments over similar maps with lapply or mclapply. My experience is that running multiple maps lapply is not quicker than a for loop running the two HistMapR functions separately, and looping makes it easier to follow progress. However, parallelisation with mclapply has the potential to be considerably faster, hence this function

Usage

HistWrapR(ras.file, colour.table=NULL, out.format="save", out.dir=".", ...)

Arguments

ras.file

The path to the input raster to be smoothed and classified. Note that this is not the raster object itself (as with other functions in HistMapR), but the path to it, which allows for parallelisation.

colour.table

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

out.format

"save" saves the classified raster, while "return" returns it as an object.

out.dir

The directory where rasters should be saved.

...

Additional arguments passed to smooth_map (e.g. darkValue or window.size) and class_map (e.g. exceptions or errors. Those not specified will take default arguments from the functions.

Value

Saves or returns the classified raster.

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. (2023) terra: Spatial Data Analysis. R package version 1.7-29, https://CRAN.R-project.org/package=terra.

Examples

	data.loc <- system.file("data", package="HistMapR")
	ras.smoothed <- rast(paste0(data.loc,"/ras.smoothed.tiff"))
	col.table <- read.csv(paste0(data.loc,"/col.table.csv"))

	HistWrapR(ras.file=ras.loc, colour.table = col.table, out.format="return") 

AGAuffret/HistMapR documentation built on Feb. 23, 2025, 1:11 a.m.