dataset module

class pyobis.dataset.DatasetResponse(url, args, mapper)[source]

An OBIS Dataset Response Object

Usage

from pyobis import dataset

query = dataset.search(args, **kwargs)  # Build the Query
query.execute()  # Execute the Query
query.data  # Returns the data

# or build and execute at the same time
data = dataset.search(args, **kwargs).execute()

Methods:

pyobis.dataset.get(id, **kwargs)[source]

Get dataset by ID

Parameters:

id – [Fixnum] An OBIS dataset identifier.

Returns:

A DatasetResponse object

Usage:

from pyobis import dataset
query = dataset.get('ec9df3b9-3b2b-4d83-881b-27bcbcd57b95')
query.execute() # execute the query
query.data # returns the data of the query
query.api_url # returns the OBIS API URL
pyobis.dataset.search(scientificname=None, taxonid=None, nodeid=None, startdate=None, enddate=None, startdepth=None, enddepth=None, geometry=None, flags=None, limit=None, offset=0, **kwargs)[source]

Find dataset records.

Parameters:
  • taxonid – [Fixnum] A obis Taxon AphiaID.

  • scientificname – [String, Array] One or more scientific names from the OBIS backbone. All included and synonym taxa are included in the search.

  • year – [Fixnum] The 4 digit year. A year of 98 will be interpreted as AD 98. Supports range queries, smaller,larger (e.g., ‘1990,1991’, whereas ‘1991,1990’ wouldn’t work)

  • geometry – [String] Well Known Text (WKT). A WKT shape written as either POINT, LINESTRING, LINEARRING or POLYGON. Example of a polygon: ((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1)) would be queried as https://api.obis.org/v3/occurrence?geometry=POLYGON%28%2830.1+10.1%2C+10+20%2C+20+40%2C+40+40%2C+30.1+10.1%29%29 Geometry, formatted as WKT or GeoHash.

  • nodeid – [Fixnum] Node UUID.

  • startdate – [Fixnum] Start date

  • enddate – [Boolean] End date

  • startdepth – [Fixnum] Start depth, in meters. Depth below sea level are treated as positive numbers.

  • enddepth – [Fixnum] End depth, in meters. Depth below sea level are treated as positive numbers.

  • flags – [String, Array] Comma separated list of quality flags that need to be set

  • offset – [Fixnum] Start at record. Default: 0

Returns:

A DatasetResponse object

Usage:

from pyobis import dataset
query = dataset.search(scientificname = 'Mola mola')
data = query.execute() # or query.data

# Many names
dataset.search(
    scientificname = ['Mola', 'Abra', 'Lanice', 'Pectinaria']
).execute()

# Use paging parameters (limit and start) to page.
# Note the different results for the two queries below.
# build the query
query = dataset.search(scientificname = 'Mola mola')
query.execute() # fetch the data
query.data # return the data
dataset.search(scientificname = 'Mola mola').execute() # or simply one-easy step

# Search on a bounding box
## in well known text format
dataset.search(
    geometry='POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))'
).execute()
from pyobis import taxa
from pyobis import dataset

res = taxa.search(scientificname='Mola mola').execute().data['results'][0]
dataset.search(
    taxonid=res['id'],
    geometry='POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))',
    limit=20
).execute()
dataset.search(
    aphiaid=res['worms_id'],
    geometry='POLYGON((30.1 10.1, 10 20, 20 40, 40 40, 30.1 10.1))',
    limit=20
).execute()

# Get resources for a particular eventDate
data = dataset.search(taxonid=res['worms_id']).execute()