赖江山的博客分享 http://blog.sciencenet.cn/u/laijiangshan 生态、统计与R语言

博文

用R直接从全球生物多样性信息网络(GBIF)获取物种地理分布数据

已有 19160 次阅读 2017-4-10 14:23 |个人分类:RDA|系统分类:科研笔记

#install.packages(c('raster', 'rgdal', 'dismo', 'rJava'))
# loads the dismo (distribution modeling) library
#using an example file that is installed with the dismo package
library(dismo)
Xishu= gbif("Camptotheca", "acuminata")
#Use '*' to download the entire genus. 
#Append '*' to the species name to get all naming variants 
#Xishu= gbif("Camptotheca", "acuminata",extent(85,125,10,55))
# how many rows and colums?
dim(Xishu)
#select the records that have longitude and latitude data
colnames(Xishu)
Xishu$lon
XSgeo <- subset(Xishu, !is.na(lon) & !is.na(lat))
dim(XSgeo)
#remove duplicated record
dups <- duplicated(XSgeo[, c('lon', 'lat')])
XSfin=XSgeo[!dups,]
dim(XSfin)
# show some values
#opne world simple map
library(maptools)
data(wrld_simpl)
plot(wrld_simpl, xlim=c(85,125), ylim=c(10,55), axes=TRUE,col="light yellow")
# restore the box around the map
box()
# plot points
points(XSfin$lon, XSfin$lat, col='orange', pch=20, cex=0.75)
# plot points again to add a border, for better visibility
points(XSfin$lon, XSfin$lat, col='red', cex=0.75)




https://blog.sciencenet.cn/blog-267448-1047946.html

上一篇:R里面读取netcdf(.nc)格式数据的函数
下一篇:已知经纬度直接算地理距离的函数
收藏 IP: 159.226.89.*| 热度|

3 李利平 封托 周向军

该博文允许注册用户评论 请点击登录 评论 (8 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-20 05:32

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部