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第三方库


热门话题
java如何在收到spring mqtt集成中停止重复订阅保留的消息   java改造安卓在textview中显示数据   读取CSV Java时获取While循环中的最后一行数据   将Java程序转换为小程序的部署   java如何在不向Src添加文件的情况下将文件放入GitLab测试   java包含字节数组列表的方法   java十进制转换错误   eclipse是由java引起的。lang.ClassNotFoundException:org。springframework。js。资源ResourceServlet   继承Java向上与向下   java自动调整标签内容的大小   java从Android中的AlertDialog返回信息   java在声明按钮时仿真程序中出现错误   java编写刷新线程的最佳方法   Java初学者错误   java需要帮助重置JComboBox   java如何用Spring/MultipartFile捕获中断流   java是否可以在JUnit中设置被测试类的方法的返回值?