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.

Look in the last column of the table for the Dataset ID.

πŸ“ 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