ogc web服务实用程序库

OWSLib的Python项目详细描述


Travis BuildCodacy CheckGitHub licenseJoin the chat at https://gitter.im/geopython/OWSLib

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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如果SQL server执行计划是流式传输数据,那么调用next()时Java ResultSet对象将如何反应?   java为什么水平滚动条永远不会出现在JTable上?   java如何在Android项目中添加SDK模块   绿脚:爪哇。lang.ClassCastException:无法将障碍物投射到球投射物   xslt需要在Java1.4.2中使用SaxonB(版本9.1.0.8)方面的帮助   java Apache HTTP客户端下载SOAP响应的一部分   为Java 9计划的“过滤传入序列化数据”解决了数据反序列化安全漏洞吗?   java如何使用drools对列表中的元素进行分组   java从匿名类到lambda表达式   Java中是否有不可变的单链表实现?   java动态添加按钮以滚动查看安卓   java GAE:无法为模块http请求设置管理员登录凭据   java如何在Hibernate 5 CriteriaBuilder中使用条件条件获取计数   java如何将JSON+HAL响应解析为POJO   java如何获取计算器程序,对两个以上的数字进行加、减、乘、除   java Thymeleaf+静态资源+@ResponseBody