Skip to content

Commit

Permalink
added jupyter demo
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Nov 12, 2015
1 parent 5023b5b commit 18d5b34
Showing 1 changed file with 311 additions and 0 deletions.
311 changes: 311 additions & 0 deletions demos/pygbif-intro.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Install\n",
"pip install pygbif"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Registry/datasets\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{u'colCoveragePct': 79,\n",
" u'colMatchingCount': 24335,\n",
" u'countByConstituent': {},\n",
" u'countByIssue': {u'BACKBONE_MATCH_FUZZY': 573,\n",
" u'BACKBONE_MATCH_NONE': 1306,\n",
" u'VERNACULAR_NAME_INVALID': 7777},\n",
" u'countByKingdom': {u'ANIMALIA': 30,\n",
" u'FUNGI': 3,\n",
" u'INCERTAE_SEDIS': 26,\n",
" u'PLANTAE': 10997,\n",
" u'PROTOZOA': 1},\n",
" u'countByOrigin': {u'DENORMED_CLASSIFICATION': 2010,\n",
" u'PROPARTE': 11,\n",
" u'SOURCE': 28775},\n",
" u'countByRank': {u'CLASS': 1,\n",
" u'FAMILY': 172,\n",
" u'GENUS': 3255,\n",
" u'ORDER': 55,\n",
" u'SECTION': 323,\n",
" u'SERIES': 40,\n",
" u'SPECIES': 6046,\n",
" u'SUBCLASS': 6,\n",
" u'SUBFAMILY': 150,\n",
" u'SUBGENUS': 99,\n",
" u'SUBSECTION': 56,\n",
" u'SUBSPECIES': 742,\n",
" u'SUBTRIBE': 61,\n",
" u'SUPERORDER': 12,\n",
" u'TRIBE': 328,\n",
" u'VARIETY': 863},\n",
" u'countExtRecordsByExtension': {u'DESCRIPTION': 10176,\n",
" u'DISTRIBUTION': 29037,\n",
" u'IDENTIFIER': 0,\n",
" u'MULTIMEDIA': 0,\n",
" u'REFERENCE': 0,\n",
" u'SPECIES_PROFILE': 0,\n",
" u'TYPES_AND_SPECIMEN': 0,\n",
" u'VERNACULAR_NAME': 32143},\n",
" u'countNamesByLanguage': {u'ENGLISH': 20864, u'FRENCH': 11279},\n",
" u'created': u'2015-08-19T16:44:57.166+0000',\n",
" u'datasetKey': u'3f8a1297-3259-4700-91fc-acc4170b27ce',\n",
" u'distinctNamesCount': 30776,\n",
" u'downloaded': u'2015-08-19T16:04:50.099+0000',\n",
" u'key': 1481,\n",
" u'nubCoveragePct': 95,\n",
" u'nubMatchingCount': 29490,\n",
" u'otherCount': {},\n",
" u'synonymsCount': 18587,\n",
" u'usagesCount': 30796}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from pygbif import registry\n",
"registry.dataset_metrics(uuid='3f8a1297-3259-4700-91fc-acc4170b27ce')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Taxonomic names"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'data': [{u'canonicalName': u'Puma concolor',\n",
" u'class': u'Mammalia',\n",
" u'classKey': 359,\n",
" u'family': u'Felidae',\n",
" u'familyKey': 9703,\n",
" u'genus': u'Puma',\n",
" u'genusKey': 2435098,\n",
" u'key': 2435099,\n",
" u'kingdom': u'Animalia',\n",
" u'kingdomKey': 1,\n",
" u'nubKey': 2435099,\n",
" u'order': u'Carnivora',\n",
" u'orderKey': 732,\n",
" u'parent': u'Puma',\n",
" u'parentKey': 2435098,\n",
" u'phylum': u'Chordata',\n",
" u'phylumKey': 44,\n",
" u'rank': u'SPECIES',\n",
" u'species': u'Puma concolor',\n",
" u'speciesKey': 2435099}],\n",
" 'hierarchy': [{u'1': u'Animalia',\n",
" u'2435098': u'Puma',\n",
" u'359': u'Mammalia',\n",
" u'44': u'Chordata',\n",
" u'732': u'Carnivora',\n",
" u'9703': u'Felidae'}]}"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from pygbif import species\n",
"species.name_suggest(q='Puma concolor', limit = 1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Occurrence data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"__Search__"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"[u'Basidiomycota',\n",
" u'Basidiomycota',\n",
" u'Basidiomycota',\n",
" u'Basidiomycota',\n",
" u'Basidiomycota',\n",
" u'Basidiomycota',\n",
" u'Basidiomycota',\n",
" u'Basidiomycota',\n",
" u'Basidiomycota',\n",
" u'Basidiomycota']"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from pygbif import occurrences\n",
"res = occurrences.search(taxonKey = 3329049, limit = 10)\n",
"[ x['phylum'] for x in res['results'] ]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"__Fetch specific occurrences__"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"{u'basisOfRecord': u'OBSERVATION',\n",
" u'catalogNumber': u'70875196',\n",
" u'collectionCode': u'7472',\n",
" u'continent': u'EUROPE',\n",
" u'country': u'United Kingdom',\n",
" u'countryCode': u'GB',\n",
" u'datasetKey': u'26a49731-9457-45b2-9105-1b96063deb26',\n",
" u'day': 30,\n",
" u'decimalLatitude': 52.51021,\n",
" u'decimalLongitude': -1.0193,\n",
" u'eventDate': u'2006-06-29T22:00:00.000+0000',\n",
" u'extensions': {},\n",
" u'facts': [],\n",
" u'gbifID': u'252408386',\n",
" u'geodeticDatum': u'WGS84',\n",
" u'identifiedBy': u'DA Lott',\n",
" u'identifiers': [],\n",
" u'institutionCode': u'Leicestershire and Rutland Environmental Records Centre',\n",
" u'issues': [u'COORDINATE_ROUNDED',\n",
" u'GEODETIC_DATUM_ASSUMED_WGS84',\n",
" u'TAXON_MATCH_NONE'],\n",
" u'key': 252408386,\n",
" u'lastCrawled': u'2013-09-07T07:08:17.000+0000',\n",
" u'lastInterpreted': u'2014-06-05T03:33:35.082+0000',\n",
" u'locality': u'Saddington Reservoir, Saddington Reservoir',\n",
" u'month': 6,\n",
" u'protocol': u'DWC_ARCHIVE',\n",
" u'publishingCountry': u'GB',\n",
" u'publishingOrgKey': u'07f617d0-c688-11d8-bf62-b8a03c50a862',\n",
" u'recordedBy': u'DA Lott',\n",
" u'relations': [],\n",
" u'year': 2006}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"occurrences.get(key = 252408386)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"__Occurrence counts API__"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"500283031"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"occurrences.count(isGeoreferenced = True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit 18d5b34

Please sign in to comment.