knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/"
)

rangeMapper

R-CMD-check CRAN_Status_Badge status Codecov test coverage

A framework for the study of macroecological patterns of life-history traits.

rangeMapper builds upon three types of data:

  1. Species distribution ranges
  2. Life-history datasets
  3. Environmental rasters

rangeMapper is build on three concepts:

  1. The canvas which is a regular grid of squares or hexagons.
  2. The subsets which are defined by combinations of life-history datasets and map data.
  3. The maps representing one or several variables summarised on the canvas.
require(rangeMapper)
require(sf)
require(data.table)
require(ggplot2)
require(patchwork)


con = rmap_connect()
rmap_add_ranges(con, x = wrens, ID = 'sci_name')
rmap_prepare(con, 'hex', cellsize = 500)
rmap_add_bio(con, wrens, 'sci_name')
rmap_save_map(con, fun= 'avg', v = 'clutch_size', src='wrens', dst='cs')
cs = rmap_to_sf(con, 'cs')
cnv = rmap_to_sf(con, 'wkt_canvas')

thm = theme_bw() +theme(plot.margin = unit(c(0,0,0,0), "cm") )

g1 = 
ggplot() + 
  geom_sf(data = wrens, aes(),  alpha= 0.2, size  = 0.3) + 
   thm +  ggtitle('Distribution ranges') + 
   scale_y_continuous(position = "right") + ylab('⇧') + theme(axis.title=element_text(size=30, color = "grey60") )

g2 = 
ggplot() + 
  geom_sf(data = cnv, aes(),  size  = 0.3) + 
  thm + ggtitle('Canvas') + 
  scale_y_continuous(position = "right") + ylab('⇧') + theme(axis.title=element_text(size=30, color = "grey60") )

g3 = 
ggplot(cs) + 
  geom_sf(aes(fill = avg_clutch_size),  size= 0.05, color = 'grey90', show.legend = FALSE) + 
  scale_fill_gradientn(colours = viridis::viridis(10, option = 'E') ) + 
  thm  + ggtitle('Map')

x = data.frame(Species = c('S1', 'S2', 'S3', '...', 'Si'), Trait = c('t1', 't2', 't3', '...', 'ti'))  

T = ggplot() +
  ggpmisc::annotate(geom = "table", x = 0, y = 0, size= 5, label = list(x) ) + 
  scale_x_continuous(position = "top") + xlab('⇧') + 
  guides(x = "none", y = "none") + ylab(NULL) +
  theme_minimal() + theme(axis.title=element_text(size=30, color = "grey60") ) 

(g1 + g2 + g3)/(plot_spacer() +T + plot_spacer()) 

File format

rangeMapper's project containers are sqlite files.

Installation

# Install release version from CRAN
install.packages("rangeMapper")

# Install development version from GitHub
remotes::install_github("mpio-be/rangeMapper")


mpio-be/rangeMapper documentation built on Oct. 6, 2022, 7:42 p.m.