install.packages("rgbif")
library(rgbif)
The best way to approach this right now is to use the scientificname
argument in the occurrencelist
function. For example, use an asterisk "*" after "Abies", which will get you everything in the genus "Abies". Then you can clean up afterwards if you want. See below
There are only 2975, so we can just set maxresults below to this number
occurrencecount("Abies*", coordinatestatus=TRUE, originisocountrycode="ES")
[1] 2975
dataout <- occurrencelist(scientificname="Abies*",coordinatestatus=TRUE,
originisocountrycode="ES", removeZeros=TRUE, maxresults=2975)
head(dataout[,1:4])
taxonName country decimalLatitude decimalLongitude
1 Abies alba Mill. ES 42.92568 -0.8569100
2 Abies alba Mill. ES 42.92568 -0.8569100
3 Abies alba Mill. ES 43.02382 -1.3444000
4 Abies alba Mill. ES 42.92568 -0.8569100
5 Abies alba Mill. ES 42.92013 -0.8019660
6 Abies alba Mill. ES 42.75954 -0.8809775
length(unique(dataout$taxonName))
[1] 31
unique(dataout$taxonName)
[1] "Abies alba Mill."
[2] "Abies alba L."
[3] "Abies sp."
[4] "Abies"
[5] "Abies alba"
[6] "Abies alba Mill."
[7] "Abies alba M Miller"
[8] "Abies pinsapo Boiss."
[9] "Abies excelsa Poir."
[10] "Abies pectinata DC."
[11] "Abies balsamea (L.) Mill."
[12] "Abies nordmanniana (Steven) Spach"
[13] "Abies numidica De Lannoy ex Carriere"
[14] "Abies concolor Hildebr."
[15] "Abies alba Miller"
[16] "Abies koreana"
[17] "Abies pinsapo var. \"Kelleris\""
[18] "Abies pinsapo Boiss"
[19] "Abies pinsapo Boiss."
[20] "Abies pinsapo"
[21] "Abies excelsa DC."
[22] "Abies pectinata DC."
[23] "Abies nordmanniana"
[24] "Abies pectinata"
[25] "Abies alba Miller"
[26] "Abies marocana Trab."
[27] "Abies concolor (Gord.) Lindl. & Hildebr."
[28] "Abies pinsapo"
[29] "Abies cephalonica Loudon"
[30] "Abies concolor (Gord.) Lindl.ex Hildebr."
[31] "Abies pinsapo Boiss. var. pinsapo"
So you can exlude ones you don't want or change names using regex, for example (notice one name replaced)
library(stringr)
unique(gsub("Abies pinsapo Boiss","Abies pinsapo", dataout$taxonName, fixed=TRUE))
[1] "Abies alba Mill."
[2] "Abies alba L."
[3] "Abies sp."
[4] "Abies"
[5] "Abies alba"
[6] "Abies alba Mill."
[7] "Abies alba M Miller"
[8] "Abies pinsapo."
[9] "Abies excelsa Poir."
[10] "Abies pectinata DC."
[11] "Abies balsamea (L.) Mill."
[12] "Abies nordmanniana (Steven) Spach"
[13] "Abies numidica De Lannoy ex Carriere"
[14] "Abies concolor Hildebr."
[15] "Abies alba Miller"
[16] "Abies koreana"
[17] "Abies pinsapo var. \"Kelleris\""
[18] "Abies pinsapo"
[19] "Abies pinsapo Boiss."
[20] "Abies pinsapo"
[21] "Abies excelsa DC."
[22] "Abies pectinata DC."
[23] "Abies nordmanniana"
[24] "Abies pectinata"
[25] "Abies alba Miller"
[26] "Abies marocana Trab."
[27] "Abies concolor (Gord.) Lindl. & Hildebr."
[28] "Abies cephalonica Loudon"
[29] "Abies concolor (Gord.) Lindl.ex Hildebr."
[30] "Abies pinsapo. var. pinsapo"
I can't wrap my head around the GBIF taxonconceptkeys - I thought I got it, but using a taxononcept key from a search of Abies keys, you get back non-Abies results
abies.keys <- taxonsearch("Abies", rank="genus", maxresults=1000)
data <- occurrencelist(taxonconceptKey=abies.keys[[1]], coordinatestatus=TRUE, originisocountrycode="ES", removeZeros=TRUE, maxresults=200)
head(data[,1:4])
taxonName country decimalLatitude decimalLongitude
1 Megaspilidae Spain 38.91060 1.2725
2 Telenomus Spain 38.83330 1.3667
3 Telenomus Spain 38.91670 1.3500
4 Idris Spain 38.91670 1.3500
5 Conchoecia obtusa <NA> 44.04585 -12.7067
6 Diaphus garmani <NA> 28.04500 -14.0767
I will work on fixing this...