Use CSW to find model data at NODC, NGDC, DATA.GOV, and PACIOOS


In [1]:
from owslib.csw import CatalogueServiceWeb
from owslib import fes
import netCDF4
import numpy as np

Find model results at NODC (geoportal)


In [2]:
endpoint = 'http://www.nodc.noaa.gov/geoportal/csw'   # NODC/UAF Geoportal: granule level
csw = CatalogueServiceWeb(endpoint,timeout=60)
print csw.version


2.0.2

In [3]:
csw.get_operation_by_name('GetRecords').constraints


Out[3]:
[Constraint: SupportedCommonQueryables - ['Subject', 'Title', 'Abstract', 'AnyText', 'Format', 'Identifier', 'Modified', 'Type', 'BoundingBox'],
 Constraint: SupportedISOQueryables - ['apiso:Subject', 'apiso:Title', 'apiso:Abstract', 'apiso:AnyText', 'apiso:Format', 'apiso:Identifier', 'apiso:Modified', 'apiso:Type', 'apiso:BoundingBox', 'apiso:CRS.Authority', 'apiso:CRS.ID', 'apiso:CRS.Version', 'apiso:RevisionDate', 'apiso:AlternateTitle', 'apiso:CreationDate', 'apiso:PublicationDate', 'apiso:OrganizationName', 'apiso:HasSecurityConstraints', 'apiso:Language', 'apiso:ResourceIdentifier', 'apiso:ParentIdentifier', 'apiso:KeywordType', 'apiso:TopicCategory', 'apiso:ResourceLanguage', 'apiso:GeographicDescriptionCode', 'apiso:Denominator', 'apiso:DistanceValue', 'apiso:DistanceUOM', 'apiso:TempExtent_begin', 'apiso:TempExtent_end', 'apiso:ServiceType', 'apiso:ServiceTypeVersion', 'apiso:Operation', 'apiso:OperatesOn', 'apiso:OperatesOnIdentifier', 'apiso:OperatesOnName', 'apiso:CouplingType'],
 Constraint: AdditionalQueryables - ['apiso:Degree', 'apiso:AccessConstraints', 'apiso:OtherConstraints', 'apiso:Classification', 'apiso:ConditionApplyingToAccessAndUse', 'apiso:Lineage', 'apiso:ResponsiblePartyRole', 'apiso:SpecificationTitle', 'apiso:SpecificationDate', 'apiso:SpecificationDateType']]

In [4]:
val = 'level'
filter1 = fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ filter1 ]

In [5]:
csw.getrecords2(constraints=filter_list,maxrecords=100,esn='full')
len(csw.records.keys())


Out[5]:
100

In [6]:
choice=np.random.choice(list(csw.records.keys()))
print(csw.records[choice].title)
csw.records[choice].references


SAMOS project underway oceanographic and quality-controlled meteorological data collected aboard the MILLER FREEMAN from 2008-02-01 to 2008-02-29 (NODC Accession 0044755)
Out[6]:
[{'scheme': 'urn:x-esri:specification:ServiceType:ArcIMS:Metadata:Onlink',
  'url': 'http://www.ncei.noaa.gov/'},
 {'scheme': 'urn:x-esri:specification:ServiceType:ArcIMS:Metadata:Onlink',
  'url': 'http://www.nodc.noaa.gov/'},
 {'scheme': 'urn:x-esri:specification:ServiceType:ArcIMS:Metadata:Onlink',
  'url': 'http://www.coaps.fsu.edu/'},
 {'scheme': 'urn:x-esri:specification:ServiceType:ArcIMS:Metadata:Onlink',
  'url': 'http://www.coaps.fsu.edu/'},
 {'scheme': 'urn:x-esri:specification:ServiceType:ArcIMS:Metadata:Thumbnail',
  'url': 'http://data.nodc.noaa.gov/cgi-bin/gfx?id=gov.noaa.nodc:0044755'},
 {'scheme': 'urn:x-esri:specification:ServiceType:ArcIMS:Metadata:Document',
  'url': 'http://www.nodc.noaa.gov/geoportal/csw?getxml=%7B3F0C3B7C-CCD5-48CF-A6EB-E68A21E3228B%7D'},
 {'scheme': 'urn:x-esri:specification:ServiceType:TDS',
  'url': 'http://data.nodc.noaa.gov/thredds/catalog/coaps/samos/WTDM/2008/02/'},
 {'scheme': 'urn:x-esri:specification:ServiceType:FTP',
  'url': 'ftp://ftp.nodc.noaa.gov/nodc/archive/arc0022/0044755/'},
 {'scheme': 'urn:x-esri:specification:ServiceType:OPeNDAP',
  'url': 'http://data.nodc.noaa.gov/opendap/coaps/samos/WTDM/2008/02/'},
 {'scheme': 'urn:x-esri:specification:ServiceType:Download',
  'url': 'http://data.nodc.noaa.gov/coaps/samos/WTDM/2008/02/'},
 {'scheme': 'urn:x-esri:specification:ServiceType:Download',
  'url': 'http://accession.nodc.noaa.gov/download/44755'}]

