OGC Web Service utility library
Project description
OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
Full documentation is available at http://geopython.github.io/OWSLib
OWSLib provides a common API for accessing service metadata and wrappers for numerous OGC Web Service interfaces.
Dependencies
OWSLib requires elementtree (standard in 2.5 as xml.etree) or lxml.
Installation
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/wfs_MapServerWFSCapabilities.txt for details.
There is also support for Web Coverage Service (WCS), Catalogue Service for the Web (CSW), Web Processing Service (WPS), and Web Map Tile Service (WMTS). Some of those are beta quality.
Logging
OWSLib logs messages to the ‘owslib’ named python logger. You may configure your application to use the log messages like so:
>>> import logging >>> owslib_log = logging.getLogger('owslib') >>> # Add formatting and handlers as needed, for example to log to the console >>> ch = logging.StreamHandler() >>> ch.setLevel(logging.DEBUG) >>> ch.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) >>> # add the handler to the logger >>> owslib_log.addHandler(ch) >>> owslib_log.setLevel(logging.DEBUG)
Releasing
# update version
vi VERSION.txt
vi owslib/__init__.py
git commit -m 'update release version' VERSION.txt owslib/__init__.py
# push changes
git push origin master
git tag -a x.y.z -m 'tagging OWSLib release x.y.z'
# push tag
git push --tags
# update live docs
cd docs
make html
./publish.sh
# update on PyPI (must be a maintainer)
python setup.py sdist bdist_wheel --universal
twine upload dist/*
Support
http://lists.osgeo.org/mailman/listinfo/owslib-users http://lists.osgeo.org/mailman/listinfo/owslib-devel
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file OWSLib-0.28.0.tar.gz
.
File metadata
- Download URL: OWSLib-0.28.0.tar.gz
- Upload date:
- Size: 175.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.28.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dad03f5d955c16a763954d554f63318cd3037aef7abd08fc564f5e83f72fab94 |
|
MD5 | 7859530428d404f0454a2855067de725 |
|
BLAKE2b-256 | e4bbd17ea95e3c9ceca2f3587c5c96a928514f1bf9bffe0342566bdc20c97318 |
File details
Details for the file OWSLib-0.28.0-py2.py3-none-any.whl
.
File metadata
- Download URL: OWSLib-0.28.0-py2.py3-none-any.whl
- Upload date:
- Size: 220.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.28.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2eb1f6d9f07ed36b3b75b9c10552a784c309ee99053e08ae0664ce3b7ae70d4e |
|
MD5 | 80e3cf1d6ff453db87e95938ef070924 |
|
BLAKE2b-256 | 6c94fdef1157d00bc75db8869f904e51932d6764ccaaa2389e05a783caf66e4c |