Looking for species

In [1]:
using GBIF

Using the species function, we can search for the taxonKey of different species (and other taxonomic levels too). For example, we can search for informations about Iris versicolor:

In [2]:
species("Iris versicolor", rank=:SPECIES)
Out[2]:
Dict{String,Any} with 22 entries:
  "canonicalName"  => "Iris versicolor"
  "family"         => "Iridaceae"
  "genus"          => "Iris"
  "matchType"      => "EXACT"
  "confidence"     => 98
  "classKey"       => 196
  "familyKey"      => 7698
  "orderKey"       => 1169
  "status"         => "ACCEPTED"
  "usageKey"       => 5298019
  "rank"           => "SPECIES"
  "scientificName" => "Iris versicolor L."
  "class"          => "Liliopsida"
  "kingdom"        => "Plantae"
  "species"        => "Iris versicolor"
  "kingdomKey"     => 6
  "phylum"         => "Tracheophyta"
  "speciesKey"     => 5298019
  "order"          => "Asparagales"
  "synonym"        => false
  "phylumKey"      => 7707728
  "genusKey"       => 2748017

sdsdsdsdsds

In [3]:
i_ver = species("Iris versicolor", rank=:SPECIES)["speciesKey"];
i_vir = species("Iris virginica", rank=:SPECIES)["speciesKey"];
i_set = species("Iris setosa", rank=:SPECIES)["speciesKey"];
Out[3]:
5298796
In [34]:
o_ver = occurrences(Dict("taxonKey"=>i_ver, "hasCoordinate"=>true));
o_vir = occurrences(Dict("taxonKey"=>i_vir, "hasCoordinate"=>true));
o_set = occurrences(Dict("taxonKey"=>i_set, "hasCoordinate"=>true));
In [35]:
complete!(o_ver)
complete!(o_vir)
complete!(o_set)
In [56]:
qualitycontrol!(o_ver, filters=[have_ok_coordinates])
qualitycontrol!(o_vir, filters=[have_ok_coordinates])
qualitycontrol!(o_set, filters=[have_ok_coordinates])
INFO: Starting quality control with 1307 records
INFO: 913 records left after GBIF.have_ok_coordinates
INFO: Starting quality control with 333 records
INFO: 301 records left after GBIF.have_ok_coordinates
INFO: Starting quality control with 319 records
INFO: 106 records left after GBIF.have_ok_coordinates
Out[56]:
true
In [57]:
using DataFrames, Query, StatPlots, Plots
In [59]:
iris = vcat(DataFrame(o_ver), DataFrame(o_vir), DataFrame(o_set));
In [60]:
columns_kept = [:species, :key, :dataset, :date, :latitude, :longitude, :country, :observer];
iris = iris[:,columns_kept]
Out[60]:
specieskeydatasetdatelatitudelongitudecountryobserver
1Iris versicolor1453477510iNaturalist research-grade observations2017-03-04T12:52:3529.046689-95.475967United StatesJulie Pearce
2Iris versicolor1500344499iNaturalist research-grade observations2017-04-29T10:35:2239.707347-82.69345United StatesJoe Brehm
3Iris versicolor1500259371iNaturalist research-grade observations2017-04-17T13:07:3640.293372-74.725328United Statesaeafa17
4Iris versicolor1500228344iNaturalist research-grade observations2017-04-13T10:36:0047.378387-91.187312United StatesEmily Shosh
5Iris versicolor1563436242iNaturalist research-grade observations2017-05-29T15:58:1038.990042-76.921253United Statesbelyykit
6Iris versicolor1563429498iNaturalist research-grade observations2017-05-25T17:11:1441.290844-73.598944United StatesShaun Michael
7Iris versicolor1562941189iNaturalist research-grade observations2017-05-15T14:39:4340.364613-74.754547United Statesmarybaum
8Iris versicolor1571077525iNaturalist research-grade observations2017-05-28T12:31:0050.4580126.461901GermanyMarion Zöller
9Iris versicolor1571083296iNaturalist research-grade observations2017-05-27T15:38:3545.988184-74.00615Canadamayafav
10Iris versicolor1571111308iNaturalist research-grade observations2017-05-29T09:50:0043.046847-87.9859United StatesWolfgang Siebeneich
11Iris versicolor1562981606iNaturalist research-grade observations2017-05-24T11:16:5840.628147-74.505745United Statesbrionnap
12Iris versicolor1563444812iNaturalist research-grade observations2017-05-27T14:23:0043.026327-89.435824United Statesrayrob
13Iris versicolor1563435833iNaturalist research-grade observations2017-05-29T08:37:0041.704115-70.271489United StatesRoger Debenham
14Iris versicolor1563429365iNaturalist research-grade observations2017-05-25T18:04:5241.291211-73.599193United StatesShaun Michael
15Iris versicolor1562936164iNaturalist research-grade observations2017-05-14T10:11:0047.38027-91.187363United StatesJoe Walewski
16Iris versicolor1563437695iNaturalist research-grade observations2017-05-29T20:34:4043.920812-89.9012United Statesbenandkerstyn
17Iris versicolor1572336799iNaturalist research-grade observations2017-05-29T00:00:0042.986997-89.354302United StatesScott Sauer
18Iris versicolor1563444946iNaturalist research-grade observations2017-05-31T13:37:0044.9-93.196169United StatesAndy Birkey
19Iris versicolor1571090139iNaturalist research-grade observations2017-05-27T13:08:0043.046878-87.985929United StatesWolfgang Siebeneich
20Iris versicolor1571078150iNaturalist research-grade observations2017-05-30T10:19:0139.875542-75.671904United Statesgsmccoy
21Iris versicolor1562952720iNaturalist research-grade observations2017-05-08T09:21:0047.381962-91.196071United Statesrosieh
22Iris versicolor1563440657iNaturalist research-grade observations2017-05-25T12:49:0040.67827-74.33443United StatesSara Rall
23Iris versicolor1571079266iNaturalist research-grade observations2017-05-30T14:28:0044.039444-92.505556United Stateskrallen
24Iris versicolor1572348515iNaturalist research-grade observations2017-06-24T13:54:0045.988094-89.623949United StatesEric Moody
25Iris versicolor1571117924iNaturalist research-grade observations2017-06-10T11:30:2140.330983-74.942345United Statesasleaftalk
26Iris versicolor1571167189iNaturalist research-grade observations2017-06-19T10:32:5244.66788-63.523012Canadacandelita
27Iris versicolor1571147294iNaturalist research-grade observations2017-06-16T14:39:0044.301918-72.430317United StatesErika Mitchell
28Iris versicolor1571166494iNaturalist research-grade observations2017-06-15T10:27:0043.743841-73.047095United Statestomrogers
29Iris versicolor1571151747iNaturalist research-grade observations2017-06-10T18:14:0046.024536-91.539161United Statesthesnaguy
30Iris versicolor1571158924iNaturalist research-grade observations2017-06-18T09:42:0044.351229-73.00761United StatesEric Laws
In [63]:
sort!(by(iris, [:species, :country], df -> DataFrame(N=size(df, 1))), cols=[:N], rev=true)
Out[63]:
speciescountryN
1Iris versicolorUnited States508
2Iris versicolorCanada294
3Iris virginicaUnited States286
4Iris versicolorUnited Kingdom68
5Iris setosaUnited States42
6Iris setosaCanada35
7Iris versicolorGermany24
8Iris setosaJapan19
9Iris virginicaCanada15
10Iris setosaRussian Federation8
11Iris versicolorSweden8
12Iris versicolorDenmark5
13Iris versicolorFrance2
14Iris versicolorNetherlands2
15Iris setosaChina1
16Iris setosaSweden1
17Iris versicolorAustria1
18Iris versicolorNorway1
In [72]:
northam = @from i in iris begin
    @where i.country  ["Canada", "United States"]
    @select {i.species, i.date, i.latitude, i.longitude}
    @collect DataFrame
end
Iversicolor = northam[northam[:species].=="Iris versicolor",:];
Ivirginica = northam[northam[:species].=="Iris virginica",:];
Isetosa = northam[northam[:species].=="Iris setosa",:];
In [86]:
scatter(Iversicolor, :longitude, :latitude, marker=(:blue, :circle, 0.3, 3), lab="I. versicolor")
scatter!(Ivirginica, :longitude, :latitude, marker=(:green, :rect, 0.1, 3), lab="I. vriginica")
scatter!(Isetosa, :longitude, :latitude, marker=(:orange, :utriangle, 0.6, 3), lab="I. setosa")
Out[86]:
-150 -100 -50 30 40 50 60 longitude latitude I. versicolor I. vriginica I. setosa