跳转到主要内容

OGC网络服务实用库

项目描述

OWSLib

Build License Chat

概述

OWSLib 是一个用于客户端编程的 Python 包,它遵循开放地理空间联盟(OGC)的 Web 服务(因此称为 OWS)接口标准及其相关内容模型。

完整文档可在 https://owslib.readthedocs.io 获取

OWSLib 提供了一个通用的 API 来访问服务元数据,并为许多 OGC Web 服务接口提供了包装器。

安装

安装 pywis-pubsub 最简单的方法是通过 Python 的 pip 工具

pip3 install OWSLib

需求

依赖项

依赖项列在 requirements.txt 中。依赖项将在 OWSLib 安装过程中自动安装。

安装 OWSLib

# setup virtualenv
python3 -m venv owslib
cd owslib
source bin/activate

# clone codebase and install
git clone https://github.com/geopython/OWSLib.git
cd OWSLib
python3 setup.py install

运行

了解 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.'

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()

对于 WebFeatureService 也有非常类似的 API。有关详细信息,请参阅 tests/wfs_MapServerWFSCapabilities.txt。

还支持 Web 覆盖服务(WCS)、网络目录服务(CSW)、网络处理服务(WPS)和网络地图瓦片服务(WMTS)。其中一些是beta质量。

日志记录

OWSLib 将消息记录到名为 'owslib' 的 Python 日志记录器。您可以配置应用程序使用日志消息,如下所示

    >>> 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)

发布

  # update version
  vi owslib/__init__.py
  git commit -m 'update release version' 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 on PyPI (must be a maintainer)
  rm -fr build dist *.egg-info
  python setup.py sdist bdist_wheel --universal
  twine upload dist/*

支持

项目详情


发布历史 发布通知 | RSS 源

下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

OWSLib-0.31.0.tar.gz (185.3 kB 查看哈希值)

上传

构建分布

OWSLib-0.31.0-py2.py3-none-any.whl (233.1 kB 查看哈希值)

上传于 Python 2 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面