Find model results at NGDC (geoportal)


In [161]:
endpoint = 'http://www.ngdc.noaa.gov/geoportal/csw' #  NGDC/IOOS Geoportal
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version


Out[161]:
'2.0.2'

In [162]:
csw.get_operation_by_name('GetRecords').constraints


Out[162]:
[Constraint: SupportedCommonQueryables - ['Subject', 'Title', 'Abstract', 'AnyText', 'Format', 'Identifier', 'Modified', 'Type', 'BoundingBox'],
 Constraint: SupportedISOQueryables - ['apiso:Subject', 'apiso:Title', 'apiso:Abstract', 'apiso:AnyText', 'apiso:Format', 'apiso:Identifier', 'apiso:Modified', 'apiso:Type', 'apiso:BoundingBox', 'apiso:CRS.Authority', 'apiso:CRS.ID', 'apiso:CRS.Version', 'apiso:RevisionDate', 'apiso:AlternateTitle', 'apiso:CreationDate', 'apiso:PublicationDate', 'apiso:OrganizationName', 'apiso:HasSecurityConstraints', 'apiso:Language', 'apiso:ResourceIdentifier', 'apiso:ParentIdentifier', 'apiso:KeywordType', 'apiso:TopicCategory', 'apiso:ResourceLanguage', 'apiso:GeographicDescriptionCode', 'apiso:Denominator', 'apiso:DistanceValue', 'apiso:DistanceUOM', 'apiso:TempExtent_begin', 'apiso:TempExtent_end', 'apiso:ServiceType', 'apiso:ServiceTypeVersion', 'apiso:Operation', 'apiso:OperatesOn', 'apiso:OperatesOnIdentifier', 'apiso:OperatesOnName', 'apiso:CouplingType'],
 Constraint: AdditionalQueryables - ['apiso:Degree', 'apiso:AccessConstraints', 'apiso:OtherConstraints', 'apiso:Classification', 'apiso:ConditionApplyingToAccessAndUse', 'apiso:Lineage', 'apiso:ResponsiblePartyRole', 'apiso:ResponsiblePartyName', 'apiso:SpecificationTitle', 'apiso:SpecificationDate', 'apiso:SpecificationDateType']]

In [163]:
try:
    csw.get_operation_by_name('GetDomain')
    csw.getdomain('apiso:ServiceType', 'property')
    print(csw.results['values'])
except:
    print('GetDomain not supported')


GetDomain not supported

In [164]:
val = 'level'
filter1 = fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ filter1 ]

In [165]:
val = 'erddap'
filter1 = fes.PropertyIsLike(propertyname='apiso:ServiceType',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ filter1 ]

In [166]:
csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
len(csw.records.keys())


Out[166]:
104

In [167]:
choice=np.random.choice(list(csw.records.keys()))
print choice
csw.records[choice].references


