前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >R语言里做生态位分化分析(1)背景知识查询

R语言里做生态位分化分析(1)背景知识查询

作者头像
用户7010445
发布2024-06-07 19:35:05
1110
发布2024-06-07 19:35:05
举报

使用到的R包是 ENMtools,这个R包对应的github主页是

https://github.com/danlwarren/ENMTools

发现ggtree的作者Y叔也关注了这个R包的作者的github。那这个作者也是个大佬无疑了。

这个R包对应的论文

ENMTools 1.0: an R package for comparative ecological biogeography

https://nsojournals.onlinelibrary.wiley.com/doi/full/10.1111/ecog.05485

这个作者还有youtube账号专门介绍这个R包

https://www.youtube.com/@danlwarren

这个作者的github主页还有专门的一个仓库作为这个R包的教程

https://github.com/danlwarren/ENMTools-Tutorials

做生态位分化分析需要用到的函数是identity.test(),两个物种的经纬度,还有一个环境数据

这个R包对应的主页的文档里获取环境数据用到的是 geodata 这个R包

geodata对应的github主页

https://github.com/rspatial/geodata

这个R包里有世界气候数据( glocal climate data WorldClim)

这些数据对应的网站

https://worldclim.org/data/worldclim21.html

关于数据的基本介绍

This is WorldClim version 2.1 climate data for 1970-2000. This version was released in January 2020. There are monthly climate data for minimum, mean, and maximum temperature, precipitation, solar radiation, wind speed, water vapor pressure, and for total precipitation. There are also 19 “bioclimatic” variables.

这里的数据单位是 10 minutes 30 seconds。我开始以为是时间上的单位,查了一下原来是 地理上的单位,一个位置的经纬度 是度 分 秒

image.png

19个 bioclimatic 数据

https://worldclim.org/data/bioclim.html

image.png

还有海拔数据

这些数据可以直接使用R语言的命令来下载

比如下载 19个 bioclimatic

代码语言:javascript
复制
#install.packages("ENMTools")

library(ENMTools)
#remotes::install_github("rspatial/geodata")
library(geodata)
library(terra)
env <- worldclim_global(var='bio', res=10, path = "./")

这个env 是一个SpatRaster对象,这里有19个数据

可以直接用plot画图展示

代码语言:javascript
复制
plot(env[[1]])

image.png

还可以对这个数据进行裁剪,只展示特定的范围的数据

代码语言:javascript
复制
env01.crop <- crop(env[[1]], extent(-10, 17, 39, 48))

plot(env01.crop)

这里 -10 17 是经度范围 39 48 是维度范围

image.png

这个数据可以转换成数据框用ggplot2去作图

代码语言:javascript
复制
terra::as.data.frame(env[[1]],xy=TRUE) -> env1.data

head(env1.data)
library(ggplot2)
ggplot(env1.data, aes(x = x, y = y, fill = wc2.1_10m_bio_1)) +
  geom_raster() +
  scale_fill_gradient(low = "white", high = "blue") 

image.png

也可以单独下载某个国家的数据,用到的函数是 worldclim_country()

下载链接是 https://geodata.ucdavis.edu/climate/worldclim/

这里好想没有中国的bioclimatic数据

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2024-06-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 小明的数据分析笔记本 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档