smooth_map | R Documentation |
Smooths out inconsistencies in the map by performing a function on each pixel based on the values of surrounding pixels. Can also remove dark RGB values, typically used for map text, boundaries etc.
smooth_map(in.raster, window.size = 25, smooth.function = mean, dark.rm = TRUE, darkValue = 100, pad = TRUE, padValue = NA)
in.raster |
The raster object to be smoothed. This must be an RGB raster object, i.e. with three colour bands. Other types of raster may return an error, but can be converted e.g. in QGIS. |
window.size |
Integer. Default = 25. Must be odd. Passed to |
smooth.function |
Function. Name of an R function to apply within the window specified. Default = mean. Other functions e.g. max, min, modal are possible but run very slowly. See |
dark.rm |
Logical. Reduce the effect of map text, boundaries etc. by removing the darkest pixels prior to smoothing. Default is TRUE. |
darkValue |
Integer. Value below which all RGB layers should have for a pixel to be removed prior to smoothing. Default is 100. Too high values result in the appearance of large patches of white (NA) appear. Too low and text etc can interfere with land use categories. |
pad |
Logical. Pad the raster to avoid shrinkage. Default is TRUE. See |
padValue |
Value to pad the raster with. Default = NA. |
A smoothed raster object
Alistair Auffret and Adam Kimberley
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.
data(HistMapRex)
names(in.ras)<-c("red","green","blue")
ras.smoothed<-smooth_map(in.raster=in.ras, window.size = 5, smooth.function = mean, dark.rm = TRUE, darkValue = 80, pad = TRUE, padValue = NA)
plotRGB(ras.smoothed)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.