π 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
π 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