Parallelizer

QGIS Python Plugin by Andrii Liekariev - This plugin rotates polygons so that they become parallel to their nearest lines


Project maintained by elfpkck Hosted on GitHub Pages — Theme by mattgraham

PR Validation codecov

QGIS

Parallelizer - QGIS Python Plugin

A QGIS plugin that rotates polygons (and lines) to be parallel to a reference feature (line or polygon — polygon boundary rings are treated as polylines). Two entry points: a batch Processing algorithm that operates on whole layers, and an interactive map tool that lets you pick a reference feature on the canvas and then click — or drag-rectangle — individual line/polygon features to rotate them in place.

Parallelizer Plugin on QGIS Plugins Web Portal

Plugin Demo

Table of Contents

Installation

  1. Open QGIS
  2. Go to PluginsManage and Install Plugins
  3. Search for “Parallelizer”
  4. Click Install Plugin

Installation Guide

Method 2: Manual Installation

  1. Download the plugin from the QGIS Plugins Repository
  2. Extract to your QGIS plugins directory
  3. Restart QGIS and enable the plugin

Quick Start

Batch (Processing algorithm)

  1. Access the Plugin: Go to ProcessingToolboxParallelizer
  2. Select Input Layers: Choose your target layer (line or polygon) and a reference layer (line or polygon)
  3. Configure Parameters: Set distance and angle thresholds as needed
  4. Run: Execute the algorithm to generate aligned features

How to Access

Interactive (map tool)

  1. Open the Parallelizer toolbar (also reachable from VectorParallelizer) and click the Parallel to Line (interactive) action.
  2. Click a line or polygon feature — or drag a rectangle over one — to set it as the reference. The reference is highlighted on the canvas (polygons get an outline plus translucent fill); if both a line and a polygon are under the click, the line wins.
  3. Toggle editing on the layers you want to modify, then either click a single line/polygon to rotate it, or drag a rectangle to rotate every line/polygon feature that intersects it across all editable visible layers.
  4. Use the Settings… action on the same toolbar to choose between rotation strategies (currently Rotate by longest segment). Settings persist via QSettings.
  5. Right-click or press Esc to clear the reference; press Esc again to deactivate the tool.

Features

Algorithm

Polygon targets

The plugin processes each polygon using the following steps:

  1. Closest Reference Selection: Finds the reference feature (line or polygon) whose geometry is the nearest neighbor of the polygon centroid

  2. Distance Check: If Max distance from reference > 0 and the polygon-to-reference geometry distance exceeds it → skip rotation (note: when the target polygon overlaps the reference polygon, the distance is 0 and rotation runs even at small thresholds)

  3. Vertex Analysis: Identifies the polygon vertex closest to the nearest reference

  4. Segment Evaluation: Takes the two polygon segments adjacent to that vertex

  5. Angle Calculation: Computes the signed angle (delta azimuth) between the closest reference segment (any ring of a polygon reference counts) and each adjacent polygon segment

  6. Rotation Decision (each delta is compared against Max angle):
    • If both deltas are within Max angle:
      • Longest segment mode: Rotates by the delta of the longer segment (falls back to smallest delta if lengths are equal)
      • Default mode: Rotates by the smaller delta
    • If only one delta is within Max angle: Rotates by that delta
    • If neither delta is within Max angle: No rotation is applied
    • Rotations whose magnitude is effectively zero are skipped (avoids spurious _rotated=True)
  7. Output Generation: Writes the (possibly rotated) geometry with a _rotated boolean attribute

Default Usage

Line targets

For line targets, one segment of the target line is selected — the longest when Rotate by longest segment is enabled, otherwise the segment whose delta-azimuth to the closest reference segment is smallest. The whole line is rotated around its centroid by that delta, unless the delta exceeds Max angle (in which case no rotation is applied).

Keynotes

Rotated Field

Configuration

Max Distance from Reference

When set to 0.0, all features are processed regardless of distance.

Distance Configuration

Max Angle for Rotation

Angle Configuration

Rotate by Longest Segment

Longest Segment Option

Skip Multipart Features

Usage Examples

Basic Usage

Input: Building polygons + Road centerlines
Output: Buildings aligned parallel to the nearest roads

Advanced Filtering

Max Distance: 50.0 (meters)
Max Angle: 45.0 (degrees)
Result: Only buildings within 50 m of roads, with rotation ≤ 45°

Requirements

Compatibility

Best Practices

⚠️ Important: Validate and fix geometry errors before running the plugin for optimal results.

  1. Prepare Data: Ensure target and reference layers are in the same CRS
  2. Fix Geometries: Use Processing ToolboxVector geometryFix Geometries
  3. Test Parameters: Start with default settings on a small dataset
  4. Batch Process: Apply to full dataset with optimized parameters

Performance Tips

Development

See DEVELOPMENT.md for detailed development setup and contribution guidelines.

License

Copyright (C) 2016-2026 by Andrii Liekariev

This project is licensed under the GNU General Public License v2.0 or later.

Support


Made with ❤️ for the QGIS community