ogc web服务实用程序库
OWSLib的Python项目详细描述
owslib是一个python包,用于使用open geospatial进行客户端编程 联盟(ogc)web服务(因此是ows)接口标准,以及 相关内容模型。
完整文档可在http://geopython.github.io/OWSLib
owslib为访问 众多的ogc web服务接口。
依赖关系
owslib需要elementtree(2.5中标准的xml.etree)或lxml。
用法
了解WMS提供的服务。服务元数据:
>>> 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.'
可用层:
>>> 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']
层的详细信息:
>>> 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'}}
可用方法、它们的url和可用格式:
>>> [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']
这就是请求图像所需的一切:
>>> 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()存在一个非常相似的API。见 tests/wfs_mapserverwfscapabilities.txt了解详细信息。
还支持Web Coverage Service(WCS)、Catalogue web服务(csw)、web处理服务(wps)和web 地图平铺服务(WMTS)。其中一些是beta质量。
日志记录
owslib将消息记录到名为python logger的“owslib”中。你可以 将应用程序配置为使用如下日志消息:
>>> import logging >>> owslib_log = logging.getLogger('owslib') >>> # Add formatting and handlers as needed >>> owslib_log.setLevel(logging.DEBUG)
释放
# 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 upload
支架
http://lists.osgeo.org/mailman/listinfo/owslib-usershttp://lists.osgeo.org/mailman/listinfo/owslib-devel