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.1.tar.gz (10.2 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.1-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ogc2qgis-0.1.1.tar.gz
  • Upload date:
  • Size: 10.2 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.1.tar.gz
Algorithm Hash digest
SHA256 0c6c76e6c7dd97a5b7bdec4e922fae686089eea7efabe7e823c4308b0e22e3fc
MD5 5d8be10fee6b49b182ab1946b85c1207
BLAKE2b-256 bb598d42c818d24c51539f368d06ed396b2a406c79f64d822aa43221e4b38b80

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ogc2qgis-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 edc27c8053c7679087d230855306bff3c672284fafecef3332ea5c092802c828
MD5 916c67013078cef16c3d470bfc42721b
BLAKE2b-256 9d37e89ef1680ee6888fbc0ff96dc55c095cbe14c2e78dcf6626604e220d3479

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