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.
print(list(wcs.contents))
giveoutput = wcs.getCoverage(identifier='dop20'
tryoutput = wcs.getCoverage(identifier=wcs['dop20'].id