Skip to content

Python for Accessing ERDDAP Data

The erddapy package leverages ERDDAP’s RESTful web services to simplify tasks such as searching for datasets, acquiring metadata, and downloading data. It automatically builds the ERDDAP URLs for your requests.

đź“– Read the full documentation: erddapy docs


Installation

pip install erddapy

Finding the Dataset ID

To query a dataset with erddapy, you need its Dataset ID. You can find IDs on the CanWIN ERDDAP dataset listing, in the last column of the table.

Example Workflow

from erddapy import ERDDAP

# Connect to CanWIN ERDDAP
e = ERDDAP(
    server="https://CanWINerddap.ad.umanitoba.ca/erddap",
    protocol="tabledap",
)

# Define response format and dataset
e.response = "csv"
e.dataset_id = "GreenEdge_Nutrient_3e39_afd6_0a1e"

# Apply constraints (time range)
e.constraints = {
    "sample_date>=": "2016-06-09T00:00:00",
    "sample_date<=": "2016-06-11T00:00:00"
}

# Select variables
e.variables = [
    "sample_date",
    "NO2_um_l",
    "NO3_um_l"
]

# Convert to pandas dataframe
df = e.to_pandas()

# Save as CSV
df.to_csv("output.csv")

What This Code Does

  • Connects to CanWIN’s ERDDAP server
  • Specifies a dataset by ID
  • Filters data by date range
  • Selects variables of interest
  • Converts results into a Pandas DataFrame
  • Saves the data locally as output.csv