Case study - birds from the UK

In this example, we will build a map of the observations of birds from the United Kingdom.

In [1]:
using GBIF

Getting the data

The first thing is to specify the taxonKey -- this is explained in the GBIF taxonomy (but lookup feature will be added to the package later), and the country code (GB). Because the GBIF API cannot return more than 200000 records (that's already quite a lot, but common species have been observed far more), we will (i) focus on a single common species (the House sparrow, whose taxonKey is 5231190), and only observations for the year 2015.

In [2]:
uk_birds_query = Dict(
  "taxonKey"=>5231190,
  "country"=>"GB",
  "hasCoordinate"=>true,
  "year"=>2015)
uk_birds = occurrences(uk_birds_query)
Out[2]:
A  list of occurrences with a custom query - 20 out of 6296

This is good! The output means that we have 20 records already, out of 6296 that exist in GBIF. By default, we will only get the first 20, because (i) it avoids downloading all of the records at once, which consumes GBIF resources and (ii) there is a very simple way to get the records later.

We can now complete the request. This would take a while, since we are going through occurrences 20 at a time (this is the GBIF default). We can speed up the process a little bit, by requesting 200 records on every page. GBIF will not let you ask for more than 200 records by page.

In [3]:
uk_birds.query["limit"] = 200
Out[3]:
200

Let's now complete the request for real:

In [4]:
complete!(uk_birds)

Let's just have a look at the object now:

In [5]:
uk_birds
Out[5]:
A  list of occurrences with a custom query - 6296 out of 6296

Once this is done, we can start looking at observations. Let's load the Plots package to help us. We will also use DataFrames, because GBIF can export the results directly.

In [6]:
using Plots, DataFrames, StatPlots
#pyplot() # Feel free to replace by your favorite backend
In [7]:
birbs = DataFrame(uk_birds)
Out[7]:
keydatasetKeypublishingOrgKeypublishingCountrycountryCodecountrybasisOfRecordindividualCountlatitudelongitudeprecisionuncertaintygeodeticdateissuestaxonKeykingdomKeyphylumKeyclassKeyorderKeyfamilyKeygenusKeyspeciesKeykingdomphylumclassorderfamilygenusspeciesranknamegenericvernacularobserverlicense
113441218614fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATIONNA51.217987-3.024463NANAWGS842015-01-01T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr305550http://creativecommons.org/publicdomain/zero/1.0/legalcode
213441298434fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATIONNA55.043153-1.474953NANAWGS842015-01-01T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr255759http://creativecommons.org/publicdomain/zero/1.0/legalcode
313470764484fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION3054.653738-5.689346NANAWGS842015-01-20T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr88672http://creativecommons.org/publicdomain/zero/1.0/legalcode
413472465794fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION1252.073041-0.84159NANAWGS842015-01-24T00:00:00Symbol[]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr90515http://creativecommons.org/publicdomain/zero/1.0/legalcode
513472913344fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION252.424836-1.543013NANAWGS842015-01-04T00:00:00Symbol[]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr277872http://creativecommons.org/publicdomain/zero/1.0/legalcode
613487579614fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION254.653738-5.689346NANAWGS842015-01-26T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr88672http://creativecommons.org/publicdomain/zero/1.0/legalcode
713448524194fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION1054.021125-1.451812NANAWGS842015-01-03T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr346849http://creativecommons.org/publicdomain/zero/1.0/legalcode
813449648434fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATIONNA51.324683-3.015232NANAWGS842015-01-06T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr305550http://creativecommons.org/publicdomain/zero/1.0/legalcode
913453312954fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATIONNA51.531740.801175NANAWGS842015-01-09T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr190283http://creativecommons.org/publicdomain/zero/1.0/legalcode
1013462452574fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATIONNA54.787028-1.629882NANAWGS842015-01-17T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr337683http://creativecommons.org/publicdomain/zero/1.0/legalcode
1114113193834fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION151.596445-0.138687NANAWGS842015-01-09T00:00:00Symbol[]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr237749http://creativecommons.org/publicdomain/zero/1.0/legalcode
1214011585174fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION350.972479-1.443329NANAWGS842015-01-22T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr282174http://creativecommons.org/publicdomain/zero/1.0/legalcode
1314019219194fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATIONNA53.416285-2.325325NANAWGS842015-01-17T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr508556http://creativecommons.org/publicdomain/zero/1.0/legalcode
1414021716324fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATIONNA53.416285-2.325325NANAWGS842015-01-12T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr508556http://creativecommons.org/publicdomain/zero/1.0/legalcode
1513576549334fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATIONNA53.876121-0.930156NANAWGS842015-01-17T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr276883http://creativecommons.org/publicdomain/zero/1.0/legalcode
1615601845373dc2a7f6-8d3a-4228-a69c-ec795028fe2f47eaaa43-47c7-4754-8e7a-bfaf616da4dfGBGBUnited KingdomHUMAN_OBSERVATION3453.2463-4.47433NA10000.0WGS842015-01-01T00:00:00Symbol[:RECORDED_DATE_MISMATCH]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserHouse SparrowNAhttp://creativecommons.org/licenses/by-nc/4.0/legalcode
171538411848b7cd5ad0-f65a-4de1-a1bb-318cf5ae12f80ccc789d-ca07-4bb9-a1e7-a1d1b8491287GBGBUnited KingdomHUMAN_OBSERVATIONNA53.73743-2.68368NA2000.0WGS842015-01-01T00:00:00Symbol[:RECORDED_DATE_MISMATCH]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserHouse SparrowNAhttp://creativecommons.org/licenses/by-nc/4.0/legalcode
181537313293b7cd5ad0-f65a-4de1-a1bb-318cf5ae12f80ccc789d-ca07-4bb9-a1e7-a1d1b8491287GBGBUnited KingdomHUMAN_OBSERVATIONNA53.77338-2.68427NA2000.0WGS842015-01-01T00:00:00Symbol[:RECORDED_DATE_MISMATCH]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserHouse SparrowNAhttp://creativecommons.org/licenses/by-nc/4.0/legalcode
191537526295b7cd5ad0-f65a-4de1-a1bb-318cf5ae12f80ccc789d-ca07-4bb9-a1e7-a1d1b8491287GBGBUnited KingdomHUMAN_OBSERVATIONNA53.7376-2.65336NA2000.0WGS842015-01-01T00:00:00Symbol[:RECORDED_DATE_MISMATCH]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserHouse SparrowNAhttp://creativecommons.org/licenses/by-nc/4.0/legalcode
201537181995b7cd5ad0-f65a-4de1-a1bb-318cf5ae12f80ccc789d-ca07-4bb9-a1e7-a1d1b8491287GBGBUnited KingdomHUMAN_OBSERVATIONNA53.75523-2.7143NA2000.0WGS842015-01-01T00:00:00Symbol[:RECORDED_DATE_MISMATCH]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserHouse SparrowNAhttp://creativecommons.org/licenses/by-nc/4.0/legalcode
211538411848b7cd5ad0-f65a-4de1-a1bb-318cf5ae12f80ccc789d-ca07-4bb9-a1e7-a1d1b8491287GBGBUnited KingdomHUMAN_OBSERVATIONNA53.73743-2.68368NA2000.0WGS842015-01-01T00:00:00Symbol[:RECORDED_DATE_MISMATCH]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserHouse SparrowNAhttp://creativecommons.org/licenses/by-nc/4.0/legalcode
221537128469b7cd5ad0-f65a-4de1-a1bb-318cf5ae12f80ccc789d-ca07-4bb9-a1e7-a1d1b8491287GBGBUnited KingdomHUMAN_OBSERVATIONNA54.11452-2.75106NA2000.0WGS842015-01-01T00:00:00Symbol[:RECORDED_DATE_MISMATCH]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserHouse SparrowNAhttp://creativecommons.org/licenses/by-nc/4.0/legalcode
231537181995b7cd5ad0-f65a-4de1-a1bb-318cf5ae12f80ccc789d-ca07-4bb9-a1e7-a1d1b8491287GBGBUnited KingdomHUMAN_OBSERVATIONNA53.75523-2.7143NA2000.0WGS842015-01-01T00:00:00Symbol[:RECORDED_DATE_MISMATCH]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserHouse SparrowNAhttp://creativecommons.org/licenses/by-nc/4.0/legalcode
241537167824b7cd5ad0-f65a-4de1-a1bb-318cf5ae12f80ccc789d-ca07-4bb9-a1e7-a1d1b8491287GBGBUnited KingdomHUMAN_OBSERVATIONNA53.79296-2.2899NA2000.0WGS842015-01-01T00:00:00Symbol[:RECORDED_DATE_MISMATCH]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserHouse SparrowNAhttp://creativecommons.org/licenses/by-nc/4.0/legalcode
2513440908684fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION355.552743-4.631295NANAWGS842015-01-01T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr352263http://creativecommons.org/publicdomain/zero/1.0/legalcode
2613468515484fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION152.451560.044229NANAWGS842015-01-22T00:00:00Symbol[]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr399070http://creativecommons.org/publicdomain/zero/1.0/legalcode
2713472457564fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION452.085476-0.851278NANAWGS842015-01-24T00:00:00Symbol[]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr90515http://creativecommons.org/publicdomain/zero/1.0/legalcode
2813475042154fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION755.550525-4.635447NANAWGS842015-01-26T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr352263http://creativecommons.org/publicdomain/zero/1.0/legalcode
2913444309744fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATIONNA52.649729-0.649567NANAWGS842015-01-02T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr277657http://creativecommons.org/publicdomain/zero/1.0/legalcode
3013451214504fa7b334-ce0d-4e88-aaae-2e0c138d049ee2e717bf-551a-4917-bdc9-4fa0f342c530USGBUnited KingdomHUMAN_OBSERVATION355.615121-4.611008NANAWGS842015-01-07T00:00:00Symbol[:COORDINATE_ROUNDED]5231190144212729526424923215231190AnimaliaChordataAvesPasseriformesPasseridaePasserPasser domesticusSPECIESPasser domesticus (Linnaeus, 1758)PasserNAobsr352263http://creativecommons.org/publicdomain/zero/1.0/legalcode

Let's add a column for the month:

In [17]:
birbs[:month] = Dates.month.(birbs[:date]);
ERROR (unhandled task failure): InterruptException:
Stacktrace:
 [1] (::Base.##300#301{IJulia.#send_stderr,Timer})() at ./event.jl:430
In [9]:
histogram(birbs, :month,
  xticks=([1,3,5,7,9,11],["Jan","Mar","May","Jul","Sep","Nov"]),
  c=:lightgrey, lab="", ylab="Number of occurrences")
Out[9]:
Jan Mar May Jul Sep Nov 0 200 400 600 month Number of occurrences

We can now have a look at the latitude / longitude of the points:

In [16]:
scatter(birbs, :longitude, :latitude, aspectratio=1.5, marker=(:circle, :grey, 0.5), leg=false)
Out[16]:
-6 -4 -2 0 2 50 55 60 longitude latitude