{"id":5358,"library":"owslib","title":"OGC Web Service utility library (OWSLib)","description":"OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (OWS) interface standards, and their related content models. It provides a common API for accessing service metadata and wrappers for numerous OGC Web Service interfaces, including WMS, WFS, WCS, WPS, CSW, SOS, WMTS, and OGC API standards. The current version is 0.35.0, released on October 28, 2025. Releases are frequent, with several minor versions per year.","status":"active","version":"0.35.0","language":"en","source_language":"en","source_url":"https://github.com/geopython/OWSLib","tags":["OGC","GIS","geospatial","WMS","WFS","WCS","WPS","CSW","SOS","WMTS","OGC API"],"install":[{"cmd":"pip install OWSLib","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Required for XML parsing.","package":"lxml"},{"reason":"Provides powerful extensions to the standard Python datetime module.","package":"python-dateutil"},{"reason":"An elegant and simple HTTP library for Python.","package":"requests"},{"reason":"YAML parser and emitter for Python.","package":"PyYAML"}],"imports":[{"symbol":"WebMapService","correct":"from owslib.wms import WebMapService"},{"symbol":"WebFeatureService","correct":"from owslib.wfs import WebFeatureService"},{"symbol":"WebCoverageService","correct":"from owslib.wcs import WebCoverageService"},{"symbol":"WebProcessingService","correct":"from owslib.wps import WebProcessingService"},{"symbol":"CatalogueServiceWeb","correct":"from owslib.csw import CatalogueServiceWeb"},{"symbol":"SensorObservationService","correct":"from owslib.sos import SensorObservationService"},{"note":"OGC API - Features (formerly WFS 3) is a separate module with a different API design. Use `owslib.ogcapi.features` for these services.","wrong":"from owslib.wfs import WebFeatureService (for OGC API - Features)","symbol":"Features","correct":"from owslib.ogcapi.features import Features"}],"quickstart":{"code":"import os\nfrom owslib.wms import WebMapService\n\n# Using a public WMS server for demonstration\n# Note: Older examples might use decommissioned servers (e.g., wms.jpl.nasa.gov).\n# Ensure the URL is active and provides WMS capabilities.\n# For a robust solution, consider using a well-maintained public WMS or your own.\nwms_url = os.environ.get('WMS_SERVER_URL', 'http://ows.mundialis.de/services/service?')\n\ntry:\n    wms = WebMapService(wms_url, version='1.3.0')\n    print(f\"Connected to WMS: {wms.identification.title}\")\n    print(f\"Available layers: {list(wms.contents.keys())[:5]}...\")\n\n    # Example: Get metadata for a specific layer\n    if 'OSM-WMS' in wms.contents:\n        layer = wms.contents['OSM-WMS']\n        print(f\"\\nLayer 'OSM-WMS' title: {layer.title}\")\n        print(f\"Bounding Box: {layer.boundingBoxWGS84}\")\n    else:\n        print(\"Layer 'OSM-WMS' not found on this server. Trying first available layer...\")\n        if wms.contents:\n            first_layer_name = list(wms.contents.keys())[0]\n            layer = wms.contents[first_layer_name]\n            print(f\"\\nLayer '{first_layer_name}' title: {layer.title}\")\n            print(f\"Bounding Box: {layer.boundingBoxWGS84}\")\n        else:\n            print(\"No layers found on this WMS server.\")\n\nexcept Exception as e:\n    print(f\"Error connecting to WMS server or retrieving data: {e}\")\n    print(\"Please ensure the WMS_SERVER_URL environment variable is set to a valid WMS endpoint,\")\n    print(\"or use a known working public WMS server.\")\n","lang":"python","description":"This quickstart demonstrates how to connect to an OGC Web Map Service (WMS) using OWSLib, retrieve its capabilities, and inspect a specific layer's metadata. It fetches the service title and lists a few available layers."},"warnings":[{"fix":"Always verify WMS/WFS/etc. server URLs from official and up-to-date sources. Use a known active public WMS server or your own. For example, `http://ows.mundialis.de/services/service?` is a commonly used public WMS.","message":"Many older quickstart examples and tutorials for OWSLib, particularly those demonstrating WMS, use a decommissioned NASA JPL WMS server (`http://wms.jpl.nasa.gov`). Attempting to use this URL will result in connection errors.","severity":"gotcha","affected_versions":"All versions (due to external server change)"},{"fix":"Use `from owslib.ogcapi.features import Features` for OGC API - Features, `from owslib.ogcapi.coverages import Coverages` for OGC API - Coverages, etc. Do not try to use `WebFeatureService` for OGC API - Features.","message":"When working with OGC API services (e.g., OGC API - Features), ensure you import from the correct `owslib.ogcapi` submodule (e.g., `from owslib.ogcapi.features import Features`). These APIs are a modern, RESTful design and are distinct from traditional OGC Web Services (WFS, WMS, etc.), which have their own dedicated modules.","severity":"gotcha","affected_versions":"All versions supporting OGC API (0.26.0 onwards)"},{"fix":"Always ensure you are activating the correct Python virtual environment before installing and running scripts that use OWSLib. Verify the Python interpreter being used by your script (e.g., `import sys; print(sys.executable)`).","message":"Users often encounter `ModuleNotFoundError` for `owslib` or its submodules even after installation. This is frequently caused by Python environment issues, such as the script running in a different environment than where `owslib` was installed (e.g., a default system Python vs. a virtual environment).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your environment uses Python 3.10 or newer. OWSLib's `requires_python` is `>=3.10`.","message":"OWSLib dropped support for Python 3.8 and 3.9 in version 0.33.0 (released March 19, 2025).","severity":"deprecated","affected_versions":">=0.33.0"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}