mapdiv: mapdiv

Description Usage Arguments Value Examples

View source: R/functions.R

Description

Calculates the Shannon diversity per cell or fossilsite (taking into account relative abundances of all fossil records whithin the cell) and creates a plot of the map with a RasterLayer of the diversity.

Usage

1
2
3
4
5
mapdiv  (data, unity, rank = "genus", res = 1, map = NULL, 
                      fun = mean, model = "SETON2012",
                      colland = "#66666660", colsea = "#00509010", 
                      col.grid = mycols(100), 
                      do.plot = TRUE, save.as = NULL, ...)

Arguments

data

data.frame. Fossil occurrences data.

unity

character. Either "fossilsite" or "cell".

rank

character. The taxonomic rank of interest. "species", "genus", "family", "order", "class" or "phylum". By default rank = "genus".

res

numeric. The spatial resolution. By default res = 1.

map

(list of) SpatialPolygonDataFrames. Containing map(s) which can be created by mapast::getmap(ma, model).

fun

function or character. To determine what values to assign to cells that are covered by multiple spatial features. You can use functions such as min, max, or mean, or the character value 'count'. By default fun = mean.

model

character. The model the map should be created with. "SETON2012" (default), "MULLER2016", "GOLONKA", "PALEOMAP" or "MATTHEWS2016".

colland

character. The color of the land masses. By default colland = "#66666660".

colsea

character. The color of the sea. By default colsea = "#00509010".

col.grid

character. The color of the raster. By default col.grid = mycols(100).

do.plot

logical. If a plot is created or not. By default do.plot = TRUE.

save.as

character. The format the plots should be saved. "tiff", "pdf", "jpeg" or "png".

...

Graphical parameters. Any argument that can be passed to image.plot and to plot, such as main = "my own title" or main.col = "red".

Value

RasterLayer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Not run: 

library(mapast)

#get data and preprocess it
data  <-  base::data.frame(paleobioDB::pbdb_occurrences(base_name = "Canis", 
                                                        min_ma = 0, max_ma = 10, 
                                                        show = c("coords", "phylo"), 
                                                        vocab = "pbdb", limit = 100))
df <- formatdata(data = data)
df_auto <- paleocoords(data = df, time = "automatic")
                                                        
#create a plot with fossils on the paleogeographical map
div_fossilsite <- mapdiv(data = df_auto, unity = "fossilsite", rank = "species", res = 10,
                      fun = mean, model = "SETON2012")
div_cell <- mapdiv(data = df_auto, unity = "cell", rank = "species", res = 10, fun = mean,
                      model = "SETON2012")

#save the maps before so the function does not need to load them
maps <- getmap(ma = 2.5, model = "SETON2012", do.plot = FALSE)
mapdiv(data = df_auto, unity = "fossilsite", rank = "species", res = 10, map = maps,
                      fun = mean, model = "SETON2012")
mapdiv(data = df_auto, unity = "cell", rank = "species", res = 10, map = maps, fun = mean,
                      model = "SETON2012")

#save maps as pdf
mapdiv(data = df_auto, unity = "fossilsite", rank = "species", res = 10, map = maps, fun = mean,
                      model = "SETON2012", save.as = "pdf")
mapdiv(data = df_auto, unity = "cell", rank = "species", res = 10, map = maps, fun = mean,
                      model = "SETON2012", save.as = "pdf")


## End(Not run)

macroecology/mapast documentation built on March 1, 2020, 8:52 a.m.