There is no GML parsing in OWSLib. WebMapService.getmap and WebFeatureService.getfeature
return imagery and XML. OWSLib does parse service metadata,
and can be used to
find out what a WMS or WFS has to offer. For example:
>>> from owslib.wms import WebMapService
>>> wms = WebMapService('http://wms.jpl.nasa.gov/wms.cgi', version='1.1.1')
>>> wms.capabilities.service
'OGC:WMS'
>>> wms.capabilities.title
'JPL Global Imagery Service'
Available layers:
>>> [layer.name for layer in wms.capabilities.contents]
['global_mosaic', 'global_mosaic_base', ... ]
Details of a layer:
>>> wms.capabilities.getContentByName('global_mosaic').title
'WMS Global Mosaic, pan sharpened'
>>> wms.capabilities.getContentByName('global_mosaic').boundingBox
>>> wms.capabilities.getContentByName('global_mosaic').boundingBoxWGS84
(-180.0, -60.0, 180.0, 84.0)
>>> wms.capabilities.getContentByName('global_mosaic').crsOptions
['EPSG:4326', 'AUTO:42003']
>>> wms.capabilities.getContentByName('global_mosaic').styles
{ ...,
'visual_bright': {
'title': 'Real-color image (Uses the visual bands, 321 mapping), gamma 1.5'
}
}
Available methods, their URLs, and available formats:
>>> [op.name for op in wms.capabilities.operations]
['GetCapabilities', 'GetMap']
>>> wms.capabilities.getOperationByName('GetMap').methods
{'Get': {'url': 'http://wms.jpl.nasa.gov/wms.cgi?'}}
>>> wms.capabilities.getOperationByName('GetMap').formatOptions
['image/jpeg', 'image/png', 'image/geotiff', 'image/tiff']
That's everything needed to make a request for imagery:
>>> img = wms.getmap( layers=['global_mosaic'],
... styles=['visual_bright'],
... srs='EPSG:4326',
... bbox=(-112, 36, -106, 41),
... size=(300, 250),
... format='image/jpeg',
... transparent=True
... )
>>> out = open('jpl_mosaic_visb.jpg', 'wb')
>>> out.write(img.read())
>>> out.close()
Thanks,
Joel