Accessing THREDDS Data

What is THREDDS and OPeNDAP?

OPeNDAP is a network protocol that is widely used in the Earth Science community to subset and access NetCDF data over the Internet. SeaView uses a THREDDS server to distribute content from its collections using the OPeNDAP protocol.

One of the big advantages to accessing data through the THREDDS server is the sophisticated sub sampling capabilities of OPeNDAP. This is important when trying to navigate large, diverse collections like the ones that SeaView assembles. Another advantage to using the this method is the number of environments that support access to data through OPeNDAP. Here we briefly demonstrate accessing data through ODV, Matlab, Python, and R. A more complete list of client support can be found here. The THREDDS server allows users to browse what data are available and access the portions of the collections they are interested in on the platform of their choice.

More information about THREDDS can be found on the UCAR website. Questions and feedback for the SeaView team are encouraged and can be made through our Contact Page.

Resources for MATLAB Users

MATLAB provides built in netCDF support as of version R2011a. This includes basic access to netCDF data through OPeNDAP. Below is an example of how to investigate the metadata of the Pioneer collection and load the lat, lon, time, and temperature variables.

% Pull in the netCDF data from the follwing url
url = '';

% Load all the metadata into the variable 'metadata'
metadata = ncinfo(url);

% Variable names aren't always meaningful - display the
% associated long names and units
names = {metadata.Variables.Name};
attributes = {metadata.Variables.Attributes};
long_names = cellfun(@(x) x(1).Value, attributes, 'UniformOutput', false);
units = cellfun(@(x) char(double(strcmp(x(2).Name, 'units'))*x(2).Value), attributes, 'UniformOutput', false);   
to_display = [names; long_names; units];
fprintf('%s\t%s\t%s\n', to_display{:});

% Load specific variables
% Variable names and dimensions can be found in metadata
latitude = ncread(url, 'latitude');
longitude = ncread(url, 'longitude');
date_time = ncread(url, 'date_time');
depth = ncread(url, 'metavar9'); % Variable with long name 'Bot. Depth'

Other resources for MATLAB users:

  • Statistical analysis with MATLAB
  • Code examples for geospatial mapping with MATLAB

    Resources for python Users

    Python users can interact with the THREDDS server using the PyDAP library. Pydap is easily installed through pip or Anaconda. Below is a basic example of how to look at the metadata of the Pioneer collection as well as load the time, lat, lon, and temperature variables into python arrays.

    #!/usr/bin/env python
    # Install the pydap libraries
    # $ pip install pydap 
    from pydap.client import open_url
    url = ''
    # Get a list of variables in the collection
    # Variable names aren't always meaningful - get
    # associated 'long_name' and 'units'
    for var in dataset:
        long_name = var.attributes['long_name']
        # Variable may not have units, eg 'Cruise'
        if ('units' in var.attributes):
            units = var.attributes['units']
            print( + "\t" + long_name + "\t" + units)
            print( + "\t" + long_name)
    # Grab variables of interest
    time = dataset['date_time'][:]
    latitude = dataset['latitude'][:]
    longitude = dataset['longitude'][:]
    temp = dataset['var24'][:]  # Variable associated with 'Temperature'


    Resources for R Users

    R users can interact with the THREDDS server using the ncdf4 library. Below is a basic example of how to look at the metadata of the Pioneer collection as well as load the variable associated with temperature in the collection.

    # Install the required packages:
    # To install ncdf for linux, use the command: install.packages("ncdf4")
    # To install ncdf for Windows, you need to install a precompiled version by:
    # Menu->Packages->Install Package(s) from local zip files and select
    # Load the packages:
    # Load collection into data handle
    data <- nc_open("")
    # Look at the header column information
    # Grab temperature, for example
    temp <- ncvar_get(data, "var24")
    # Close the handle when you are done


    Resources for ODV Users

    ODV users can download ODV collections on the download pages. In addition to the data, collections have styling and processing information within them. Users can also access data from these ODV collections directly from the THREDDS server from within ODV. To do this, navigate to the SeaView THREDDS Server and select a collection in which to explore. At the top of each collection landing page is a url to the data.

    Within ODV remote collections can be accessed through this url. Navigate to File > Open Remote and insert this url into the text box that appears.

    Select 'Okay' and follow any steps to confirm variables to be imported.