The search on the next line returns 11 records from NODC geoportal (http://www.nodc.noaa.gov/geoportal/):
('roms' OR 'selfe' OR 'adcirc' OR 'ncom' OR 'hycom' OR 'fvcom') AND 'ocean' NOT 'regridded' NOT 'espresso'
How do I do this same request using OWSLib CSW w/ FES?
In [1]:
from owslib.csw import CatalogueServiceWeb
from owslib import fes
In [2]:
search_text = ['roms','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 [3]:
endpoint = 'http://www.nodc.noaa.gov/geoportal/csw' # NODC/UAF Geoportal: granule level
csw = CatalogueServiceWeb(endpoint,timeout=60)
print csw.version
In [4]:
csw.getrecords2(constraints=filter_list,maxrecords=1000,esn='full')
len(csw.records.keys())
Out[4]:
In [4]: