-
Notifications
You must be signed in to change notification settings - Fork 1
/
01_download_traitData.R
32 lines (24 loc) · 1.08 KB
/
01_download_traitData.R
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
26
27
28
29
30
31
32
# LIBS --------------------------------------------------------------------
library(BIEN)
library(tidyverse)
library(maptools)
library(rworldmap)
library(cleangeo)
# Download data -----------------------------------------------------------
spp <- BIEN_list_all()$species # Species list
traits <- BIEN_trait_species(spp) # Trait list
occur_spp<-BIEN_occurrence_species(spp,
natives.only=TRUE,
only.new.world=TRUE) # Occurrence data only New world
# Filter data -----------------------------------------------------------
# Remove info without coordinates
occur_spp_Geo<-
occur_spp%>%
filter(!is.na(latitude) & !is.na(longitude))
# Write downloaded data ---------------------------------------------------
name_file<-paste(format(Sys.time(), "%Y_%m_%d"), "BIEN_trait", sep="_")
# Traits
write.csv(traits,
file=paste("./data/",name_file,"data.csv", sep=""))
# Occurrences
saveRDS(occur_spp_Geo, file=paste("./data/",name_file,"OccurData.RData", sep=""))