0

I wrote a Python script in order to read a WCS with the module OWSlib:

# -*- coding: utf-8 -*-
from owslib.wcs import WebCoverageService
from owslib.util import Authentication
ldbv_url = 'https://geoservices.bayern.de/inspire-ows/v1/dop/oi/dls/wcs?'
wcs = WebCoverageService(ldbv_url, version='2.0.0',auth=Authentication(username='Test', password='Test'))
# Available Layer
print(wcs.contents.keys())
layer = 'dop20'
#GetCoverage Request
subset_bbox=(686995,687195,5346918,5347118)
#output=wcs.getCoverage()
output = wcs.getCoverage(identifier='dop20',Styles='fc',bbox=subset_bbox,format='image/tiff',crs='EPSG:25832', width=200, height=200)

However I get an error, as the CoverageID is wrongly set:

dict_keys(['dop20'])


Traceback (most recent call last):

File "r:\85\85_gemeinsam\rie\import_wcs.py", line 40, in <module>
output = wcs.getCoverage(identifier='dop20',Styles='fc',bbox=subset_bbox,format='image/tiff',crs='EPSG:25832', width=200, height=200)
File "C:\Users\rie\Anaconda3\lib\site-packages\owslib\coverage\wcs200.py", line 216, in getCoverage
u = openURL(base_url, data, method, self.cookies, auth=self.auth)
 File "C:\Users\rie\Anaconda3\lib\site-packages\owslib\util.py", line 210, in openURL
req.raise_for_status()
 File "C:\Users\rie\Anaconda3\lib\site-packages\requests\models.py", line 940,    in raise_for_status
raise HTTPError(http_error_msg, response=self)
HTTPError: 404 Client Error: Not Found for url: https://geoservices.bayern.de/inspire-ows/v1/dop/oi/dls/wcs?version=2.0.0&request=GetCoverage&service=WCS&CoverageID=d&crs=EPSG%3A25832&format=image%2Ftiff&width=200&height=200&Styles=fc

The CoverageId must be dop20.

What am I doing wrong?

I tried identifier=wcs['dop20'].id which gives me dop20, if I print it.

The line output = wcs.getCoverage(identifier=wcs['dop20'].id,Styles='fc',bbox=subset_bbox,format='image/tiff',crs='EPSG:25832', width=200, height=200) still gives me following error:

HTTPError: 404 Client Error: Not Found for url: https://geoservices.bayern.de/inspire-ows/v1/dop/oi/dls/wcs?version=2.0.0&request=GetCoverage&service=WCS&CoverageID=d&crs=EPSG%3A25832&format=image%2Ftiff&width=200&height=200&Styles=fc

Again the CoverageID is set wrongly.

4
  • What does the print statement give you?
    – Ian Turton
    Commented Oct 22, 2020 at 16:30
  • what does print(list(wcs.contents)) give
    – nmtoken
    Commented Oct 22, 2020 at 18:22
  • The Prinz statement gives me dict_keys(['dop20'])
    – Isabell
    Commented Oct 22, 2020 at 20:12
  • instead of output = wcs.getCoverage(identifier='dop20' try output = wcs.getCoverage(identifier=wcs['dop20'].id
    – nmtoken
    Commented Oct 23, 2020 at 11:36

1 Answer 1

1

You have probably resolved this, but the solution is to provide a list of identifiers rather than the direct string of the variable you are seeking i.e:

wcs.getCoverage(identifier=[wcs['dop20'].id],
                Styles='fc',
                bbox=subset_bbox,
                format='image/tiff',crs='EPSG:25832', width=200, height=200)

This is a key difference between version 1.0.0 and 2.0.1, as 1.0.0 would accept a single string for the identifier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.