Skip to main content

OGC Web Service utility library

Project description

Package for working with OGC map, feature, and coverage services.

OWSLib provides a common API for accessing service metadata and wrappers for GetCapabilities, GetMap, and GetFeature requests.

The OWSLib version 0.3 API is incompatible with version 0.2.1.

Dependencies

OWSLib requires elementtree (standard in 2.5 as xml.etree) or lxml.

Usage

Find out what a WMS has to offer. Service metadata:

>>> from owslib.wms import WebMapService
>>> wms = WebMapService('http://wms.jpl.nasa.gov/wms.cgi', version='1.1.1')
>>> wms.identification.type
'OGC:WMS'
>>> wms.identification.version
'1.1.1'
>>> wms.identification.title
'JPL Global Imagery Service'
>>> wms.identification.abstract
'WMS Server maintained by JPL, worldwide satellite imagery.'

Available layers:

>>> list(wms.contents)
['us_landsat_wgs84', 'modis', 'global_mosaic_base', 'huemapped_srtm',
'srtm_mag', 'daily_terra', 'us_ned', 'us_elevation', 'global_mosaic',
'daily_terra_ndvi', 'daily_aqua_ndvi', 'daily_aqua_721', 'daily_planet',
'BMNG', 'srtmplus', 'us_colordem', None, 'daily_aqua', 'worldwind_dem',
'daily_terra_721']

Details of a layer:

>>> wms['global_mosaic'].title
'WMS Global Mosaic, pan sharpened'
>>> wms['global_mosaic'].boundingBoxWGS84
(-180.0, -60.0, 180.0, 84.0)
>>> wms['global_mosaic'].crsOptions
['EPSG:4326', 'AUTO:42003']
>>> wms['global_mosaic'].styles
{'pseudo_bright': {'title': 'Pseudo-color image (Uses IR and Visual bands,
542 mapping), gamma 1.5'}, 'pseudo': {'title': '(default) Pseudo-color
image, pan sharpened (Uses IR and Visual bands, 542 mapping), gamma 1.5'},
'visual': {'title': 'Real-color image, pan sharpened (Uses the visual
bands, 321 mapping), gamma 1.5'}, 'pseudo_low': {'title': 'Pseudo-color
image, pan sharpened (Uses IR and Visual bands, 542 mapping)'},
'visual_low': {'title': 'Real-color image, pan sharpened (Uses the visual
bands, 321 mapping)'}, '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.operations]
['GetTileService', 'GetCapabilities', 'GetMap']
>>> wms.getOperationByName('GetMap').methods
{'Get': {'url': 'http://wms.jpl.nasa.gov/wms.cgi?'}}
>>> wms.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()

A very similar API exists for WebFeatureService. See tests/MapServerWFSCapabilities.txt for details.

Known Issues

OWSLib works with WMS version 1.1.1 and WFS 1.0.0 Other versions are not supported at this time.

Support

Mailing Lists:

https://lists.sourceforge.net/mailman/listinfo/owslib-users https://lists.sourceforge.net/mailman/listinfo/owslib-devel

Wiki: https://sourceforge.net/apps/trac/owslib/wiki

Documentation: http://owslib.sourceforge.net/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

OWSLib-0.3.1.tar.gz (50.9 kB view details)

Uploaded Source

File details

Details for the file OWSLib-0.3.1.tar.gz.

File metadata

  • Download URL: OWSLib-0.3.1.tar.gz
  • Upload date:
  • Size: 50.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for OWSLib-0.3.1.tar.gz
Algorithm Hash digest
SHA256 0d1b328b0efa650a2aeae06e587d111dde60b4975a476b619d0043b7602d84f1
MD5 b822f0581ee4de193df4b253aacb4189
BLAKE2b-256 b80d1a00998572f0fc8f0907314e513deb4f3cfeae8c0edb957064d284570808

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page