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.2.tar.gz (11.1 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.2-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ogc2qgis-0.1.2.tar.gz
  • Upload date:
  • Size: 11.1 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.2.tar.gz
Algorithm Hash digest
SHA256 79134936d7cfd67ffa3b75468654e27004233735658e16edd010f97066b00552
MD5 0bc86ca7b8beb3af937acea98c0ac602
BLAKE2b-256 21462c63f9552af53b4a56caf37453e405a082aa2ae344b64764f2a379578fb0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ogc2qgis-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3ec8717797777ae3e661f15df637d1f0b7efb82627bcb7a84ff81cd78d997e45
MD5 4b63e55d545d97d3e9b05b63f57e19f7
BLAKE2b-256 9b6e75da3f2c256a4a73e752f0bf662b1aa243fae23f47c8b5b98185e2c92c89

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