I01_met_all
Out[167]:
[{'scheme': 'urn:x-esri:specification:ServiceType:distribution:url',
  'url': 'http://www.neracoos.org/erddap/tabledap/I01_met_all.html'},
 {'scheme': 'urn:x-esri:specification:ServiceType:distribution:url',
  'url': 'http://www.neracoos.org/erddap/tabledap/I01_met_all.graph'},
 {'scheme': 'urn:x-esri:specification:ServiceType:download:url',
  'url': 'http://www.neracoos.org/erddap/tabledap/I01_met_all.html'}]

Find model data at CATALOG.DATA.GOV (pycsw)


In [56]:
endpoint = 'http://catalog.data.gov/csw-all' #  catalog.data.gov CSW
#endpoint = 'http://csw.data.gov.uk/geonetwork/srv/en/csw' # data.gov.uk
#endpoint = 'http://www.nationaalgeoregister.nl/geonetwork/srv/eng/csw'
#endpoint = 'http://www.rndt.gov.it/RNDT/CSW'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version


Out[56]:
'2.0.2'

In [57]:
for oper in csw.operations:
    print(oper.name)


GetCapabilities
GetRepositoryItem
DescribeRecord
GetDomain
GetRecordById
GetRecords

In [58]:
csw.get_operation_by_name('GetRecords').constraints


Out[58]:
[Constraint: SupportedISOQueryables - ['apiso:DistanceValue', 'apiso:Abstract', 'apiso:RevisionDate', 'apiso:Subject', 'apiso:KeywordType', 'apiso:Title', 'apiso:CRS', 'apiso:PublicationDate', 'apiso:Type', 'apiso:AlternateTitle', 'apiso:BoundingBox', 'apiso:AnyText', 'apiso:ParentIdentifier', 'apiso:Modified', 'apiso:Operation', 'apiso:Format', 'apiso:TempExtent_end', 'apiso:DistanceUOM', 'apiso:OrganisationName', 'apiso:ServiceType', 'apiso:TempExtent_begin', 'apiso:ResourceLanguage', 'apiso:ServiceTypeVersion', 'apiso:OperatesOn', 'apiso:Denominator', 'apiso:HasSecurityConstraints', 'apiso:OperatesOnIdentifier', 'apiso:GeographicDescriptionCode', 'apiso:Language', 'apiso:Identifier', 'apiso:OperatesOnName', 'apiso:TopicCategory', 'apiso:CreationDate', 'apiso:CouplingType'],
 Constraint: AdditionalQueryables - ['apiso:Lineage', 'apiso:Classification', 'apiso:Creator', 'apiso:Relation', 'apiso:OtherConstraints', 'apiso:SpecificationTitle', 'apiso:ResponsiblePartyRole', 'apiso:SpecificationDateType', 'apiso:Degree', 'apiso:Contributor', 'apiso:ConditionApplyingToAccessAndUse', 'apiso:SpecificationDate', 'apiso:AccessConstraints', 'apiso:Publisher'],
 Constraint: SupportedDublinCoreQueryables - ['dc:contributor', 'dc:source', 'dc:language', 'dc:title', 'dc:subject', 'dc:creator', 'dc:type', 'ows:BoundingBox', 'dct:modified', 'dct:abstract', 'dc:relation', 'dc:date', 'dc:identifier', 'dc:publisher', 'dc:format', 'csw:AnyText', 'dc:rights']]

In [59]:
try:
    csw.get_operation_by_name('GetDomain')
    csw.getdomain('apiso:ServiceType', 'property')
    print(csw.results['values'])
except:
    print('GetDomain not supported')


['ArcGIS REST API for 10', 'urn:ogc:serviceType:WebMapService']

In [60]:
val = 'salinity'
filter1 = fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ filter1 ]

In [61]:
csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
len(csw.records.keys())


Out[61]:
10

In [ ]:
csw.getrecords2()

In [51]:
choice=np.random.choice(list(csw.records.keys()))
print csw.records[choice].title
csw.records[choice].references


