
Plot a raster showing the richness of taxa
Source:R/pbdb_geographic_functions.R
pbdb_map_richness.RdCreates a SpatRaster object and a plot with richness of
species, genera, families, etc. per cell.
Arguments
- data
Input data frame. This data frame is the output of the
pbdb_occurrences()function using the argumentshow = c("coords", "classext"). See also Details and Examples.- rank
Taxon rank for which richness is calculated. The options are:
"species","genus","family","order","class"or"phylum". The default value is"species".- do_plot
Logical. If
TRUE, the function produces a plot in addition to returning aSpatRaster.- res
The resolution of the
SpatRasterobject (in decimal degrees). Seeterra::res().- col_int
The colour of the mainland.
- col_ocean
The colour of the ocean.
- col_rich
Two or more colours that are used to generate the colour gradient showing the richness per cell in the map.
- title
A title for the plot, to be positioned to the right of the legend.
- ...
Other parameters. See
par()andmaps::map().
Value
A SpatRaster object with the richness of the specified
taxon rank per cell. This SpatRaster object has the resolution
that was specified in the res argument. The default is res = 5. Users that wish to work with objects of this type should load
package terra.
Details
The argument show = c("coords", "classext") in the
pbdb_occurrences() function is required. We recommend the use
of a cairo device (X11()) for better visualization of the
graphs. See Examples.
See also
See pbdb_occurrences(), maps::map(), par() and colors()
help pages.
Examples
if (FALSE) { # \dontrun{
data <- pbdb_occurrences(
limit = 1000, vocab = "pbdb", base_name = "mammalia",
show = c("classext", "coords")
)
X11(width = 13, height = 7.8)
pbdb_map_richness(data, res = 8, rank = "genus")
pbdb_map_richness(data, res = 8, rank = "family")
## Get the raster object without plotting the map
pbdb_map_richness(data, res = 8, rank = "family", do_plot = FALSE)
} # }