2

I want to download a raster from a WMS server with Python and OWSLib. I have written this code from an example in a manual.

from owslib.wms import WebMapService
wms = WebMapService('http://mapy.geoportal.gov.pl:80/wss/servic/img/guest/ORTO/MapServer/WMSServer', version='1.1.1')
wms.identification.type
wms.identification.title
list(wms.contents)
wms['Raster'].title
wms['Raster'].queryable
wms['Raster'].opaque
wms['Raster'].boundingBoxWGS84
wms['Raster'].crsOptions
wms['Raster'].styles
[op.name for op in wms.operations]
wms.getOperationByName('GetMap').methods
wms.getOperationByName('GetMap').formatOptions
img = wms.getmap(   layers=['Raster'],
                styles=['default'],
                 srs='EPSG:2178',
                 bbox=(708542, 460329, 731172, 493289),
                 size=(32960, 22360),
                 format='image/tiff'
                           )
                           out = open('polandtest.tiff', 'wb')
out.write(img.read())
out.close()

This code returns error:

owslib.util.ServiceException: Parameter 'width' contains unacceptable   value
1
  • Does the GetCapabilities response report a <MaxWidth>?
    – nmtoken
    Nov 20, 2016 at 14:19

1 Answer 1

3

You are asking for an image of dimension 736,985,600 px (32960 x 22360) so even if it was only one byte per pixel it would be most of a giga byte. I suspect that the server will not allow you to ask for that size of image.

Try more reasonable sizes like 1024x800 - more pixels won't show up on your screen.

3
  • Hm , i think i didnt understand dowloading correctly. Usually it is like: load tiles and than merge it and i thought there is no difference what image size to ask. And i decided how to change resolution from my other question[link]( gis.stackexchange.com/questions/218256/… ). Maybe i didn't undersnat correctly too
    – mykolaq
    Nov 18, 2016 at 11:57
  • geotiff images have a specific geographic resolution for each pixel so if you resize the image the resolution will no longer be the same
    – fccoelho
    Feb 15, 2021 at 11:38
  • A WMS returns a picture of your data so pixel resolution is irrelevant.
    – Ian Turton
    Feb 15, 2021 at 11:58

Your Answer

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

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