USGS US Topo 7.5-minute map for Lindstrom Peak, ID 2011
Out[51]:
[{'scheme': 'None',
  'url': 'http://ims.er.usgs.gov/gda_services/download?item_id=5243915'}]

Search at geoport.whoi.edu (geoportal)


In [ ]:
endpoint = 'http://geoport.whoi.edu/geoportal/csw' #  catalog.data.gov CSW
csw = CatalogueServiceWeb(endpoint,timeout=60)
print csw.version

In [ ]:
for oper in csw.operations:
    if oper.name == 'GetRecords':
        print '\nISO Queryables:\n',oper.constraints['SupportedISOQueryables']['values']

In [ ]:
csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
len(csw.records.keys())

In [ ]:
choice=random.choice(list(csw.records.keys()))
print choice
csw.records[choice].references

Search at PACIOOS (pycsw)


In [175]:
endpoint='http://oos.soest.hawaii.edu/pacioos/ogc/csw.py'

In [176]:
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version


Out[176]:
'2.0.2'

In [177]:
csw.get_operation_by_name('GetRecords').constraints


Out[177]:
[Constraint: SupportedISOQueryables - ['apiso:DistanceValue', 'apiso:Abstract', 'apiso:RevisionDate', 'apiso:Subject', 'apiso:KeywordType', 'apiso:Title', 'apiso:CRS', 'apiso:PublicationDate', 'apiso:Type', 'apiso:AlternateTitle', 'apiso:BoundingBox', 'apiso:AnyText', 'apiso:ParentIdentifier', 'apiso:Modified', 'apiso:Operation', 'apiso:Format', 'apiso:TempExtent_end', 'apiso:DistanceUOM', 'apiso:OrganisationName', 'apiso:ServiceType', 'apiso:TempExtent_begin', 'apiso:ResourceLanguage', 'apiso:ServiceTypeVersion', 'apiso:OperatesOn', 'apiso:Denominator', 'apiso:HasSecurityConstraints', 'apiso:OperatesOnIdentifier', 'apiso:GeographicDescriptionCode', 'apiso:Language', 'apiso:Identifier', 'apiso:OperatesOnName', 'apiso:TopicCategory', 'apiso:CreationDate', 'apiso:CouplingType'],
 Constraint: AdditionalQueryables - ['apiso:Lineage', 'apiso:Classification', 'apiso:Creator', 'apiso:Relation', 'apiso:OtherConstraints', 'apiso:SpecificationTitle', 'apiso:ResponsiblePartyRole', 'apiso:SpecificationDateType', 'apiso:Degree', 'apiso:Contributor', 'apiso:ConditionApplyingToAccessAndUse', 'apiso:SpecificationDate', 'apiso:AccessConstraints', 'apiso:Publisher'],
 Constraint: SupportedDublinCoreQueryables - ['dc:contributor', 'dc:source', 'dc:language', 'dc:title', 'dc:subject', 'dc:creator', 'dc:type', 'ows:BoundingBox', 'dct:modified', 'dct:abstract', 'dc:relation', 'dc:date', 'dc:identifier', 'dc:publisher', 'dc:format', 'csw:AnyText', 'dc:rights']]

In [178]:
try:
    csw.get_operation_by_name('GetDomain')
    csw.getdomain('apiso:ServiceType', 'property')
    print(csw.results['values'])
except:
    print('GetDomain not supported')


GetDomain not supported

In [179]:
val = 'ROMS'
filter1 = fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ filter1 ]

In [180]:
csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
len(csw.records.keys())


---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-180-308c0d86ab3e> in <module>()
----> 1 csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
      2 len(csw.records.keys())

/home/usgs/anaconda/lib/python2.7/site-packages/OWSLib-0.8.9-py2.7.egg/owslib/csw.pyc in getrecords2(self, constraints, sortby, typenames, esn, outputschema, format, startposition, maxrecords, cql, xml, resulttype)
    348             self.request = node0
    349 
--> 350         self._invoke()
    351 
    352         if self.exceptionreport is None:

