The goal of this post is to investigate if it is possible to query the NGDC CSW Catalog to extract records matching an IOOS RA acronym, like SECOORA for example.
In the cell above we do the usual: instantiate a Catalogue Service Web (csw
) using the NGDC catalog endpoint.
from owslib.csw import CatalogueServiceWeb
endpoint = 'http://www.ngdc.noaa.gov/geoportal/csw'
csw = CatalogueServiceWeb(endpoint, timeout=30)
We need a list of all the Regional Associations we know.
ioos_ras = ['AOOS', # Alaska
'CaRA', # Caribbean
'CeNCOOS', # Central and Northern California
'GCOOS', # Gulf of Mexico
'GLOS', # Great Lakes
'MARACOOS', # Mid-Atlantic
'NANOOS', # Pacific Northwest
'NERACOOS', # Northeast Atlantic
'PacIOOS', # Pacific Islands
'SCCOOS', # Southern California
'SECOORA'] # Southeast Atlantic
To streamline the query we can create a function that instantiate the fes
filter and returns the records.
from owslib.fes import PropertyIsEqualTo
def query_ra(csw, ra='SECOORA'):
q = PropertyIsEqualTo(propertyname='apiso:Keywords', literal=ra)
csw.getrecords2(constraints=[q], maxrecords=100, esn='full')
return csw
for ra in ioos_ras:
csw = query_ra(csw, ra)
ret = csw.results['returned']
word = 'records' if ret > 1 else 'record'
print("{0:>8} has {1:>3} {2}".format(ra, ret, word))
csw.records.clear()
I would not trust those number completely. Surely some of the RA listed above have more than 0/1 record.
Note that we have more information in the csw.records
.
Let's inspect one of SECOORA's stations for example.
csw = query_ra(csw, 'SECOORA')
key = csw.records.keys()[0]
print(key)
We can verify the station type, title, and last date of modification.
station = csw.records[key]
station.type, station.title, station.modified
The subjects
field contains the variables and some useful keywords.
station.subjects
And we can access the full XML
description for the station.
print(station.xml)
This query is very simple, but also very powerful. We can quickly assess the data available for a certain Regional Association data with just a few line of code.
You can see the original notebook here.
HTML(html)