Skip to contents

Creates a data.frame of species' references that contains longitude, latitude, and species name, using a list of raster layers as input. Useful when raster layers have distinct extent or resolution.

Usage

rlist_2data(raster_list)

Arguments

raster_list

list of SpatRaster objects. Each raster layer must be named as the species that it represents, and values in each layer must be 1 (presence) and 0 (absence).

Value

A data.frame of species geographic records derived from values of presence in each layer from the list of raster layers.

Examples

# Data
rsp <- terra::rast(system.file("extdata/sp_layers.tif",
                               package = "biosurvey"))
names(rsp) <- paste0("Species_", 1:5)

rlist <- lapply(1:5, function(x) {rsp[[x]]})

# Species data from RasterStack
sp_data <- rlist_2data(raster_list = rlist)
summary(sp_data)
#>    Longitude          Latitude       Species         
#>  Min.   :-117.05   Min.   :14.65   Length:11191      
#>  1st Qu.:-106.22   1st Qu.:18.98   Class :character  
#>  Median :-101.55   Median :22.31   Mode  :character  
#>  Mean   :-101.63   Mean   :22.85                     
#>  3rd Qu.: -97.55   3rd Qu.:26.48                     
#>  Max.   : -86.88   Max.   :32.65