/home/usgs/anaconda/lib/python2.7/site-packages/OWSLib-0.8.9-py2.7.egg/owslib/csw.pyc in _invoke(self)
    627             self.request = util.element_to_string(self.request, encoding='utf-8')
    628 
--> 629             self.response = util.http_post(xml_post_url, self.request, self.lang, self.timeout, self.username, self.password)
    630 
    631         # parse result see if it's XML

/home/usgs/anaconda/lib/python2.7/site-packages/OWSLib-0.8.9-py2.7.egg/owslib/util.pyc in http_post(url, request, lang, timeout, username, password)
    370             r.add_header('Authorization', 'Basic %s' % base64string)
    371         try:
--> 372             up = urllib2.urlopen(r,timeout=timeout);
    373         except TypeError:
    374             import socket

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in urlopen(url, data, timeout)
    125     if _opener is None:
    126         _opener = build_opener()
--> 127     return _opener.open(url, data, timeout)
    128 
    129 def install_opener(opener):

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in open(self, fullurl, data, timeout)
    408         for processor in self.process_response.get(protocol, []):
    409             meth = getattr(processor, meth_name)
--> 410             response = meth(req, response)
    411 
    412         return response

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in http_response(self, request, response)
    521         if not (200 <= code < 300):
    522             response = self.parent.error(
--> 523                 'http', request, response, code, msg, hdrs)
    524 
    525         return response

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in error(self, proto, *args)
    446         if http_err:
    447             args = (dict, 'default', 'http_error_default') + orig_args
--> 448             return self._call_chain(*args)
    449 
    450 # XXX probably also want an abstract factory that knows when it makes

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
    380             func = getattr(handler, meth_name)
    381 
--> 382             result = func(*args)
    383             if result is not None:
    384                 return result

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in http_error_default(self, req, fp, code, msg, hdrs)
    529 class HTTPDefaultErrorHandler(BaseHandler):
    530     def http_error_default(self, req, fp, code, msg, hdrs):
--> 531         raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    532 
    533 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found

In [181]:
choice=np.random.choice(list(csw.records.keys()))
print choice
csw.records[choice].references


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-181-9bd2ae93b2c7> in <module>()
----> 1 choice=np.random.choice(list(csw.records.keys()))
      2 print choice
      3 csw.records[choice].references

AttributeError: CatalogueServiceWeb instance has no attribute 'records'

Working! Woo hoo!!!

EPA


In [ ]:
endpoint = 'https://edg.epa.gov/metadata/csw'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version

In [ ]:
# trying to do this search:
# ('roms' OR 'selfe' OR 'adcirc' OR 'ncom' OR 'hycom' OR 'fvcom') AND 'ocean' NOT 'regridded' NOT 'espresso'
# should return 11 records from NODC geoportal

search_text = ['waves','selfe','adcirc','ncom','hycom','fvcom']
filt=[]
for val in search_text:
    filt.append(fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                                   escapeChar='\\',wildCard='*',singleChar='?'))
filter1=fes.Or(filt)

val = 'ocean'
filter2=fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')

val = 'regridded'
filt=fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter3 = fes.Not([filt])

val = 'espresso'
filt=fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter4 = fes.Not([filt])


filter_list = [fes.And([filter1, filter2, filter3, filter4])]

In [ ]:
csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
len(csw.records.keys())

In [ ]:
choice=random.choice(list(csw.records.keys()))
print choice
csw.records[choice].references

In [ ]:
try:
    csw.get_operation_by_name('GetDomain')
    csw.getdomain('apiso:SupportedISOQueryables', 'apiso:ServiceType')
    print(csw.results['values'])
except:
    print('GetDomain not supported')

USGS CGDMS server (geonetwork)


In [ ]:
endpoint = 'http://cmgds.marine.usgs.gov/geonetwork/srv/en/csw'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version

USGS CIDA Server (geonetwork)


In [ ]:
endpoint = 'http://cida.usgs.gov/gdp/geonetwork/srv/en/csw'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version

