humboldt.sample.spp | R Documentation |
Sample environment to occurrence points
humboldt.sample.spp(
dfsp,
colspxy = 2:3,
colspkept = "xy",
dfvar,
colvarxy = 1:2,
colvar = "all",
resolution,
run.silent.sam = F
)
dfsp |
Data frame of species with x, y and optional other variables |
colspxy |
The range of columns corresponding to longitude and latitude |
colspkept |
Columns to include in output from species dataset (default="xy") |
dfvar |
Environmental data frame with x, y and environmental variables |
colvarxy |
The range of columns for x and y in dfvar |
colvar |
The range of environmental variables columns in dfvar (excluding "xy", NULL=all) |
resolution |
of environmental data (typically in decimal degrees) |
run.silent.sam=F |
If run.silent.sam=T, texts boxes displaying progress will not be displayed. Default value is FASLE. |
A simple function to sample input environmental data corresponding sites of input occurrence points. Output is a table with environmental variables for each input locality (minus sites with no or missing environmental data).
library(humboldt)
##load environmental variables for all sites of the study area 1 (env1). Column names should be x,y,X1,X2,...,Xn)
env1<-read.delim("env1.txt",h=T,sep="\t")
## load environmental variables for all sites of the study area 2 (env2). Column names should be x,y,X1,X2,...,Xn)
env2<-read.delim("env2.txt",h=T,sep="\t")
## remove NAs and make sure all variables are imported as numbers
env1<-humboldt.scrub.env(env1)
env2<-humboldt.scrub.env(env2)
##load occurrence sites for the species at study area 1 (env1). Column names should be 'sp', 'x','y'
occ.sp1<-na.exclude(read.delim("sp1.txt",h=T,sep="\t"))
##load occurrence sites for the species at study area 2 (env2). Column names should be 'sp', 'x','y'
occ.sp2<-na.exclude(read.delim("sp2.txt",h=T,sep="\t"))
##remove occurrences closer than a minimum distance to each other (remove aggregation). Setting min.dist=0 will remove no occurrence.
occ.sp1<-humboldt.occ.rarefy(in.pts=occ.sp1,colxy=2:3, rarefy.dist=40, rarefy.units="km")
occ.sp2<-humboldt.occ.rarefy(in.pts=occ.sp2,colxy=2:3, rarefy.dist=40, rarefy.units="km")
##sample environment using humboldt.sample.sp() function
## env.reso should be the resolution of the environmental data grid
env.reso=0.41666669
occ.sp1<-na.exclude(humboldt.sample.spp(dfsp=occ.sp1,colspxy=2:3,colspkept=NULL,dfvar=env1,colvarxy=1:2,colvar="all",resolution=env.reso))
occ.sp2<-na.exclude(humboldt.sample.spp(dfsp=occ.sp2,colspxy=2:3,colspkept=NULL,dfvar=env2,colvarxy=1:2,colvar="all",resolution=env.reso))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.