# 🗺️ Layer Comparison Tool for QGIS

[![QGIS Plugin](https://img.shields.io/badge/QGIS-3.0+-green.svg)](https://qgis.org)
[![Python](https://img.shields.io/badge/Python-3.6+-blue.svg)](https://python.org)
[![License](https://img.shields.io/badge/License-GPLv3-orange.svg)](https://www.gnu.org/licenses/gpl-3.0)

A professional tool for comparing vector layers and tables in QGIS, designed for data validation, quality control, and geospatial data auditing.

---

## 📋 Description

**Layer Comparison Tool** is a QGIS plugin that allows you to compare two vector layers or tables based on an alphanumeric field (codes, IDs, names, etc.). It offers three comparison modes and generates detailed statistics, automatically creating a temporary table with the analysis results.

### 🎯 Use Cases

- ✅ **Quality control** of geographic data
- ✅ **Data migration** between systems
- ✅ **Data source integration**
- ✅ **Inventory and catalog auditing**
- ✅ **Detection of missing or duplicate records**
- ✅ **Consistency validation** between databases

---

## ✨ Key Features

### 🔍 Three Comparison Modes

1. **Only in Layer 1** - Identifies values present solely in the first layer
2. **Only in Layer 2** - Identifies values present solely in the second layer
3. **Matches** - Finds values existing in both layers but with different record counts

### 📊 Detailed Statistics

- Total records per layer
- Unique values per layer
- Exact matches
- Quantity differences
- Exclusive elements from each layer

### 🗺️ Visual Results

- Temporary table with analysis results
- Columns: value, description, count per layer, difference, and who has more
- Easy integration with other QGIS tools

### 🎨 User-Friendly Interface

- Professional and clean design
- Color-coded buttons for common actions
- Progress bar for long processes
- Real-time log panel
- Modern and consistent style

---

## 📥 Installation

### From QGIS Official Repository

1. Open QGIS
2. Go to **Plugins** → **Manage and Install Plugins**
3. Search for **"Layer Comparison Tool"**
4. Click **Install**

### From Source Code

```bash
# Clone the repository
git clone https://github.com/viquezr-dev/compara_tools.git

# Copy the plugin folder to QGIS plugins directory
# Windows: C:/Users/USER/AppData/Roaming/QGIS/QGIS3/profiles/default/python/plugins/
# Linux: ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/
# macOS: ~/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/


🚀 Quick Start Guide
Open the plugin: Plugins → Compare Layers → Compare Layers

Select layers:

Layer 1: Layer to verify

Layer 2: Reference layer

Select the field to compare in each layer

Choose comparison mode:

🔍 Only in Layer 1

🔍 Only in Layer 2

✅ Matches

Start comparison: Click ▶ START

Analyze results:

Review the statistical summary

Check the process log

Explore the generated temporary table

📊 Example Results
Results Table (Matches Mode)
value	description					Layer_1	Layer_2	difference	who_has_more
ID001	Layer_1 has 2 more record(s) than Layer_2	5	3	2		Layer_1
ID002	Layer_2 has 1 more record(s) than Layer_1	2	3	1		Layer_2
ID003	Only in Layer_1					1	0	1		Layer_1

Generated Statistics

📊 Layer1 (Inventory_2024): 250 records | 150 unique
📊 Layer2 (Inventory_2023): 230 records | 140 unique
✅ Exact matches: 120
⚠️ Values with different quantity: 15
📌 Only in Layer 1: 30
📌 Only in Layer 2: 20
🛠️ Technical Requirements
QGIS: Version 3.0 or higher

Python: 3.6 or higher

Operating System: Windows, Linux, macOS

Dependencies
All dependencies are included in QGIS:

PyQt5

qgis.core

qgis.gui

qgis.utils

🔧 Development
Project Structure

compara_tools/
├── __init__.py              # Plugin initialization
├── comparador_capas.py      # Main logic
├── icon.png                 # Plugin icon
├── metadata.txt             # Plugin metadata
└── README.md                # This file
Contribution Guide
Fork the repository

Create a branch for your feature: git checkout -b feature/new-feature

Commit your changes: git commit -m 'Add new feature'

Push to the branch: git push origin feature/new-feature

Open a Pull Request

Code Style
Follow PEP 8 for Python

Use docstrings to document functions and classes

Maintain compatibility with QGIS 3.x

📝 Changelog
Version 1.1.1 (Current)
✅ First stable version

✅ Basic comparison between two vector layers

✅ Three search modes

✅ Temporary table generation with results

✅ Real-time statistics panel

✅ Progress bar for long processes

✅ Detailed process log

✅ Professional-style interface

Upcoming Features
□ Support for comparing multiple layers
□ Export results to CSV/Excel
□ Comparison with custom expressions
□ Advanced filtering options
🤝 Contributing
Contributions are welcome! Please:

Check the open issues

Comment if you're working on one

Follow the style guides

Ensure code passes tests

📄 License
This project is licensed under the GNU General Public License v3.0.

text
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
👤 Author
Raúl Víquez

📧 Email: viquezr@gmail.com

🔗 GitHub: @viquezr-dev

🙏 Acknowledgments
To the QGIS development team for their incredible work

To the QGIS community for constant support and feedback

To all users who have contributed with suggestions and bug reports