In [ ]:
foo=csw.get_operation_by_name('GetRecords')
foo.constraints

In [ ]:
try:
    csw.get_operation_by_name('GetDomain')
    csw.getdomain('SupportedISOQueryables', 'ServiceType')
    print(csw.results['values'])
except:
    print('GetDomain not supported')

In [ ]:
val = 'dap'
service_type = fes.PropertyIsLike(propertyname='ServiceType',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ service_type]

In [ ]:
csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
len(csw.records.keys())

In [ ]:
val = 'climate'
filter1 = fes.PropertyIsLike(propertyname='AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ filter1 ]

In [ ]:
csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
len(csw.records.keys())

In [ ]:
choice=random.choice(list(csw.records.keys()))
print choice
csw.records[choice].references

INSPIRE


In [63]:
endpoint ='http://inspire-geoportal.ec.europa.eu/GeoportalProxyWebServices/resources/OGCCSW202/AT'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version


---------------------------------------------------------------------------
timeout                                   Traceback (most recent call last)
<ipython-input-63-d234a92397ce> in <module>()
      1 endpoint ='http://inspire-geoportal.ec.europa.eu/GeoportalProxyWebServices/resources/OGCCSW202/AT'
----> 2 csw = CatalogueServiceWeb(endpoint,timeout=60)
      3 csw.version

/home/usgs/anaconda/lib/python2.7/site-packages/OWSLib-0.8.9-py2.7.egg/owslib/csw.pyc in __init__(self, url, lang, version, timeout, skip_caps, username, password)
     77             self.request = '%s%s' % (bind_url(self.url), urlencode(data))
     78 
---> 79             self._invoke()
     80 
     81             if self.exceptionreport is None:

/home/usgs/anaconda/lib/python2.7/site-packages/OWSLib-0.8.9-py2.7.egg/owslib/csw.pyc in _invoke(self)
    595                 base64string = base64.encodestring('%s:%s' % (self.username, self.password))[:-1]
    596                 req.add_header('Authorization', 'Basic %s' % base64string)
--> 597             self.response = urlopen(req, timeout=self.timeout).read()
    598         else:
    599             xml_post_url = self.url

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in urlopen(url, data, timeout)
    125     if _opener is None:
    126         _opener = build_opener()
--> 127     return _opener.open(url, data, timeout)
    128 
    129 def install_opener(opener):

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in open(self, fullurl, data, timeout)
    402             req = meth(req)
    403 
--> 404         response = self._open(req, data)
    405 
    406         # post-process response

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in _open(self, req, data)
    420         protocol = req.get_type()
    421         result = self._call_chain(self.handle_open, protocol, protocol +
--> 422                                   '_open', req)
    423         if result:
    424             return result

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
    380             func = getattr(handler, meth_name)
    381 
--> 382             result = func(*args)
    383             if result is not None:
    384                 return result

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in http_open(self, req)
   1212 
   1213     def http_open(self, req):
-> 1214         return self.do_open(httplib.HTTPConnection, req)
   1215 
   1216     http_request = AbstractHTTPHandler.do_request_

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in do_open(self, http_class, req)
   1185         else:
   1186             try:
-> 1187                 r = h.getresponse(buffering=True)
   1188             except TypeError: # buffering kw not supported
   1189                 r = h.getresponse()

/home/usgs/anaconda/lib/python2.7/httplib.pyc in getresponse(self, buffering)
   1065         response = self.response_class(*args, **kwds)
   1066 
-> 1067         response.begin()
   1068         assert response.will_close != _UNKNOWN
   1069         self.__state = _CS_IDLE

/home/usgs/anaconda/lib/python2.7/httplib.pyc in begin(self)
    407         # read until we get a non-100 response
    408         while True:
--> 409             version, status, reason = self._read_status()
    410             if status != CONTINUE:
    411                 break

/home/usgs/anaconda/lib/python2.7/httplib.pyc in _read_status(self)
    363     def _read_status(self):
    364         # Initialize with Simple-Response defaults
--> 365         line = self.fp.readline(_MAXLINE + 1)
    366         if len(line) > _MAXLINE:
    367             raise LineTooLong("header line")

/home/usgs/anaconda/lib/python2.7/socket.pyc in readline(self, size)
    474             while True:
    475                 try:
--> 476                     data = self._sock.recv(self._rbufsize)
    477                 except error, e:
    478                     if e.args[0] == EINTR:

timeout: timed out

In [ ]:
csw.get_operation_by_name('GetRecords').constraints

In [14]:
try:
    csw.get_operation_by_name('GetDomain')
    csw.getdomain('apiso:ServiceType', 'property')
    print(csw.results['values'])
except:
    print('GetDomain not supported')


GetDomain not supported

In [15]:
val = 'data'
filter1 = fes.PropertyIsLike(propertyname='AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ filter1 ]

In [16]:
csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
len(csw.records.keys())


Out[16]:
1000

In [62]:
choice=random.choice(list(csw.records.keys()))
print(csw.records[choice].title)
csw.records[choice].references


20130208-MODIS_A-JPL-L2P-A2013039075500.L2_LAC_GHRSST_N-v01.nc.bz2
Out[62]:
[{'scheme': 'urn:x-esri:specification:ServiceType:ArcIMS:Metadata:Onlink',
  'url': 'http://www.nodc.noaa.gov/SatelliteData/ghrsst/'},
 {'scheme': 'urn:x-esri:specification:ServiceType:ArcIMS:Metadata:Document',
  'url': 'http://www.nodc.noaa.gov/geoportal/csw?getxml=%7BED84C0FD-766F-4E20-812E-5C358AB0D82C%7D'},
 {'scheme': 'urn:x-esri:specification:ServiceType:TDS',
  'url': 'http://data.nodc.noaa.gov/thredds/catalog/ghrsst/L2P/MODIS_A/JPL/2013/039/catalog.html?dataset=ghrsst/L2P/MODIS_A/JPL/2013/039/20130208-MODIS_A-JPL-L2P-A2013039075500.L2_LAC_GHRSST_N-v01.nc.bz2'},
 {'scheme': 'urn:x-esri:specification:ServiceType:FTP',
  'url': 'ftp://ftp.nodc.noaa.gov/pub/data.nodc/ghrsst/L2P/MODIS_A/JPL/2013/039/20130208-MODIS_A-JPL-L2P-A2013039075500.L2_LAC_GHRSST_N-v01.nc.bz2'},
 {'scheme': 'urn:x-esri:specification:ServiceType:OPeNDAP',
  'url': 'http://data.nodc.noaa.gov/opendap/ghrsst/L2P/MODIS_A/JPL/2013/039/20130208-MODIS_A-JPL-L2P-A2013039075500.L2_LAC_GHRSST_N-v01.nc.bz2.html'},
 {'scheme': 'urn:x-esri:specification:ServiceType:Download',
  'url': 'http://data.nodc.noaa.gov/ghrsst/L2P/MODIS_A/JPL/2013/039/20130208-MODIS_A-JPL-L2P-A2013039075500.L2_LAC_GHRSST_N-v01.nc.bz2'},
 {'scheme': 'urn:x-esri:specification:ServiceType:WMS',
  'url': 'http://data.nodc.noaa.gov/thredds/wms/ghrsst/L2P/MODIS_A/JPL/2013/039/20130208-MODIS_A-JPL-L2P-A2013039075500.L2_LAC_GHRSST_N-v01.nc.bz2?service=WMS&version=1.3.0&request=GetCapabilities'},
 {'scheme': 'urn:x-esri:specification:ServiceType:WCS',
  'url': 'http://data.nodc.noaa.gov/thredds/wcs/ghrsst/L2P/MODIS_A/JPL/2013/039/20130208-MODIS_A-JPL-L2P-A2013039075500.L2_LAC_GHRSST_N-v01.nc.bz2?service=WCS&version=1.0.0&request=GetCapabilities'}]

Italy


In [18]:
endpoint = 'http://www.rndt.gov.it/RNDT/CSW'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version


Out[18]:
'2.0.2'

In [19]:
csw.get_operation_by_name('GetRecords').constraints


Out[19]:
[Constraint: SupportedISOQueryables - ['OrganisationName', 'Type', 'ServiceType', 'RevisionDate', 'AnyText', 'PublicationDate', 'ResourceIdentifier', 'ParentIdentifier', 'Identifier', 'TopicCategory', 'DistanceValue', 'DistanceUOM', 'TempExtent_end', 'Subject', 'CreationDate', 'Title', 'Denominator', 'Language', 'TempExtent_begin', 'Abstract'],
 Constraint: AdditionalQueryables - ['SpecificationDate', 'SpecificationDateType', 'ConditionApplyingToAccessAndUse', 'AccessConstraints', 'Classification', 'OtherConstraints', 'Degree', 'Lineage', 'SpecificationTitle', 'ResponsiblePartyRole']]

In [27]:
val = 'water'
filter1 = fes.PropertyIsLike(propertyname='AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ filter1 ]

In [28]:
csw.getrecords2(constraints=filter_list,maxrecords=100,esn='full')
len(csw.records.keys())


Out[28]:
28

In [53]:
choice=random.choice(list(csw.records.keys()))
print(csw.records[choice].title)
print(csw.records[choice].references)


MOLISEDB.GIS.MO_PTA24G_staz_monit
[]

In [152]:
endpoint='http://172.21.173.15/geonetwork/srv/eng/csw'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version


---------------------------------------------------------------------------
URLError                                  Traceback (most recent call last)
<ipython-input-152-f9afd2b8dff5> in <module>()
      1 endpoint='http://172.21.173.15/geonetwork/srv/eng/csw'
----> 2 csw = CatalogueServiceWeb(endpoint,timeout=60)
      3 csw.version

/home/usgs/anaconda/lib/python2.7/site-packages/OWSLib-0.8.9-py2.7.egg/owslib/csw.pyc in __init__(self, url, lang, version, timeout, skip_caps, username, password)
     77             self.request = '%s%s' % (bind_url(self.url), urlencode(data))
     78 
---> 79             self._invoke()
     80 
     81             if self.exceptionreport is None:

/home/usgs/anaconda/lib/python2.7/site-packages/OWSLib-0.8.9-py2.7.egg/owslib/csw.pyc in _invoke(self)
    595                 base64string = base64.encodestring('%s:%s' % (self.username, self.password))[:-1]
    596                 req.add_header('Authorization', 'Basic %s' % base64string)
--> 597             self.response = urlopen(req, timeout=self.timeout).read()
    598         else:
    599             xml_post_url = self.url

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in urlopen(url, data, timeout)
    125     if _opener is None:
    126         _opener = build_opener()
--> 127     return _opener.open(url, data, timeout)
    128 
    129 def install_opener(opener):

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in open(self, fullurl, data, timeout)
    402             req = meth(req)
    403 
--> 404         response = self._open(req, data)
    405 
    406         # post-process response

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in _open(self, req, data)
    420         protocol = req.get_type()
    421         result = self._call_chain(self.handle_open, protocol, protocol +
--> 422                                   '_open', req)
    423         if result:
    424             return result

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
    380             func = getattr(handler, meth_name)
    381 
--> 382             result = func(*args)
    383             if result is not None:
    384                 return result

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in http_open(self, req)
   1212 
   1213     def http_open(self, req):
-> 1214         return self.do_open(httplib.HTTPConnection, req)
   1215 
   1216     http_request = AbstractHTTPHandler.do_request_

/home/usgs/anaconda/lib/python2.7/urllib2.pyc in do_open(self, http_class, req)
   1182         except socket.error, err: # XXX what error?
   1183             h.close()
-> 1184             raise URLError(err)
   1185         else:
   1186             try:

URLError: <urlopen error timed out>

In [ ]: