Skip to main content

py-seaaroundus

PyPI version Python versions

Python wrapper for the Sea Around Us API, inspired by the R rseaaroundus package. Install as py-seaaroundus; import as seaaroundus.

Install from PyPI:

pip install py-seaaroundus

Optional extras:

pip install "py-seaaroundus[plot]"     # matplotlib stacked-area charts
pip install "py-seaaroundus[maps]"     # geopandas region maps
pip install "py-seaaroundus[notebook]" # ipykernel for notebooks
pip install "py-seaaroundus[all]"      # plot, maps, and dev tools

The Sea Around Us data are licensed to the public under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License. Please read the data use policy in DATA_USE.

Quick start

import seaaroundus as sau

# List exclusive economic zones
eezs = sau.list_regions("eez")

# Catch data for Brazil (EEZ id 76) as a wide year-by-species table
catch = sau.catch_data("eez", 76)

# Top 3 taxa only
catch_top3 = sau.catch_data("eez", 76, limit=3)

# Value by reporting status
value = sau.catch_data("eez", 76, measure="value", dimension="reporting-status")

# Long/tidy format (useful for ggplot-style workflows)
long = sau.catch_data_long("eez", 76, dimension="functionalgroup")

# Catch-data reliability / uncertainty scores (1 = least, 4 = most reliable)
scores = sau.reliability_score("eez", 76)

# Marine trophic index (deprecated: endpoint currently returns HTTP 500)
mti = sau.marine_trophic_index("eez", 76)
fib = sau.marine_trophic_index("eez", 76, mti_type="fib_index", transfer_efficiency=0.25)

# Global EEZ vs. high-seas percentages (deprecated: endpoint currently unavailable)
global_split = sau.eez_vs_high_seas()

# Spatial cell queries (deprecated: endpoints currently return HTTP 403)
cells = sau.get_cells(
    "POLYGON ((-48.17 15.84, -54.96 28.96, -35.96 27.60, -48.17 15.84))"
)
cell_catch = sau.get_cell_data(cells, year=2005)

Plotting and maps

import seaaroundus as sau

fig, ax = sau.plot_catch_data("eez", 76, measure="tonnage", dimension="taxon")
fig, ax = sau.plot_mti("eez", 76)
fig, ax = sau.region_map("eez", 76)

Batch downloads for multiple countries

import pandas as pd
import seaaroundus as sau

countries = pd.DataFrame(
    {
        "iso_a3": ["BRA", "IDN"],
        "country": ["Brazil", "Indonesia"],
    }
)

totals = sau.download_country_fisheries_timeseries(
    countries,
    years=10,
    measure="value",
    show_progress=True,
)

breakdown = sau.download_country_fisheries_breakdown(
    countries,
    dimension="functionalgroup",
    measure="value",
)

API reference

Python R equivalent Description
list_regions(region) listregions() List region IDs and titles
list_fishing_entities() List fishing countries/territories
catch_data(...) catchdata() Wide catch table (years × categories)
catch_data_long(...) Long/tidy catch table
reliability_score(...) Catch-data reliability / uncertainty scores (1–4)
region_map(region, id=...) regionmap() Region map (requires [maps])
plot_catch_data(...) catchdata(..., chart=TRUE) Stacked area chart (with reliability strip)
marine_trophic_index(...) marinetrophicindex() Deprecated: endpoint currently returns HTTP 500
eez_vs_high_seas() eezsvshighseas() Deprecated: endpoint currently times out/unavailable
get_cells(shape) getcells() Deprecated: endpoint currently returns HTTP 403
get_cell_data(cells, year=...) getcelldata() Deprecated: endpoint currently returns HTTP 403
plot_mti(...) marinetrophicindex(..., chart=TRUE) Deprecated: depends on deprecated MTI endpoint
plot_eez_vs_high_seas() eezsvshighseas(chart=TRUE) Deprecated: depends on unavailable endpoint

Regions

  • eez
  • lme
  • rfmo
  • eez-bordering
  • taxon
  • fishing-entity

Measures

  • tonnage — reconstructed catch in metric tonnes
  • value — real 2019 million US dollars

Dimensions

  • taxon (not available for the taxon region type)
  • commercialgroup
  • functionalgroup
  • country (fishing country)
  • gear
  • enduse
  • sector
  • catchtype
  • reporting-status
  • layer
  • eez (only for eez-bordering and taxon regions)
  • highseas — not currently usable (404 for EEZ; empty for taxon)

Reconstructed catch is currently available through 2019.

Endpoint availability notes

The Sea Around Us public API is upstream and may change without notice. As of the latest probe in this repository:

  • /api/v1/eez/marine-trophic-index/ returns HTTP 500
  • /api/v1/global/eez-vs-high-seas/ is timing out
  • /api/v1/eez/tonnage/highseas/ returns HTTP 404
  • /api/v1/spatial/r/shape returns HTTP 403
  • /api/v1/spatial/r/cells returns HTTP 403

Related wrapper functions are marked deprecated in code and README until (and if) these endpoints are restored.

Custom client

from seaaroundus import SeaAroundUsClient, catch_data

client = SeaAroundUsClient(
    base_url="http://api.seaaroundus.org/api/v1",
    request_source="my-research-project",
    timeout=60,
)
catch = catch_data("eez", 76, client=client)

Usage note

When querying the API, please be respectful of the resources required to provide this data. Cache results locally (handled by the repository's default behaviour) and avoid repeated requests for duplicate information.

Development

Clone the repository and install in editable mode:

git clone https://github.com/orlando-code/py-seaaroundus.git
cd py-seaaroundus
pip install -e ".[dev]"
pre-commit install   # run ruff + pytest on each commit
pytest               # run tests manually

CI runs the same checks on push and pull requests via GitHub Actions.

License

See LICENSE for more information.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_seaaroundus-1.1.0.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_seaaroundus-1.1.0-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file py_seaaroundus-1.1.0.tar.gz.

File metadata

  • Download URL: py_seaaroundus-1.1.0.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for py_seaaroundus-1.1.0.tar.gz
Algorithm Hash digest
SHA256 ed9214c89ddb53298d656f94002e3b024094ea736a81d338f973386fd260e0e5
MD5 fd8b3f8cf8667a7e998fc5cc96a6c92f
BLAKE2b-256 c8dff02cd497c6b148bf1d467ff1aae921a663ac6954e23aa2c5987c72dac8f0

See more details on using hashes here.

File details

Details for the file py_seaaroundus-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_seaaroundus-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for py_seaaroundus-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fc0a08ebd209b814106bf59107cbe8237ee7e66bd63a12b4a50910f1f01d769
MD5 bc08338b2d3c9fb9de3b279b5e8ded86
BLAKE2b-256 3d4b27607abd1be8d3cf941f0aa099adf62b597ad2696e02dad6b4f1fc88a694

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.2

2 files

1.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page