[OWSLib-users] Download Large Sizes for WMS Request in OWSLib

Noah Taylor haonrolyat at gmail.com
Wed Sep 24 22:15:29 PDT 2014


Hi,

I have been having troubles finding a working WMS server for OWSLib but I
finally found a URL that is working with my code:

http://raster.nationalmap.gov/arcgis/services/Orthoimagery/USGS_EROS_Ortho_NAIP/ImageServer/WMSServer?request=GetCapabilities&service=WMS

I'd like to have a world map at this high resolution since this is just a
U.S. map, if anybody knows of any, but in any case the problem I am facing
now is that when I attempt to call a large size, I get the following error:

*KeyError: 'content-type'*

The error does not show up if I stay below or close to 3MB so I am unsure
if this is a limit that the WMS server is imposing on me or if it is an
error in the Python code. I read somewhere there is a default limit to act
as the safeguard to the user so they don't accidentally download more than
they can handle but am unsure. I will post my 'working' script below. You
will only need to run it to see the error and downsize the size for it to
actually download the request.

Thanks for your time
Noah

###################################################################

from owslib.wms import WebMapService
wms = WebMapService('
http://raster.nationalmap.gov/arcgis/services/Orthoimagery/USGS_EROS_Ortho_NAIP/ImageServer/WMSServer?request=GetCapabilities&service=WMS
')


print(wms.identification.type)
print(wms.identification.title)
print(list(wms.contents))
print(wms['0'].title)
print(wms['0'].boundingBox)
print(wms['0'].crsOptions)
print(wms['0'].styles)

print(wms.getOperationByName('GetMap').formatOptions)

print(list(wms.contents))


img = wms.getmap(   layers=['0'],
                     styles=[],
                     srs='EPSG:4326',
                     bbox=(-111.85738494873, 39.9462890625,
-110.98876849262, 40.445555601989),
                     size=(8000, 4598),
                     format='image/jpeg',
                     transparent=True,
                     stream = True)
out = open('nationalmap.jpg', 'wb')
out.write(img.read())
out.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/owslib-users/attachments/20140924/332ecba8/attachment.html>


More information about the OWSLib-users mailing list