Skip to main content

Convert OGC Web Services (WMS, WCS, WFS) GetCapabilities to QGIS connection configurations

Project description

ogc2qgis

Convert OGC Web Services (WMS, WCS, WFS) GetCapabilities XML to QGIS connection configurations.

PyPI version Python 3.8+ License: MIT

✨ Features

  • 🔄 Auto-detection: Automatically identifies service type (WMS, WCS, WFS)
  • 📁 Batch processing: Convert multiple capabilities files at once
  • 🌐 Remote fetch: Download capabilities directly from URLs
  • 📦 Zero dependencies: Uses only Python standard library
  • 🎯 QGIS ready: Generates files ready to import into QGIS
  • 🔧 CLI & Library: Use as command-line tool or Python library

🚀 Quick Start

Installation

pip install ogc2qgis

Command Line Usage

# Convert local file
ogc2qgis convert capabilities.xml

# Fetch and convert from URL
ogc2qgis fetch https://geoservicos.inde.gov.br/geoserver/BAPSalvador/ows

# Process multiple files
ogc2qgis convert ows.xml ows_wcs.xml ows_wfs.xml

# Specify output directory
ogc2qgis convert capabilities.xml -o /path/to/output

Python Library Usage

from ogc2qgis import parse_capabilities, fetch_and_convert

# Parse local file
configs = parse_capabilities('capabilities.xml')
# Returns: {'wms': QGISConfig, 'wcs': None, 'wfs': None}

# Fetch from URL
configs = fetch_and_convert('https://servidor.com/ows')

# Save to file
if configs['wms']:
    configs['wms'].save('qgis_wms_connections.xml')

📖 Documentation

Supported Services

  • WMS (Web Map Service) - Map visualization
  • WCS (Web Coverage Service) - Raster data download
  • WFS (Web Feature Service) - Vector data access

Output Files

The tool generates QGIS-compatible XML files:

  • qgis_wms_connections.xml - WMS connections
  • qgis_wcs_connections.xml - WCS connections
  • qgis_wfs_connections.xml - WFS connections

Import into QGIS

  1. Open QGIS
  2. Go to SettingsOptionsSystem
  3. In Service Connections section, click Import
  4. Select the generated XML file(s)
  5. Done! Servers appear in your connection lists

🔧 Advanced Usage

CLI Options

ogc2qgis convert --help

Usage: ogc2qgis convert [OPTIONS] FILES...

Options:
  -o, --output-dir PATH  Output directory for generated files
  -p, --prefix TEXT      Prefix for output filenames
  -v, --verbose          Verbose output
  --help                 Show this message and exit

Library API

from ogc2qgis.parsers import WMSParser, WCSParser, WFSParser

# Parse WMS
parser = WMSParser('ows.xml')
print(f"Service: {parser.service_name}")
print(f"URL: {parser.server_url}")
print(f"Layers: {len(parser.layers)}")

# Generate config
config = parser.to_qgis_config()
config.save('output.xml')

# Auto-detect service type
from ogc2qgis.core import detect_service_type
service_type = detect_service_type('capabilities.xml')  # Returns 'wms', 'wcs', 'wfs', or None

🌐 Real World Example

# INDE Brazil - Salvador Geographic Data
ogc2qgis fetch https://geoservicos.inde.gov.br/geoserver/BAPSalvador/ows

# Output:
# ✅ Downloaded WMS capabilities (111 layers)
# ✅ Downloaded WCS capabilities (7 coverages)
# ✅ Generated qgis_wms_connections.xml
# ✅ Generated qgis_wcs_connections.xml

🧪 Development

# Clone repository
git clone https://github.com/ogc2qgis/ogc2qgis.git
cd ogc2qgis

# Install with Poetry
poetry install

# Run tests
poetry run pytest

# Format code
poetry run black src/

# Lint
poetry run ruff src/

📝 License

MIT License - see LICENSE file for details.

🤝 Contributing

Contributions welcome! Please feel free to submit a Pull Request.

🔗 Links

📊 Status

This project is actively maintained. If you encounter any issues or have feature requests, please open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ogc2qgis-0.1.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ogc2qgis-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file ogc2qgis-0.1.0.tar.gz.

File metadata

  • Download URL: ogc2qgis-0.1.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.4 Windows/11

File hashes

Hashes for ogc2qgis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a758cfd33b8e479380beec558d578a7b29f7daf25720eb2f6ae460fbf608b96c
MD5 d719aefbaa7d55d00585dc6aca9754b6
BLAKE2b-256 9f09961d7ff6b87c42e4cdbe21b541986ad4a7d978739d67978b785fa39b417d

See more details on using hashes here.

File details

Details for the file ogc2qgis-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ogc2qgis-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.4 Windows/11

File hashes

Hashes for ogc2qgis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 221c129f303cef4d51037c71f68c2f60b482418876d72c65b6c8c9c4136a61eb
MD5 632349ad7b7683ff53eadcf8a9ae9b3f
BLAKE2b-256 18c258efde0996807e522e992d8c0df8c48152cfb27edde580f1940ff9365717

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page