raster2comm: Convert raw input distribution data to community

Description Usage Arguments Value See Also Examples

View source: R/convert_input_data.R

Description

The functions points2comm, polys2comm, raster2comm provide convenient interfaces to convert raw distribution data often available as point records, polygons and raster layers, respectively, to a community composition data frame at varying spatial grains and extents for downstream analyses.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
raster2comm(files)

polys2comm(dat, res = 1, species = "species", shp.grids = NULL, ...)

points2comm(
  dat,
  mask = NULL,
  res = 1,
  lon = "decimallongitude",
  lat = "decimallatitude",
  species = "species",
  shp.grids = NULL,
  ...
)

Arguments

files

list of raster layer objects with the same spatial extent and resolution.

dat

layers of merged maps corresponding to species polygons for polys2comm; or point occurrence data frame for points2comm, with at least three columns:

  • Column 1: species (listing the taxon names)

  • Column 2: decimallongitude (corresponding to decimal longitude)

  • Column 3: decimallatitude (corresponding to decimal latitude)

res

the grain size of the grid cells in decimal degrees (default).

species

a character string. The column with the species or taxon name. Default = “species”.

shp.grids

if specified, the polygon shapefile of grid cells with a column labeled “grids”.

...

Further arguments passed to or from other methods.

mask

Only applicable to points2comm. If supplied, a polygon shapefile covering the boundary of the survey region.

lon

character with the column name of the longitude.

lat

character with the column name of the latitude.

Value

Each of these functions generate a list of two objects as follows:

See Also

mapproject for conversion of latitude and longitude into projected coordinates system. long2sparse for conversion of community data.

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
fdir <- system.file("NGAplants", package="phyloregion")
files <- file.path(fdir, dir(fdir))
ras <- raster2comm(files) # Note, this function generates
     # a list of two objects
head(ras[[1]])



s <- readRDS(system.file("nigeria/nigeria.rds", package="phyloregion"))
sp <- random_species(100, species=5, shp=s)
pol <- polys2comm(dat = sp, species = "species")
head(pol[[1]])


s <- readRDS(system.file("nigeria/nigeria.rds", package = "phyloregion"))

set.seed(1)
m <- data.frame(sp::spsample(s, 10000, type = "nonaligned"))
names(m) <- c("lon", "lat")
species <- paste0("sp", sample(1:1000))
m$taxon <- sample(species, size = nrow(m), replace = TRUE)

pt <- points2comm(dat = m, mask = s, res = 0.5, lon = "lon", lat = "lat",
            species = "taxon") # Note, this generates a list of two objects
head(pt[[1]])

phyloregion documentation built on May 1, 2021, 9:06 a.m.