A QGIS processing plugin that automatically rotates polygons to align them parallel with their nearest lines based on configurable parameters.
Polygons Parallel to Line Plugin on QGIS Plugins Web Portal
- Installation
- Quick Start
- Features
- Algorithm
- Configuration
- Usage Examples
- Requirements
- Best Practices
- Development
- License
- Support
- Open QGIS
- Go to Plugins → Manage and Install Plugins
- Search for "Polygons Parallel to Line"
- Click Install Plugin
- Download the plugin from the QGIS Plugins Repository
- Extract to your QGIS plugins directory
- Restart QGIS and enable the plugin
- Access the Plugin: Go to Processing → Toolbox → Polygons Parallel to Line
- Select Input Layers: Choose your polygon and line layers
- Configure Parameters: Set distance and angle thresholds as needed
- Run: Execute the algorithm to generate aligned polygons
✅ Automatic Polygon Rotation: Intelligently rotates polygons to align with nearest lines
✅ Distance-based Filtering: Optional maximum distance constraint
✅ Angle Threshold Control: Configurable rotation angle limits
✅ Multigeometry Support: Handles both simple and complex geometries
✅ Rotation Tracking: Adds _rotated
field to track which polygons were modified
✅ Geometry Validation: Built-in checks for geometry integrity
The plugin processes each polygon using the following steps:
-
Distance Check: Calculates distance from polygon centroid to nearest line
- If
Max distance from line
> 0 and distance exceeds threshold → skip polygon
- If
-
Vertex Analysis: Identifies the closest polygon vertex to the nearest line
-
Segment Evaluation: Analyzes two adjacent segments of the closest vertex
-
Angle Calculation: Computes rotation angles between line segment and polygon segments
-
Rotation Decision:
- If both angles ≤
Max angle
:- Longest segment mode: Rotates based on longest segment (or smallest angle if equal)
- Default mode: Rotates based on smallest angle
- If only one angle ≤
Max angle
: Rotates based on that segment
- If both angles ≤
-
Output Generation: Creates rotated geometry with
_rotated
field indicator
- Rotation center is the polygon centroid
- Interior rings and duplicate vertices are ignored
- Multipolygons use the same principles as simple polygons
- The
_rotated
field indicates transformation status (boolean)
- Type: Float (optional)
- Range: ≥ 0.0
- Default: 0.0 (processes all polygons)
- Unit: Line layer CRS units
When set to 0.0, all polygons are processed regardless of distance.
- Type: Float (optional)
- Range: 0.0 - 89.9 degrees
- Default: 89.9
- Purpose: Limits maximum rotation angle
- Type: Boolean
- Default: False
- Behavior: When both segments have valid angles (≤ Max angle), prioritizes the longest segment
- Type: Boolean
- Default: False
- Purpose: Excludes multipolygon geometries from processing
Input: Building polygons + Road centerlines
Output: Buildings aligned parallel to nearest roads
Max Distance: 50.0 (meters)
Max Angle: 45.0 (degrees)
Result: Only buildings within 50m of roads, with rotation ≤ 45°
- QGIS: 3.0 or higher
- Dependencies: Standard QGIS processing framework
- ✅ Windows
- ✅ macOS
- ✅ Linux
- ✅ All QGIS LTR versions
- Prepare Data: Ensure polygon and line layers are in the same CRS
- Fix Geometries: Use Processing Toolbox → Vector geometry → Fix Geometries
- Test Parameters: Start with default settings on a small dataset
- Batch Process: Apply to full dataset with optimized parameters
- Use spatial indexes for large datasets
- Consider processing in smaller batches for very large datasets
- Test different parameter combinations on representative samples
See DEVELOPMENT.md for detailed development setup and contribution guidelines.
Copyright (C) 2016-2025 by Andrii Liekariev
This project is licensed under the GNU General Public License v2.0.
Made with ❤️ for the QGIS community