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
Vale
  • 941
  • 7
  • 23
mykolaq
  • 73
  • 1
  • 7

1 Answers1

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.

Ian Turton
  • 81,417
  • 6
  • 84
  • 185
  • 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 questionlink. Maybe i didn't undersnat correctly too – mykolaq Nov 18 '16 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 '21 at 11:38
  • A WMS returns a picture of your data so pixel resolution is irrelevant. – Ian Turton Feb 15 '21 at 11:58