root@874f513999fd:~# pip3.8 install -U owslib
Requirement already up-to-date: owslib in /usr/lib/python3/dist-packages (0.20.0)
WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
root@874f513999fd:~#
why thius query:
from owslib.csw import CatalogueServiceWeb
from owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox
endpoint='https://csw.epinux.com'
csw = CatalogueServiceWeb(endpoint,timeout=30)
bbox=[2,50,15,70]
bbox_query = BBox(bbox)
equalTo_query = [PropertyIsEqualTo('csw:AnyText', 'sentinel')]
csw.getrecords2(constraints=[equalTo_query, bbox_query], maxrecords=20)
returns 10 records
while this one:
csw.getrecords2(constraints=[bbox_query], maxrecords=20)
returns 0
csw.getrecords2(constraints=equalTo_query, maxrecords=20)
compared with csw.getrecords2(constraints=[equalTo_query, bbox_query], maxrecords=20)
getrecords2
function:from owslib.csw import CatalogueServiceWeb
from owslib.fes import PropertyIsEqualTo, PropertyIsLike, BBox
endpoint='https://csw.epinux.com'
csw = CatalogueServiceWeb(endpoint,timeout=30)
bbox=[2,50,15,70]
bbox_query = BBox(bbox)
equalTo_query = PropertyIsEqualTo('csw:AnyText', 'sentinel')
csw.getrecords2(constraints=[[equalTo_query, bbox_query]], maxrecords=20)
print(csw.request)
print(csw.results)
csw.getrecords2(constraints=[bbox_query], maxrecords=20)
print(csw.request)
print(csw.results)
thanks! I think I am getting there, thanks for the working example :) - now dealing with the extraction of the extent for each dataset - I got it with something like:
for rec in csw.records:
bbox = vars(csw.records[rec].bbox)
which I'm gonna use to create a geojson feature.
I am not quite sure about how to work with the generator returned by the query.
I can get the first 10 records .. but how to access the next in the results? Do I need to repeat the query by changing the startposition
parameter .. until I get all of them?
say, csw.results
gives me:
{'matches': 274536, 'returned': 10, 'nextrecord': 11}
I can get the values for the first "returned" 10 elements, by looping over it, like:
for rec in csw.records:
appendJsonFeature(name = csw.records[rec].identifiers,
geom = vars(csw.records[rec].bbox))
How to get the next 10 ,, and so on .. ?
do I need to re-issue the query, like:
startposition = csw.results['nextrecord']
csw.getrecords2(constraints=[[equalTo_query, bbox_query]], maxrecords=20, esn='full', startposition=startposition)
until startposition reaches the 'matches' records?
Hi all: FYI 0.21.0 has been released: https://lists.osgeo.org/pipermail/owslib-users/2020-December/000194.html
Thanks for everyone’s contributions and @cehbrecht for continued support.
processes.py
being put there, for example?