R/CentroidSpeices.R

#' Get the species in the centroid
#'
#' @param species a string containing all species name and country (if any) in the end, separate by ','.
#' @param centroid the result generated by the function Getcentroid
#' @return the gbif data that inside the centroid
#' @examples
#' centroid <- Getcentroid('Canada', 8)
#' CentroidSpecies('Pinus contorta,Danaus plexippus,Canada', centroid)
#' @import rgbif
#' @import spocc
#' @export

CentroidSpeices <- function(species, centroid){

        namelist <- Readname(species)

        #namelist contains the name "namelist[[1]]" the species number"namelist[[2]]"
        #the indicater of the country "namelist[[3]]" and the countrycode "namelist[[4]]"
        species_c <- namelist[[1]]
        species_n <- namelist[[2]]
        #checkcountry <- namelist[[3]]
        country_code <- namelist[[4]]
        countryname <- namelist[[5]]

        #Searching for the occurrence data
        species_c <- species_c[1:species_n]
        dat <- occ_search(scientificName = species_c, limit = 300, country = country_code, geometry = centroid, geom_big = "bbox")
}
Tim-Yu/rgcd documentation built on May 9, 2019, 4:46 p.m.